branch: externals/hyperbole
commit 71f0bac2ac2c7b370959eaa209c062a34ed3aa13
Author: bw <r...@gnu.org>
Commit: bw <r...@gnu.org>

    Fix hkey-alist vertico handling and more
    
    Fix hypb:in-string-p when in change-log-mode.
    Fix test of closing delimiters after HyWikiWords.
    Fix 'hywiki-at-range-delimiter' in modes where scan-sexp is disabled.
    Add "test/hui-mouse-tests.el".
---
 ChangeLog            | 29 +++++++++++++++++++++++++++++
 hmouse-drv.el        | 15 ++++++++++++++-
 hui-mouse.el         | 29 ++++++++++++++---------------
 hypb.el              | 20 ++++++++++++--------
 hywiki.el            |  4 ++--
 test/MANIFEST        |  1 +
 test/hywiki-tests.el |  9 +++++----
 7 files changed, 77 insertions(+), 30 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bc3efe8854..c34f33b848 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2025-04-12  Bob Weiner  <r...@gnu.org>
+
+* test/hywiki-tests.el (hywiki-tests--wikiword-step-check): Fix to not expect
+    closing paren delimiter as part of the WikiWord.
+
+* hywiki.el (hywiki-at-range-delimiter): Handle if scan-sexps returns nil then
+    return '(nil nil).
+
+* hypb.el (hypb:in-string-p): Update to handle change-log-mode which disables
+    syntax parsing and so is handled with a string search.
+
+* hmouse-drv.el (hkey-actions): Add for use in Hyperbole testing and call from
+    "test/hui-mouse-tests.el".
+
+* hui-mouse.el (hkey-alist): Ignore 'ivy-mode' if 'vertico-mode' is actively
+    prompting for an argument and allow for this outside of the minibuffer
+    since vertico may prompt within another buffer.  Also, ignore the value
+    of hargs:reading-type here, otherwise, it will not catch all uses of
+    'vertico-mode'.
+
+2025-04-07  Mats Lidell  <ma...@gnu.org>
+
+* test/MANIFEST: Add hui-mouse-tests.el
+
+* test/hui-mouse-tests.el (hui-mouse-tests--hkey-alist): Verify a
+    predicate setting leads to the proper action.
+    (hui-mouse-tests--hkey-get-action): Helper that gets primary action
+    and assist action from hkey-alist for the predicates in effect.
+
 2025-04-06  Bob Weiner  <r...@gnu.org>
 
 * test/hywiki-tests.el (hywiki-tests--wikiword-identified-in-emacs-lisp-mode):
