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

    transient--ensure-infix-command: Avoid false-positives
    
    This function is supposed to generate the command for an anonymous
    infix argument but until now it also generated a command for other
    kinds of suffixes if the command was not defined or autoloaded.
    
    Now this function detects that issue and raises an informative error
    instead of defining a bogus command, which then caused a confusing
    error later on.
    
    Closes https://github.com/magit/magit/issues/3761.
---
 lisp/transient.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index c58349a7bf..ba1210ffe6 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -752,8 +752,12 @@ example, sets a variable use `define-infix-command' 
instead.
   (let ((cmd (oref obj command)))
     (unless (or (commandp cmd)
                 (get cmd 'transient--infix-command))
-      (put cmd 'transient--infix-command
-           (transient--default-infix-command)))))
+      (if (or (cl-typep obj 'transient-switch)
+              (cl-typep obj 'transient-option))
+          (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)))))
 
 (defun transient--derive-shortarg (arg)
   (save-match-data

Reply via email to