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

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

[elpa] externals/transient 6842305e84 286/366: Support undefined suffixe


From: Jonas Bernoulli
Subject: [elpa] externals/transient 6842305e84 286/366: Support undefined suffixes if an extra step is taken
Date: Tue, 25 Jan 2022 18:54:48 -0500 (EST)

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

    Support undefined suffixes if an extra step is taken
    
    See #61 and https://github.com/emacs-evil/evil-collection/issues/543.
---
 docs/transient.org  | 16 ++++++++++++++--
 docs/transient.texi | 16 ++++++++++++++--
 lisp/transient.el   |  3 ++-
 3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/docs/transient.org b/docs/transient.org
index f164454189..dd7c2970db 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.3.6 (v0.3.6-16-gf5e600d3+1)
+#+SUBTITLE: for version 0.3.6 (v0.3.6-17-g2281d952+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.3.6 (v0.3.6-16-gf5e600d3+1).
+This manual is for Transient version 0.3.6 (v0.3.6-17-g2281d952+1).
 
 #+BEGIN_QUOTE
 Copyright (C) 2018-2021 Jonas Bernoulli <jonas@bernoul.li>
@@ -938,6 +938,18 @@ argument that is mandatory in all cases.
   be set in the suffix specification.  Therefore if there is no object,
   then you have to make sure to specify the KEY and the DESCRIPTION.
 
+  As a special case, if you want to add a command that might be neither
+  defined nor autoloaded, you can use a workaround like:
+
+  #+BEGIN_SRC emacs-lisp
+    (transient-insert-suffix 'some-prefix "k"
+      '("!" "Ceci n'est pas une commande" no-command
+        :if (lambda () (featurep 'no-library))))
+  #+END_SRC
+
+  Instead of ~featurep~ you could also use ~require~ with a non-nil value
+  for NOERROR.
+
 - The mandatory argument can also be a command-line argument, a
   string.  In that case an anonymous command is defined and bound.
 
diff --git a/docs/transient.texi b/docs/transient.texi
index a852cd01df..6cf8e6a94f 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.3.6 (v0.3.6-16-gf5e600d3+1)
+@subtitle for version 0.3.6 (v0.3.6-17-g2281d952+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.3.6 (v0.3.6-16-gf5e600d3+1).
+This manual is for Transient version 0.3.6 (v0.3.6-17-g2281d952+1).
 
 @quotation
 Copyright (C) 2018-2021 Jonas Bernoulli <jonas@@bernoul.li>
@@ -1184,6 +1184,18 @@ be used to set the default for certain values that 
otherwise have to
 be set in the suffix specification.  Therefore if there is no object,
 then you have to make sure to specify the KEY and the DESCRIPTION@.
 
+As a special case, if you want to add a command that might be neither
+defined nor autoloaded, you can use a workaround like:
+
+@lisp
+(transient-insert-suffix 'some-prefix "k"
+  '("!" "Ceci n'est pas une commande" no-command
+    :if (lambda () (featurep 'no-library))))
+@end lisp
+
+Instead of @code{featurep} you could also use @code{require} with a non-nil 
value
+for NOERROR@.
+
 
 @item
 The mandatory argument can also be a command-line argument, a
diff --git a/lisp/transient.el b/lisp/transient.el
index ac718ba850..c939589fa2 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1074,7 +1074,8 @@ example, sets a variable use `transient-define-infix' 
instead.
           (put cmd 'transient--infix-command
                (transient--default-infix-command))
         ;; This is not an anonymous infix argument.
-        (error "Suffix %s is not defined or autoloaded as a command" cmd)))))
+        (when (transient--use-suffix-p obj)
+          (error "Suffix %s is not defined or autoloaded as a command" 
cmd))))))
 
 (defun transient--derive-shortarg (arg)
   (save-match-data



reply via email to

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