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

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

[elpa] externals/transient a3e536333e 189/366: Support anonymous non-inf


From: Jonas Bernoulli
Subject: [elpa] externals/transient a3e536333e 189/366: Support anonymous non-infix suffixes
Date: Tue, 25 Jan 2022 18:54:40 -0500 (EST)

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

    Support anonymous non-infix suffixes
---
 docs/transient.org  | 20 ++++++++++++++------
 docs/transient.texi | 20 ++++++++++++++------
 lisp/transient.el   |  9 +++++++++
 3 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/docs/transient.org b/docs/transient.org
index ff08372ec0..cf55360ff8 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -8,7 +8,7 @@
 #+TEXINFO_DIR_CATEGORY: Emacs
 #+TEXINFO_DIR_TITLE: Transient: (transient).
 #+TEXINFO_DIR_DESC: Transient Commands
-#+SUBTITLE: for version 0.2.0 (v0.2.0-36-g96cec8e1+1)
+#+SUBTITLE: for version 0.2.0 (v0.2.0-37-gf2252d53+1)
 
 #+TEXINFO_DEFFN: t
 #+OPTIONS: H:4 num:4 toc:2
@@ -37,7 +37,7 @@ Calling a suffix command usually causes the transient to be 
exited
 but suffix commands can also be configured to not exit the transient.
 
 #+TEXINFO: @noindent
-This manual is for Transient version 0.2.0 (v0.2.0-36-g96cec8e1+1).
+This manual is for Transient version 0.2.0 (v0.2.0-37-gf2252d53+1).
 
 #+BEGIN_QUOTE
 Copyright (C) 2018-2020 Jonas Bernoulli <jonas@bernoul.li>
@@ -894,10 +894,18 @@ the object's values just for the binding inside this 
transient.
 The next element is either a command or an argument.  This is the only
 argument that is mandatory in all cases.
 
-- COMMAND is a symbol that is bound as a function, which has to be a
-  command.  Any command will do; it does not need to have an object
-  associated with it (as would be the case if ~transient-define-suffix~
-  or ~transient-define-infix~ were used to define it).
+- Usually COMMAND is a symbol that is bound as a function, which has
+  to be defined or at least autoloaded as a command by the time the
+  containing prefix command is invoked.
+
+  Any command will do; it does not need to have an object associated
+  with it (as would be the case if ~transient-define-suffix~ or
+  ~transient-define-infix~ were used to define it).
+
+  The command can also be a closure or lambda expression, but that
+  should only be used for dynamic transients whose suffixes are
+  defined when the prefix command is invoked.  See information about
+  the ~:setup-children~ function in [[*Group Specifications]].
 
   As mentioned above, the object that is associated with a command can
   be used to set the default for certain values that otherwise have to
diff --git a/docs/transient.texi b/docs/transient.texi
index f7dcae2d0d..7eaecfdfe9 100644
--- a/docs/transient.texi
+++ b/docs/transient.texi
@@ -31,7 +31,7 @@ General Public License for more details.
 @finalout
 @titlepage
 @title Transient User and Developer Manual
-@subtitle for version 0.2.0 (v0.2.0-36-g96cec8e1+1)
+@subtitle for version 0.2.0 (v0.2.0-37-gf2252d53+1)
 @author Jonas Bernoulli
 @page
 @vskip 0pt plus 1filll
@@ -65,7 +65,7 @@ Calling a suffix command usually causes the transient to be 
exited
 but suffix commands can also be configured to not exit the transient.
 
 @noindent
-This manual is for Transient version 0.2.0 (v0.2.0-36-g96cec8e1+1).
+This manual is for Transient version 0.2.0 (v0.2.0-37-gf2252d53+1).
 
 @quotation
 Copyright (C) 2018-2020 Jonas Bernoulli <jonas@@bernoul.li>
@@ -1134,10 +1134,18 @@ argument that is mandatory in all cases.
 
 @itemize
 @item
-COMMAND is a symbol that is bound as a function, which has to be a
-command.  Any command will do; it does not need to have an object
-associated with it (as would be the case if @code{transient-define-suffix}
-or @code{transient-define-infix} were used to define it).
+Usually COMMAND is a symbol that is bound as a function, which has
+to be defined or at least autoloaded as a command by the time the
+containing prefix command is invoked.
+
+Any command will do; it does not need to have an object associated
+with it (as would be the case if @code{transient-define-suffix} or
+@code{transient-define-infix} were used to define it).
+
+The command can also be a closure or lambda expression, but that
+should only be used for dynamic transients whose suffixes are
+defined when the prefix command is invoked.  See information about
+the @code{:setup-children} function in @ref{Group Specifications}.
 
 As mentioned above, the object that is associated with a command can
 be used to set the default for certain values that otherwise have to
diff --git a/lisp/transient.el b/lisp/transient.el
index 1945f5937e..758a3daaf0 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -945,6 +945,15 @@ example, sets a variable use `transient-define-infix' 
instead.
         (error "Need command, got %S" car))
        ((symbolp car)
         (setq args (plist-put args :command pop)))
+       ((and (commandp car)
+             (not (stringp car)))
+        (let ((cmd pop)
+              (sym (intern (format "transient:%s:%s"
+                                   prefix
+                                   (or (plist-get args :description)
+                                       (plist-get args :key))))))
+          (defalias sym cmd)
+          (setq args (plist-put args :command sym))))
        ((or (stringp car)
             (and car (listp car)))
         (let ((arg pop))



reply via email to

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