[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole d4a61d9c9f 3/6: hywiki-existing-word ibtype -
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole d4a61d9c9f 3/6: hywiki-existing-word ibtype - fix to always set label and range |
Date: |
Fri, 30 Aug 2024 03:58:26 -0400 (EDT) |
branch: externals/hyperbole
commit d4a61d9c9f812e8fdd22a06b64cb469d11004b7d
Author: bw <rsw@gnu.org>
Commit: bw <rsw@gnu.org>
hywiki-existing-word ibtype - fix to always set label and range
---
ChangeLog | 12 +++++++++++
hibtypes.el | 7 ++++---
hywiki.el | 67 ++++++++++++++++++++++++++++++++++++-------------------------
3 files changed, 56 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 345d9748d6..36f8650a58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
+2024-08-30 Bob Weiner <rsw@gnu.org>
+
+* hywiki.el (hywiki-word-at): Add optional arg 'range-flag' and when non-nil
+ return (wikiword word-start word-end).
+ (hywiki-word-activate): Fix call to 'hywiki-word-at'.
+
2024-08-29 Bob Weiner <rsw@gnu.org>
+* hywiki.el (hywiki-page-exists-p): Use 'range only if 'word' is non-nil.
+ Add 'start' and 'end' optional args to record 'word' position range.
+
+* hibtypes.el (hywiki-existing-word): Fix to set label when a word is given
+ but no position is known for the word.
+
* hactypes.el (link-to-texinfo-node): If 'node' is not a string, set it to
"Top", the first node. If 'file' equals "hyperbole.texi", make the file
name absolute.
diff --git a/hibtypes.el b/hibtypes.el
index 8a3b2346d2..f2f6b4606e 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -1686,10 +1686,11 @@ If a boolean function or variable, display its value."
(defib hywiki-existing-word ()
"When on a HyWiki word with an existing page, display its page and optional
section."
(cl-destructuring-bind (page-name start end)
- (hywiki-page-exists-p 'range)
+ (hywiki-page-exists-p :range)
(when page-name
- (when (and start end)
- (ibut:label-set page-name start end))
+ (if (and start end)
+ (ibut:label-set page-name start end)
+ (ibut:label-set page-name))
(hact 'hywiki-find-page page-name))))
;;; ========================================================================
diff --git a/hywiki.el b/hywiki.el
index 1d58c2ed91..18495823b6 100644
--- a/hywiki.el
+++ b/hywiki.el
@@ -669,13 +669,16 @@ If found, return the full path of the page.
If not on a wiki word and optional prefix ARG is null, emulate an
Action Key press; with a prefix ARG, emulate an Assist Key press."
(interactive "P")
- (let ((word hywiki-word-at))
+ (let ((word (hywiki-word-at)))
(if word
(hywiki-find-page word)
(hkey-either arg))))
-(defun hywiki-word-at (&optional)
+(defun hywiki-word-at (&optional range-flag)
"Return HyWiki word and optional #section at point or nil if not on one.
+With optional RANGE-FLAG non-nil and there is a HyWikiWord at point,
+return the tuple of values: (word word-start word-end) instead of a string,
+
Does not test whether or not a page exists for the HyWiki word; call
`hywiki-page-exists-p' without an argument for that.
@@ -686,9 +689,12 @@ or this will return nil."
(hproperty:char-property-range (point) 'face hywiki-word-face))
(buffer-substring-no-properties (car hywiki--range) (cdr hywiki--range))
(save-excursion
- (let ((wikiword (progn (when (looking-at "\\[\\[")
- (goto-char (+ (point) 2)))
- (ibut:label-p t "[[" "]]"))))
+ (let* ((word-start-end (progn (when (looking-at "\\[\\[")
+ (goto-char (+ (point) 2)))
+ (ibut:label-p t "[[" "]]" range-flag)))
+ (wikiword (if range-flag (car word-start-end) word-start-end))
+ start
+ end)
(if wikiword
;; Handle an Org link [[HyWikiWord]] [[hy:HyWikiWord]] or
[[HyWikiWord#section]].
(progn
@@ -701,7 +707,7 @@ or this will return nil."
hywiki-org-link-type)))
;; Ignore prefixed, typed hy:HyWikiWord since Org mode will
display those.
(when (hywiki-word-is-p wikiword)
- wikiword))
+ (if range-flag word-start-end wikiword)))
;; Handle a HyWiki word with optional #section; if it is an Org
;; link, it may optionally have a hy: link-type prefix.
;; Ignore wikiwords preceded by any non-whitespace
@@ -710,14 +716,17 @@ or this will return nil."
(skip-chars-backward "-_*#[:alnum:]")
(when (hywiki-maybe-at-wikiword-beginning)
(cond ((looking-at hywiki--word-and-buttonize-character-regexp)
- (string-trim
- (buffer-substring-no-properties (match-beginning 0)
- (1- (match-end 0)))))
+ (setq start (match-beginning 0)
+ end (1- (match-end 0))
+ wikiword (string-trim
+ (buffer-substring-no-properties start
end))))
((looking-at (concat
hywiki-word-with-optional-section-regexp "\\'"))
- ;; No following char
- (string-trim
- (buffer-substring-no-properties (match-beginning 0)
- (match-end
0)))))))))))))
+ (setq start (match-beginning 0)
+ end (match-end 0)
+ ;; No following char
+ wikiword (string-trim
+ (buffer-substring-no-properties start
end)))))
+ (if range-flag (list wikiword start end) wikiword)))))))))
(defun hywiki-word-consult-grep (word)
"Use `hywiki-consult-grep' to show occurrences of a prompted for HyWikiWord.
@@ -1292,30 +1301,34 @@ variables."
:follow #'hywiki-find-page
:store #'hywiki-org-link-store))
-(defun hywiki-page-exists-p (&optional word)
+(defun hywiki-page-exists-p (&optional word start end)
"Return an existing HyWiki page name from optional WORD or word at point.
Word may be of form: HyWikiWord#section with an optional #section.
If no such page exists, return nil.
-If WORD is the symbol, 'range, rather than a string, and there is a
-HyWikiWord at point with an existing page, then return the tuple of
-values: (word word-start word-end).
+If WORD is the symbol, :range, and there is a HyWikiWord at point
+with an existing page, then return the tuple of values: (word
+word-start word-end) instead of a string,
When using the word at point, a call to
-`hywiki-active-in-current-buffer-p' at point must return non-nil or
-this will return nil."
+`hywiki-active-in-current-buffer-p' at point must return non-nil
+or this will return nil."
(setq hywiki--page-name word)
(if (or (stringp word)
(setq word (hywiki-word-at)))
- (progn (setq word (hywiki-page-strip-section word))
- (unless (hywiki-get-page word)
- (setq word nil)))
+ (unless (hywiki-get-page (hywiki-page-strip-section word))
+ (setq word nil))
(setq word nil))
- (if (eq hywiki--page-name 'range)
- (if (setq hywiki--range
- (hproperty:char-property-range (point) 'face hywiki-word-face))
- (list word (car hywiki--range) (cdr hywiki--range))
- (list word nil nil))
+ (when (and (listp word) (= (length word) 3))
+ (setq start (nth 1 word)
+ end (nth 2 word)
+ word (nth 0 word)))
+ (if (eq hywiki--page-name :range)
+ (if (and word (setq hywiki--range
+ (hproperty:char-property-range
+ (point) 'face hywiki-word-face)))
+ (list word (or start (car hywiki--range)) (or end (cdr
hywiki--range)))
+ (list word start end))
word))
(defun hywiki-page-strip-section (page-name)
- [elpa] externals/hyperbole updated (a7527d1d30 -> 5dbd852f10), ELPA Syncer, 2024/08/30
- [elpa] externals/hyperbole 95a590eb1e 2/6: hyp-manual - Add this ibtype to display Hyperbole manual, ELPA Syncer, 2024/08/30
- [elpa] externals/hyperbole 0e56e9db54 5/6: Merge branch 'master' into rsw, ELPA Syncer, 2024/08/30
- [elpa] externals/hyperbole a128365535 1/6: man/hyperbole.texi - Add doc for hywiki-existing-word, hywiki-word, ELPA Syncer, 2024/08/30
- [elpa] externals/hyperbole 3a8bdcf0a3 4/6: * hibtypes.el (hyp-manual) - Fix to strip spaces around any section, ELPA Syncer, 2024/08/30
- [elpa] externals/hyperbole 5dbd852f10 6/6: Merge pull request #583 from rswgnu/rsw, ELPA Syncer, 2024/08/30
- [elpa] externals/hyperbole d4a61d9c9f 3/6: hywiki-existing-word ibtype - fix to always set label and range,
ELPA Syncer <=