emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole 53641280fb 3/6: Remove recursive call of hbut


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 53641280fb 3/6: Remove recursive call of hbut:act from ibut-to-text, in most cases
Date: Sat, 15 Jan 2022 18:57:39 -0500 (EST)

branch: externals/hyperbole
commit 53641280fb2b5cca0eb859b89d4f682739d8f711
Author: Robert Weiner <rsw@gnu.org>
Commit: Robert Weiner <rsw@gnu.org>

    Remove recursive call of hbut:act from ibut-to-text, in most cases
---
 ChangeLog           |  6 ++++++
 HY-TALK/HY-TALK.org |  2 +-
 hbut.el             | 30 +++++++++++++++++++++++++++++-
 hib-kbd.el          |  5 +++++
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4ad8e0b7f1..ada675d92b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-01-11  Bob Weiner  <rsw@gnu.org>
+
+* hbut.el (hbut:act): If point is within the button to be activated, prevent
+    ibut:to-text call which recursively calls hbut:act and can cause problems
+    with key series buttons at least.  Much more efficient in most cases.
+
 2022-01-09  Bob Weiner  <rsw@gnu.org>
 
 * topwin.py: Update to Python 3.7 or greater.
diff --git a/HY-TALK/HY-TALK.org b/HY-TALK/HY-TALK.org
index 897c6ad85a..3c2bb0aa98 100644
--- a/HY-TALK/HY-TALK.org
+++ b/HY-TALK/HY-TALK.org
@@ -361,7 +361,7 @@ they can be quickly collapsed and re-organized in standard 
ways.
 
      In practice, fiddling with the frame sizes sounds like:
      'Hyperbole Frame Control. Press Period. Numeral 20. Go left
-     ten. Press H. Press W. Press Q.' It’s just… great.  I can’t say
+     ten. Press H. Press W. Press Q.' It’s just great.  I can’t say
      enough nice things about it. I always know I’ve found a killer
      piece of functionality when I find myself desperately wishing I
      had it everywhere."
diff --git a/hbut.el b/hbut.el
index 1f03b8a37c..bc98a785a8 100644
--- a/hbut.el
+++ b/hbut.el
@@ -855,7 +855,35 @@ Default is 'hbut:current."
         (let ((orig-point (point-marker))
               text-point)
           (when (ibut:is-p hbut)
-            (ibut:to-text (hattr:get hbut 'lbl-key)))
+            ;; Determine whether point is already within hbut; if
+            ;; not, it is moved there.
+            ;;
+            ;; The next line returns the lbl-key of the current
+            ;; button only if point is within the optional name,
+            ;; otherwise, nil.
+            (let* ((lbl-key-start-end (ibut:label-p nil nil nil t t))
+                   (lbl-key (nth 0 lbl-key-start-end))
+                   (delim-text-start (or (nth 1 lbl-key-start-end)
+                                         (hattr:get hbut 'lbl-start)))
+                   (delim-text-end (or (nth 2 lbl-key-start-end)
+                                      (hattr:get hbut 'lbl-end))))
+              (if (and lbl-key
+                       (or (equal (hattr:get hbut 'loc) (current-buffer))
+                           (equal (hattr:get hbut 'loc) buffer-file-name))
+                       (equal lbl-key (hattr:get hbut 'lbl-key)))
+                  (unless (and delim-text-start delim-text-end
+                               (< delim-text-start (point))
+                               (>= delim-text-end (point)))
+                    (goto-char delim-text-start)
+                    (skip-chars-forward "^-_a-zA-Z0-9"))
+                ;; Here handle when there is no name preceding the
+                ;; implicit button.
+                (unless (and (or (equal (hattr:get hbut 'loc) (current-buffer))
+                                 (equal (hattr:get hbut 'loc) 
buffer-file-name))
+                             delim-text-start delim-text-end
+                             (< delim-text-start (point))
+                             (>= delim-text-end (point)))
+                  (ibut:to-text (hattr:get hbut 'lbl-key))))))
           (setq text-point (point-marker))
           (prog1 (apply hrule:action
                         (hattr:get hbut 'actype)
diff --git a/hib-kbd.el b/hib-kbd.el
index ed9ceeb021..876d742a22 100644
--- a/hib-kbd.el
+++ b/hib-kbd.el
@@ -121,6 +121,11 @@ Any key sequence must be a string of one of the following:
                   (when (memq (char-before start) '(nil ?\ ?\t ?\n ?\j ?\f 
?\"))
                     (when (and (stringp key-series)
                                (not (eq key-series "")))
+                      ;; Replace any ${} internal or env vars; leave
+                      ;; $VAR untouched for the shell to evaluate.
+                      (let ((hpath:variable-regexp "\\${\\([^}]+\\)}"))
+                        (setq key-series (hpath:substitute-value key-series)))
+
                       (setq key-series (kbd-key:normalize key-series)
                             binding (kbd-key:binding key-series)))
                     (and (stringp key-series)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]