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

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

[elpa] externals/transient 784887b781 14/41: Account for t as transient-


From: Jonas Bernoulli
Subject: [elpa] externals/transient 784887b781 14/41: Account for t as transient-suffix for nested prefixes
Date: Sun, 12 Nov 2023 20:04:08 -0500 (EST)

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

    Account for t as transient-suffix for nested prefixes
    
    When the prefix's `transient-suffix' is t, and the current prefix
    is a sub-prefix, then suffixes have to use `transient--do-return',
    to exit the sub-prefix but not the outer prefix.
    
    Previously this only worked if the value of that slot was that
    predicate itself, but that must be avoided because it is only
    suitable for suffixes, not infixes and sub-prefixes.
---
 lisp/transient.el | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index 1e83c33eef..40ea33414d 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1756,8 +1756,9 @@ of the corresponding object."
     map))
 
 (defun transient--make-predicate-map ()
-  (let ((default (oref transient--prefix transient-suffix))
-        (map (make-sparse-keymap)))
+  (let* ((default (oref transient--prefix transient-suffix))
+         (return (eq default t))
+         (map (make-sparse-keymap)))
     (set-keymap-parent map transient-predicate-map)
     (when (memq (oref transient--prefix transient-non-suffix)
                 '(nil transient--do-warn transient--do-noop))
@@ -1772,24 +1773,26 @@ of the corresponding object."
           (define-key map (vector cmd) #'transient--do-warn-inapt))
          ((slot-boundp obj 'transient)
           (define-key map (vector cmd)
-            (pcase (list kind (oref obj transient))
-              ('(prefix   t) #'transient--do-recurse)
-              ('(prefix nil) #'transient--do-replace)
-              ('(infix    t) #'transient--do-stay)
-              ('(suffix   t) #'transient--do-call)
-              (`(,_     nil) #'transient--do-exit)
-              (`(,_     ,do) do))))
+            (pcase (list kind (oref obj transient) return)
+              (`(prefix   t ,_) #'transient--do-recurse)
+              (`(prefix nil ,_) #'transient--do-replace)
+              (`(infix    t ,_) #'transient--do-stay)
+              (`(suffix   t ,_) #'transient--do-call)
+              ('(suffix nil  t) #'transient--do-return)
+              (`(,_     nil ,_) #'transient--do-exit)
+              (`(,_     ,do ,_) do))))
          ((not (lookup-key transient-predicate-map (vector cmd)))
           (define-key map (vector cmd)
-            (pcase (list kind default)
-              (`(prefix ,(or 'transient--do-stay 'transient--do-call))
+            (pcase (list kind default return)
+              (`(prefix ,(or 'transient--do-stay 'transient--do-call) ,_)
                #'transient--do-recurse)
-              ('(prefix   t) #'transient--do-recurse)
-              (`(prefix  ,_) #'transient--do-replace)
-              (`(infix   ,_) #'transient--do-stay)
-              ('(suffix   t) #'transient--do-call)
-              ('(suffix nil) #'transient--do-exit)
-              (`(suffix ,do) do)))))))
+              (`(prefix   t ,_) #'transient--do-recurse)
+              (`(prefix  ,_ ,_) #'transient--do-replace)
+              (`(infix   ,_ ,_) #'transient--do-stay)
+              (`(suffix   t ,_) #'transient--do-call)
+              ('(suffix nil  t) #'transient--do-return)
+              (`(suffix nil ,_) #'transient--do-exit)
+              (`(suffix ,do ,_) do)))))))
     map))
 
 (defun transient--make-redisplay-map ()
@@ -2547,7 +2550,7 @@ If there is no parent prefix, then just call the command."
         (when (and (slot-boundp suffix-obj 'transient)
                    (memq (oref suffix-obj transient)
                          (list t #'transient--do-recurse)))
-          (oset prefix-obj transient-suffix 'transient--do-return))))))
+          (oset prefix-obj transient-suffix t))))))
 
 (defun transient--do-replace ()
   "Call the transient prefix command, replacing the active transient."



reply via email to

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