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

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

[elpa] externals/transient e2fee19879 204/366: Support using variables i


From: Jonas Bernoulli
Subject: [elpa] externals/transient e2fee19879 204/366: Support using variables in group and suffix specifications
Date: Tue, 25 Jan 2022 18:54:41 -0500 (EST)

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

    Support using variables in group and suffix specifications
    
    Re #101.
---
 docs/transient.org |  8 ++++++++
 lisp/transient.el  | 10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/docs/transient.org b/docs/transient.org
index 404b97b645..cf4ffe3fa2 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -857,6 +857,14 @@ that specify commands and strings.  Strings are inserted 
verbatim.
 The empty string can be used to insert gaps between suffixes, which is
 particularly useful if the suffixes are outlined as a table.
 
+Variables are supported inside group specifications.  For example in
+place of a direct subgroup specification, a variable can be used whose
+value is a vector that qualifies as a group specification.  Likewise a
+variable can be used where a suffix specification is expected.  Lists
+of group or suffix specifications are also supported.  Indirect
+specifications are resolved when the transient prefix is being
+defined.
+
 The form of suffix specifications is documented in the next node.
 
 *** Suffix Specifications
diff --git a/lisp/transient.el b/lisp/transient.el
index 9ed968e937..f6ff888297 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -889,7 +889,9 @@ example, sets a variable use `transient-define-infix' 
instead.
             (setq class v)
           (push k keys)
           (push v keys))))
-    (while (vectorp (car args))
+    (while (let ((arg (car args)))
+             (or (vectorp arg)
+                 (and arg (symbolp arg))))
       (push (pop args) suffixes))
     (list (if (eq (car-safe class) 'quote)
               (cadr class)
@@ -901,6 +903,12 @@ example, sets a variable use `transient-define-infix' 
instead.
 
 (defun transient--parse-child (prefix spec)
   (cl-etypecase spec
+    (symbol  (let ((value (symbol-value spec)))
+               (if (and (listp value)
+                        (or (listp (car value))
+                            (vectorp (car value))))
+                   (cl-mapcan (lambda (s) (transient--parse-child prefix s)) 
value)
+                 (transient--parse-child prefix value))))
     (vector  (when-let ((c (transient--parse-group  prefix spec))) (list c)))
     (list    (when-let ((c (transient--parse-suffix prefix spec))) (list c)))
     (string  (list spec))))



reply via email to

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