diff --git a/hmouse-drv.el b/hmouse-drv.el
index bacb22e1ce..c2ea344f78 100644
--- a/hmouse-drv.el
+++ b/hmouse-drv.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    04-Feb-90
-;; Last-Mod:     22-Feb-25 at 11:52:57 by Bob Weiner
+;; Last-Mod:     12-Apr-25 at 15:47:32 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -992,6 +992,19 @@ frame instead."
           (mouse-drag-frame-move start-event)
         (mouse-drag-frame start-event 'move))))))
 
+(defun hkey-actions ()
+  "Return the cons of the Action and Assist Key actions at point.
+Useful in testing Smart Key contexts."
+  (let ((hkey-forms hkey-alist)
+       pred-value hkey-actions hkey-form pred)
+    (while (and (null pred-value) (setq hkey-form (car hkey-forms)))
+      (if (setq hkey-actions (cdr hkey-form)
+               pred (car hkey-form)
+               pred-value (hypb:eval-debug pred))
+          nil
+       (setq hkey-forms (cdr hkey-forms))))
+    hkey-actions))
+
 (defun hkey-debug (pred pred-value hkey-action)
   "Display a message with the context and values from Smart Key activation."
   (message (concat "(HyDebug) %sContext: %s; %s: %s; Buf: %s; Mode: %s; 
MinibufDepth: %s\n"
diff --git a/hui-mouse.el b/hui-mouse.el
index 8f5b775234..30af357e44 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    04-Feb-89
-;; Last-Mod:     22-Feb-25 at 16:18:02 by Bob Weiner
+;; Last-Mod:     12-Apr-25 at 14:29:25 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -253,20 +253,19 @@ Its default value is `smart-scroll-down'.  To disable it, 
set it to
      . ((smart-push-button nil (mouse-event-p last-command-event))
        . (smart-push-button-help nil (mouse-event-p last-command-event))))
     ;;
-    ;; If in the minibuffer and reading an argument with vertico
-    ;; run the vertico command on {M-RET} which accepts the first
-    ;; line of minibuffer input, rather than any candidate.
-    ((and hargs:reading-type
-         (> (minibuffer-depth) 0)
-         (eq (selected-window) (minibuffer-window))
-         (not (bound-and-true-p ivy-mode))
-         (and (bound-and-true-p vertico-mode)
-              ;; Is vertico prompting for an argument?
-              (vertico--command-p nil (current-buffer))))
-     . ((vertico-exit-input) . (vertico-exit-input)))
-    ;;
-    ;; If in the minibuffer and reading an argument (aside from
-    ;; with vertico or ivy), accept argument or give completion help.
+    ;; If in a window reading an argument with vertico, run the
+    ;; vertico command on {M-RET} which by default accepts the
+    ;; existing input at the prompt rather than the candidate pointed
+    ;; to.
+    ((and (bound-and-true-p vertico-mode)
+         ;; Is vertico prompting for an argument?
+         (vertico--command-p nil (current-buffer)))
+     . ((funcall (lookup-key vertico-map (kbd "M-RET"))) 
+       . (funcall (lookup-key vertico-map (kbd "M-RET")))))
+    ;;
+    ;; If in the minibuffer and reading a non-menu Hyperbole argument
+    ;; (aside from with vertico or ivy), accept the argument or give
+    ;; completion help.
     ((and hargs:reading-type
          (> (minibuffer-depth) 0)
          (eq (selected-window) (minibuffer-window))
diff --git a/hypb.el b/hypb.el
index afa75dc6ac..1ca259e9d6 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:     15-Mar-25 at 09:06:58 by Bob Weiner
+;; Last-Mod:     12-Apr-25 at 16:58:59 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -664,13 +664,17 @@ This will this install the Emacs helm package when 
needed."
                      help-file))))))
 
 (defun hypb:in-string-p ()
-  "Return non-nil iff point is in a double quoted string."
-  (syntax-ppss-flush-cache (line-beginning-position))
-  (let ((sexp-state-list (syntax-ppss)))
-    ;; if in a string
-    (when (nth 3 sexp-state-list)
-      ;; return start of str position (opening quote)
-      (nth 8 sexp-state-list))))
+  "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:indirect-function (obj)
   "Return the function at the end of OBJ's function chain.
diff --git a/hywiki.el b/hywiki.el
index 11ea2281c2..0178f46bae 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:      6-Apr-25 at 18:27:25 by Bob Weiner
+;; Last-Mod:     12-Apr-25 at 17:04:06 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1718,7 +1718,7 @@ This includes the delimiters: (), {}, <>, [] and \"\" 
(double quotes)."
                               (not (hypb:in-string-p)))
                          (list (point) (scan-sexps (point) 1))))
                      (error nil))))
-       (if result
+       (if (and result (integerp (nth 0 result)) (integerp (nth 1 result)))
            (sort result #'<)
          (list nil nil))))))
 
diff --git a/test/MANIFEST b/test/MANIFEST
index 00dbe43c1e..37356fdd7b 100644
--- a/test/MANIFEST
+++ b/test/MANIFEST
@@ -13,6 +13,7 @@ hpath-tests.el          - unit tests for hpath
 hsettings-test.el       - unit tests for hsettings
 hsys-org-tests.el       - hsys-org tests
 hui-mini-tests.el       - hui-mini tests
+hui-mouse-tests.el      - hui-mouse and hkey-alist Action Key tests
 hui-register-tests.el   - test for hui-register
 hui-select-tests.el     - hui-select tests
 hui-tests.el            - tests for hui.el Hyperbole UI
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index c762ba7b52..efc1071d6a 100644
--- a/test/hywiki-tests.el
+++ b/test/hywiki-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:    18-May-24 at 23:59:48
-;; Last-Mod:     12-Apr-25 at 13:16:10 by Bob Weiner
+;; Last-Mod:     12-Apr-25 at 17:00:40 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1292,7 +1292,8 @@ up the test."
    (save-excursion
      (unwind-protect
          (progn
-           (should (hact 'kbd-key "C-u C-h hhc MyWiki RET n (emacs) RET"))
+           ;; (should (hact 'kbd-key "C-u C-h hhc MyWiki RET n (emacs) RET"))
+           (should (hact 'kbd-key "C-u C-h hhcn (emacs) RET"))
            (hy-test-helpers:consume-input-events))
        (kill-buffer "*info*")))))
 
@@ -1440,8 +1441,8 @@ the function is called."
     (("HiHo#s " . t) (" n"))
     ;; With delimiters
     (("(HiHo#s" . "HiHo#s") (" " . "HiHo#s"))
-    (("(HiHo#s" . "HiHo#s") (")" . "HiHo#s)")) ; Delimiter part of WikiWord. 
See below too.
-    (("(HiHo#s" . "HiHo#s") ("-" . "HiHo#s-") ("n" . "HiHo#s-n") (")" . 
"HiHo#s-n)"))
+    (("(HiHo#s" . "HiHo#s") (")" . "HiHo#s")) ; Delimiter part of WikiWord. 
See below too.
+    (("(HiHo#s" . "HiHo#s") ("-" . "HiHo#s-") ("n" . "HiHo#s-n") (")" . 
"HiHo#s-n"))
     ;; Insert and delete between WikiWords
     (("HiHo" . t) (p3 . t) (" " . "Hi") (p4 . "Ho") (-1 . "HiHo"))
     (("Hiho" . t) (p3 . t) (" " . "Hi") (p4) (-1 . "Hiho"))

Reply via email to