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

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

[elpa] externals/transient f43aee1a5e 08/41: transient--suffix-prototype


From: Jonas Bernoulli
Subject: [elpa] externals/transient f43aee1a5e 08/41: transient--suffix-prototype: New function
Date: Sun, 12 Nov 2023 20:04:07 -0500 (EST)

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

    transient--suffix-prototype: New function
    
    This makes it possible to use aliases as suffixes but still share the
    settings from the suffix object.  Using an alias is necessary when we
    want to use the same command to different keys and independently
    change only some of the slots inside the prefix definition.
---
 lisp/transient.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index c7246ee612..d0cdd8ae01 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1364,7 +1364,7 @@ See info node `(transient)Modifying Existing Transients'."
          (plist-get plist :command)))))
 
 (defun transient--command-key (cmd)
-  (and-let* ((obj (get cmd 'transient--suffix)))
+  (and-let* ((obj (transient--suffix-prototype cmd)))
     (cond ((slot-boundp obj 'key)
            (oref obj key))
           ((slot-exists-p obj 'shortarg)
@@ -1523,13 +1523,18 @@ probably use this instead:
                            (listify-key-sequence (this-command-keys))))
                   suffixes))
             (car suffixes)))
-    (and-let* ((obj (get (or command this-command) 'transient--suffix))
+    (and-let* ((obj (transient--suffix-prototype (or command this-command)))
                (obj (clone obj)))
       (progn ; work around debbugs#31840
         (transient-init-scope obj)
         (transient-init-value obj)
         obj))))
 
+(defun transient--suffix-prototype (command)
+  (or (get command 'transient--suffix)
+      (seq-some (lambda (cmd) (get cmd 'transient--suffix))
+                (function-alias-p command))))
+
 ;;; Keymaps
 
 (defvar-keymap transient-base-map
@@ -1945,7 +1950,7 @@ value.  Otherwise return CHILDREN as is."
                      (apply class :level level args)
                    (unless (and cmd (symbolp cmd))
                      (error "BUG: Non-symbolic suffix command: %s" cmd))
-                   (if-let ((proto (and cmd (get cmd 'transient--suffix))))
+                   (if-let ((proto (and cmd (transient--suffix-prototype 
cmd))))
                        (apply #'clone proto :level level args)
                      (apply class :command cmd :level level args)))))
         (cond ((not cmd))
@@ -3071,7 +3076,7 @@ The last value is \"don't use any of these switches\"."
 Use this if you want to share an infix's history with a regular
 stand-alone command."
   (cl-letf (((symbol-function #'transient--show) #'ignore))
-    (transient-infix-read (get command 'transient--suffix))))
+    (transient-infix-read (transient--suffix-prototype command))))
 
 ;;;; Readers
 



reply via email to

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