[Top][All Lists]

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

[elpa] externals/transient 769219b 4/5: Enable section movement

From: Jonas Bernoulli
Subject: [elpa] externals/transient 769219b 4/5: Enable section movement
Date: Mon, 26 Jul 2021 16:11:45 -0400 (EDT)

branch: externals/transient
commit 769219b5f5757f1373a28e993f36b6a41c778651
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Enable section movement
    This doesn't actually implement any section movement commands.
    It merely makes it possible to implement such commands without
    having to modify or advice transient.
    See https://github.com/magit/magit/issues/4438.
    This stops placing the cursor on the first suffix.  Instead the
    cursor is now left at the beginning of the buffer, on the first
    section heading.  This is beneficial for blind users who rely
    on a screen reader.  The old hack that moved the cursor did not
    only do that initially, it actually prevented from ever moving
    before the first suffix.
 lisp/transient.el | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index cca092f..9af641e 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -2876,7 +2876,8 @@ have a history of their own.")
             (display-buffer buf transient-display-buffer-action)))
     (with-selected-window transient--window
       (when transient-enable-popup-navigation
-        (setq focus (button-get (point) 'command)))
+        (setq focus (or (button-get (point) 'command)
+                        (transient--heading-at-point))))
       (set-window-hscroll transient--window 0)
       (set-window-dedicated-p transient--window t)
@@ -3448,13 +3449,23 @@ See `forward-button' for information about N."
     (forward-button n t)))
 (defun transient--goto-button (command)
-  (if (not command)
-      (forward-button 1)
+  (cond
+   ((stringp command)
+    (when (search-forward command nil t)
+      (goto-char (match-beginning 0))))
+   (command
     (while (and (ignore-errors (forward-button 1))
                 (not (eq (button-get (button-at (point)) 'command) command))))
     (unless (eq (button-get (button-at (point)) 'command) command)
       (goto-char (point-min))
-      (forward-button 1))))
+      (forward-button 1)))))
+(defun transient--heading-at-point ()
+  (and (eq (get-text-property (point) 'face) 'transient-heading)
+       (let ((beg (line-beginning-position)))
+         (buffer-substring-no-properties
+          beg (next-single-property-change
+               beg 'face nil (line-end-position))))))
 ;;;; Popup Isearch

reply via email to

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