branch: externals/hyperbole
commit d3203181fc665808a09e0183e872e768a0428b5e
Author: bw <[email protected]>
Commit: bw <[email protected]>
Fix `hywiki-word-at' and `hypb:in-string-p' issues
---
ChangeLog | 15 +++++++++++++++
hypb.el | 26 +++++++++++++-------------
hywiki.el | 35 ++++++++++++++++++-----------------
3 files changed, 46 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a44d873914..663d10fc92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-04-18 Bob Weiner <[email protected]>
+
+* hywiki.el (hywiki-word-at): Remove unneeded clause that checks for opening
+ delimiters a second time within a delimited set of WikiWords. This fixes
+ an error of returning the prior WikiWord within a delimited group due to
+ moving back past leading whitespace.
+
+* hypb.el (hypb:in-string-p): Fix by removing `syntax-ppss' calls and using
+ regexp searches for double quoted delimiters instead.
+
+2025-04-15 Bob Weiner <[email protected]>
+
+* hypb.el (hypb:in-string-p): Add optional 'max-lines' arg to limit the
+ search to that many full buffer lines starting with the line beginning
+
2025-04-14 Bob Weiner <[email protected]>
* test/hui-mouse-tests.el (hui-mouse-tests--hkey-alist): Update with new
diff --git a/hypb.el b/hypb.el
index 1ca259e9d6..80aab6ae5d 100644
--- a/hypb.el
+++ b/hypb.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 6-Oct-91 at 03:42:38
-;; Last-Mod: 12-Apr-25 at 16:58:59 by Bob Weiner
+;; Last-Mod: 18-Apr-25 at 21:38:23 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -663,18 +663,18 @@ This will this install the Emacs helm package when
needed."
(error "(hypb:hkey-help-file): Non-existent file: \"%s\""
help-file))))))
-(defun hypb:in-string-p ()
- "Return non-nil iff point is in the first line of a double quoted string."
- (if (derived-mode-p 'change-log-mode)
- ;; limited to single line strings; count must be odd to be
- ;; inside a string
- (when (cl-oddp (count-matches "\"" (line-beginning-position) (point)))
- (save-excursion (search-backward "\"" (line-beginning-position) t)))
- (syntax-ppss-flush-cache (line-beginning-position))
- (let ((sexp-state-list (syntax-ppss)))
- (when (eq ?\" (nth 3 sexp-state-list)) ; in a double quoted string
- ;; return start of str position (opening quote)
- (nth 8 sexp-state-list)))))
+(defun hypb:in-string-p (&optional max-lines)
+ "Return t iff point is within a double quoted string."
+ (save-restriction
+ (when (integerp max-lines)
+ (narrow-to-region (line-beginning-position)
+ (line-end-position max-lines)))
+ ;; Don't use `syntax-ppss' here as it fails to ignore backquoted
+ ;; double quote characters in strings and doesn't work in
+ ;; `change-log-mode' due to its syntax-table.
+ (and (cl-oddp (count-matches "\\(^\\|[^\\]\\)\"" (point-min) (point)))
+ (save-excursion (re-search-forward "\\(^\\|[^\\]\\)\"" nil t))
+ t)))
(defun hypb:indirect-function (obj)
"Return the function at the end of OBJ's function chain.
diff --git a/hywiki.el b/hywiki.el
index 3c9ed8dc4d..ca4a901272 100644
--- a/hywiki.el
+++ b/hywiki.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 21-Acpr-24 at 22:41:13
-;; Last-Mod: 13-Apr-25 at 02:03:01 by Bob Weiner
+;; Last-Mod: 18-Apr-25 at 21:53:17 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -3045,22 +3045,23 @@ or this will return nil."
;; Move to start of wikiword reference
(skip-chars-backward "-_*#:[:alnum:]" bol)
(skip-syntax-backward "-" bol))
- (when (and (or (bolp)
- (string-match (regexp-quote
- (char-to-string
(char-before)))
- "\[\(\{\<\""))
- (progn
- (skip-chars-forward " \t")
- (hywiki-maybe-at-wikiword-beginning))
- (looking-at (concat
- hywiki-word-regexp
-
"\\(#[^][#()<>{}\"\n\r\f]+\\)?"
-
hywiki-word-line-and-column-numbers-regexp "?"))
- ;; Can't be followed by a # character
- (/= (or (char-after (match-end 0)) 0)
- ?#)
- (progn (goto-char (match-end 0))
- (skip-syntax-forward "-")))
+ (when (and
+ ;; (or (bolp)
+ ;; (string-match (regexp-quote
+ ;; (char-to-string
(char-before)))
+ ;; "\[\(\{\<\""))
+ (progn
+ (skip-chars-forward " \t")
+ (hywiki-maybe-at-wikiword-beginning))
+ (looking-at (concat
+ hywiki-word-regexp
+ "\\(#[^][#()<>{}\"\n\r\f]+\\)?"
+
hywiki-word-line-and-column-numbers-regexp "?"))
+ ;; Can't be followed by a # character
+ (/= (or (char-after (match-end 0)) 0)
+ ?#)
+ (progn (goto-char (match-end 0))
+ (skip-syntax-forward "-")))
(setq start (match-beginning 0)
end (match-end 0)
;; No following char