branch: externals/hyperbole
commit 18da353802bbd89d5f48fdb266a1e43be655f317
Merge: ec9947eb7d 17fb3e5049
Author: Robert Weiner <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #879 from rswgnu/rsw
hywiki.el - Fix a number of completion issues; hyrolo-mode - Make the
match buffer's 'hyrolo-mode' a special mode
---
ChangeLog | 23 ++++++++++++++++++++++-
hyrolo.el | 4 +++-
hywiki.el | 60 +++++++++++++++++++++++++++++++++++++++---------------------
3 files changed, 64 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index da3c001285..315160385a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2026-03-01 Bob Weiner <[email protected]>
+
+* hywiki.el (hywiki-maybe-highlight-references): Fix to include #section
+ spaces only if the delimiter is at the start of the WikiWord ref.
+ (hywiki--end-pos): Add and set in 'hywiki-completion-at-point'
+ to pass to 'hywiki-completion-exit-function'. This handles when point
+ is moved to before the completion prefix, it is cancelled and the exit
+ function should not insert anything or move point any further.
+ (hywiki-completion-at-point): Fix completion after # suffix by
+ stripping the suffix off the WikiWord ref when used as the page name
+ in the grep 'cmd'.
+ (hywiki-word-at): Make char after # optional so when doing
+ completion and # is followed by a closing delimiter, it does not stop
+ completing because of failure to recognize the WikiWord reference.
+
+2026-02-28 Bob Weiner <[email protected]>
+
+* hyrolo.el (hyrolo-mode): Make the match buffer's 'hyrolo-mode' a special
+ mode. HyWiki buttons will never be active therein since every name
+ would trigger as a new, potential HyWiki word.
+
2026-02-28 Mats Lidell <[email protected]>
* test/hywiki-tests.el (hywiki-tests--get-page-headings):
@@ -33,7 +54,7 @@
first or the difference will always be nil.
hsys-consult.el (hsys-consult-require-version): Add to make
'hsys-consult-flag'
and this version check callable from other libraries.
- (hsys-consult-grep, hsys-consult--grep-paths): Call above
+ (hsys-consult-grep, hsys-consult--grep-paths): Call above
new function.
* hywiki.el (hywiki-consult-page-and-headline): Call above new function.
diff --git a/hyrolo.el b/hyrolo.el
index a6f7a07211..d291a97bb1 100644
--- a/hyrolo.el
+++ b/hyrolo.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 7-Jun-89 at 22:08:29
-;; Last-Mod: 30-Dec-25 at 14:42:32 by Mats Lidell
+;; Last-Mod: 28-Feb-26 at 23:10:24 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -2253,6 +2253,8 @@ Calls the functions given by `hyrolo-mode-hook'.
\\{hyrolo-mode-map}"
(interactive)
(unless (eq major-mode 'hyrolo-mode)
+ ;; The mode controls the data in its buffers and it is non-editable
+ (put 'hyrolo-mode 'mode-class 'special)
(push (cons (substring hyrolo-hdr-regexp 1) 1) outline-heading-alist)
(push (cons (if (boundp 'hbut:source-prefix)
hbut:source-prefix
diff --git a/hywiki.el b/hywiki.el
index 900366d6d9..a9e42579d6 100644
--- a/hywiki.el
+++ b/hywiki.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 21-Apr-24 at 22:41:13
-;; Last-Mod: 28-Feb-26 at 15:37:59 by Bob Weiner
+;; Last-Mod: 1-Mar-26 at 01:28:37 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -198,12 +198,13 @@ checks it to determine if any buffer modification has
occurred or not.")
Each such key self-inserts before highlighting any prior HyWikiWord
in `hywiki-mode'.")
-(defvar hywiki--delimiter-hasht (hash-make '(("\"" . ?\")
- ("\'" . ?\')
- ("{" . ?})
- ("[" . ?\])
- ("<" . ?>)
- ("(" . ?\))) t)
+(defconst hywiki--delimiter-hasht (hash-make '(("\"" . ?\")
+ ("\'" . ?\')
+ ("{" . ?})
+ ("[" . ?\])
+ ("<" . ?>)
+ ("(" . ?\)))
+ t)
"Delimiter htable with (open-delim-string . close-delim-char) key-value
pairs.")
(defvar hywiki--directory-checksum ""
@@ -255,6 +256,7 @@ Group 1 is the entire HyWikiWord#section:Lnum:Cnum
expression.")
(defvar-local hywiki--buttonize-start (make-marker)) ;; This must always stay
a marker
(defvar-local hywiki--buttonize-range nil)
(defvar-local hywiki--char-before nil)
+(defvar-local hywiki--end-pos nil)
(defvar-local hywiki--end nil)
(defvar-local hywiki--range nil)
(defvar-local hywiki--start nil)
@@ -1496,6 +1498,7 @@ exists."
(defun hywiki-completion-at-point ()
"Complete a HyWiki reference at point.
Each candidate is an alist with keys: file, line, text, and display."
+ (setq hywiki--end-pos nil)
(let* ((ref-start-end (and (hywiki-active-in-current-buffer-p)
(not (hywiki-non-hook-context-p))
(hywiki-word-at t t)))
@@ -1505,7 +1508,7 @@ Each candidate is an alist with keys: file, line, text,
and display."
(when start
(let* ((default-directory hywiki-directory)
(cmd (format "grep -nEH '^([ \t]*\\*+|#\\+TITLE:) +' ./*%s*%s"
- (regexp-quote ref)
+ (hywiki-word-strip-suffix ref)
hywiki-file-suffix))
(output (shell-command-to-string cmd))
(lines (split-string output "\n" t))
@@ -1515,7 +1518,8 @@ Each candidate is an alist with keys: file, line, text,
and display."
(nconc (hywiki-get-page-list)
(mapcar #'hywiki-format-grep-to-reference
lines))))))
(when candidate-alist
- (setq hywiki--char-before (char-before start))
+ (setq hywiki--char-before (char-before start)
+ hywiki--end-pos end)
(list start end candidate-alist
:exclusive 'no
;; For company, allow any non-delim chars in prefix
@@ -2703,11 +2707,23 @@ whenever `hywiki-mode' is enabled/disabled."
(skip-syntax-forward "^-\)$\>._\"\'"))
(skip-chars-forward "-_*[:alnum:]")
(unless (zerop (skip-chars-forward "#:"))
- (skip-chars-forward (if
(save-restriction
- (widen)
-
(hywiki-delimited-p))
- "-_*:
\t[:alnum:]"
-
"-_*:[:alnum:]")))
+ (skip-chars-forward
+ (if (save-restriction
+ (widen)
+ (and (hywiki-delimited-p)
+ ;; Only if delimiter is
+ ;; the char preceding
+ ;; the start of the
+ ;; WikiWord do we skip
+ ;; over spaces to find
+ ;; the #section.
+ (hash-get
+ (char-to-string
+ (or (char-before (or
hywiki--start 0))
+ 0))
+
hywiki--delimiter-hasht)))
+ "-_*: \t[:alnum:]"
+ "-_*:[:alnum:]")))
(setq hywiki--end (point))
;; Don't highlight current-page matches
unless they
;; include a #section.
@@ -3575,7 +3591,7 @@ non-nil or this will return nil."
(hywiki-maybe-at-wikiword-beginning))
(looking-at (concat
hywiki-word-regexp
- "\\(#[^][#()<>{}\"
\t\n\r\f]+\\)?"
+ "\\(#[^][#()<>{}\"
\t\n\r\f]*\\)?"
hywiki-word-line-and-column-numbers-regexp "?"))
;; Can't be followed by a # character
(/= (or (char-after (match-end 0)) 0)
@@ -3966,12 +3982,14 @@ occurs with one of these hooks, the problematic hook is
removed."
(let ((end-delim (when (characterp hywiki--char-before)
(hash-get (char-to-string hywiki--char-before)
hywiki--delimiter-hasht))))
- (if (and end-delim
- (or (>= (point) (point-max))
- (not (eq (char-after (point)) end-delim))))
- (progn (insert end-delim)
- (goto-char (- (point) 2)))
- (goto-char (1- (point)))))
+ (when (and hywiki--end-pos
+ (>= (point) hywiki--end-pos))
+ (if (and end-delim
+ (or (>= (point) (point-max))
+ (not (eq (char-after (point)) end-delim))))
+ (progn (insert end-delim)
+ (goto-char (- (point) 2)))
+ (when end-delim (goto-char (1- (point)))))))
(hywiki-maybe-highlight-reference))
(defun hywiki-word-add-completion-at-point ()