[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient bcd07e065b 172/366: transient--suffix-symbol:
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient bcd07e065b 172/366: transient--suffix-symbol: Split from transient--suffix-command |
Date: |
Tue, 25 Jan 2022 18:54:38 -0500 (EST) |
branch: externals/transient
commit bcd07e065b3b821ea0ccb5ee90e846a4e51b0580
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
transient--suffix-symbol: Split from transient--suffix-command
---
lisp/transient.el | 93 ++++++++++++++++---------------------------------------
1 file changed, 26 insertions(+), 67 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index f3c1db2c1f..127d29cce1 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1203,62 +1203,21 @@ probably use this instead:
(transient-init-value obj)
obj)))
-(defun transient--suffix-command (arg)
- "Return the command specified by ARG.
-
-Given a suffix specified by ARG, this function returns the
-respective command or a symbol that represents it. It could
-therefore be considered the inverse of `transient-suffix-object'.
-
-Unlike that function it is only intended for internal use though,
-and it is more complicated to describe because of some internal
-tricks it has to account for. You do not actually have to know
-any of this.
-
-ARG can be a `transient-suffix' object, a symbol representing a
-command, or a command (which can be either a fbound symbol or a
-lambda expression).
-
-If it is an object, then the value of its `command' slot is used
-as follows. If ARG satisfies `commandp', then that is returned.
-Otherwise it is assumed to be a symbol that merely represents the
-command. In that case the lambda expression that is stored in
-the symbols `transient--infix-command' property is returned.
-
-Therefore, if ARG is an object, then this function always returns
-something that is callable as a command.
-
-ARG can also be something that is callable as a function. If it
-is a symbol, then that is returned. Otherwise it is a lambda
-expression and a symbol that merely representing that command is
-returned.
-
-Therefore, if ARG is something that is callable as a command,
-then this function always returns a symbol that is, or merely
-represents that command.
-
-The reason that there are \"symbols that merely represent a
-command\" is that by avoiding binding a symbol as a command we
-can prevent it from being offered as a completion candidate for
-`execute-extended-command'. That is useful for infix arguments,
-which usually do not work correctly unless called from a
-transient. Unfortunately this only works for infix arguments
-that are defined inline in the definition of a transient prefix
-command; explicitly defined infix arguments continue to pollute
-the command namespace. It would be better if all this were made
-unnecessary by a `execute-extended-command-ignore' symbol property
-but unfortunately that does not exist (yet?)."
- (if (transient-suffix--eieio-childp arg)
- (let ((sym (oref arg command)))
- (if (commandp sym)
- sym
- (get sym 'transient--infix-command)))
- (if (symbolp arg)
- arg
- ;; ARG is an interactive lambda. The symbol returned by this
- ;; is not actually a command, just a symbol representing it
- ;; for purposes other than invoking it as a command.
- (oref (transient-suffix-object) command))))
+(defun transient--suffix-command (object)
+ "Return the command represented by OBJECT.
+
+If the value of OBJECT's `command' slot is a command, then return
+that. Otherwise it is a symbol whose `transient--infix-command'
+property holds an anonymous command, which is returned instead."
+ (let ((sym (oref object command)))
+ (if (commandp sym)
+ sym
+ (get sym 'transient--infix-command))))
+
+(defun transient--suffix-symbol (arg)
+ (if (symbolp arg)
+ arg
+ (oref (transient-suffix-object) command)))
;;; Keymaps
@@ -1446,10 +1405,10 @@ of the corresponding object.")
(dolist (obj transient--suffixes)
(let* ((cmd (oref obj command))
(sub-prefix (and (symbolp cmd) (get cmd 'transient--prefix)))
- (cmd (transient--suffix-command cmd)))
+ (sym (transient--suffix-symbol cmd)))
(cond
((slot-boundp obj 'transient)
- (define-key map (vector cmd)
+ (define-key map (vector sym)
(let ((do (oref obj transient)))
(pcase do
(`t (if sub-prefix
@@ -1457,8 +1416,8 @@ of the corresponding object.")
'transient--do-stay))
(`nil 'transient--do-exit)
(_ do)))))
- ((not (lookup-key transient-predicate-map (vector cmd)))
- (define-key map (vector cmd)
+ ((not (lookup-key transient-predicate-map (vector sym)))
+ (define-key map (vector sym)
(if sub-prefix
'transient--do-replace
(or (oref transient--prefix transient-suffix)
@@ -1582,7 +1541,7 @@ EDIT may be non-nil."
(defun transient--init-suffix (levels spec)
(pcase-let* ((`(,level ,class ,args) spec)
(cmd (plist-get args :command))
- (level (or (alist-get (transient--suffix-command cmd) levels)
+ (level (or (alist-get (transient--suffix-symbol cmd) levels)
level)))
(let ((fn (and (symbolp cmd)
(symbol-function cmd))))
@@ -1697,7 +1656,7 @@ EDIT may be non-nil."
(t
(setq transient--exitp nil)
(when (eq (if-let ((fn (or (lookup-key transient--predicate-map
- (vector (transient--suffix-command
+ (vector (transient--suffix-symbol
this-original-command)))
(oref transient--prefix transient-non-suffix))))
(let ((action (funcall fn)))
@@ -1976,7 +1935,7 @@ to `transient--do-warn'."
'face 'font-lock-warning-face)
(propertize "C-g" 'face 'transient-key)
(propertize "?" 'face 'transient-key)
- (propertize (symbol-name (transient--suffix-command
+ (propertize (symbol-name (transient--suffix-symbol
this-original-command))
'face 'font-lock-warning-face)))
@@ -2054,7 +2013,7 @@ transient is active."
(transient--show)
(transient--read-number-N
(format "Set level for `%s': "
- (transient--suffix-command command))
+ (transient--suffix-symbol command))
nil nil (not (eq command prefix)))))))))))
(cond
((not command)
@@ -2063,12 +2022,12 @@ transient is active."
(level
(let* ((prefix (oref transient--prefix command))
(alist (alist-get prefix transient-levels))
- (key (transient--suffix-command command)))
+ (sym (transient--suffix-symbol command)))
(if (eq command prefix)
(progn (oset transient--prefix level level)
- (setq key t))
+ (setq sym t))
(oset (transient-suffix-object command) level level))
- (setf (alist-get key alist) level)
+ (setf (alist-get sym alist) level)
(setf (alist-get prefix transient-levels) alist))
(transient-save-levels))
(t
- [elpa] externals/transient 919fc6653d 048/366: transient--make-predicate-map: Always respect transient slot, (continued)
- [elpa] externals/transient 919fc6653d 048/366: transient--make-predicate-map: Always respect transient slot, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 93b5088ffd 050/366: Highlight the active infix while reading its value from the user, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 32459a4dde 074/366: Bring back arrow key navigation in transient popups, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 23fab3a114 075/366: Bring back mouse support in transient popups, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient b52c9652fa 077/366: Update manual, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient dcf7a4dc62 084/366: transient-read-with-initial-input: New option, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient fd9e9bfe26 088/366: transient--layout-member-1: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient ac02efc119 157/366: transient--scroll-commands: New variable, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 9683e8add2 165/366: transient--do-suffix-p: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient ec2de622d2 171/366: transient-suffix-object: Check type of argument, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient bcd07e065b 172/366: transient--suffix-symbol: Split from transient--suffix-command,
Jonas Bernoulli <=
- [elpa] externals/transient 293a437d66 206/366: Support padding of keys regardless of the group's class, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 3284f6a0fe 213/366: transient-init-value: Support per-object functions for prefixes, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 809fd048b1 223/366: transient--insert-suffix: Add comments, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient fd2695d12c 217/366: transient--with-emergency-exit: Wrap default debug function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient f086cb620b 224/366: transient--insert-suffix: Allow same key with different predicates, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 7811dcff82 226/366: Add /docs/*.info to .gitignore, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 8ad5fb83c4 227/366: Remove async-bytecomp kludge, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient d48f2451ec 232/366: transient--pre-exit: Don't log clearing of minibuffer, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 48335f8370 237/366: transient-status: Prevent use while minibuffer is active, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient baebe85ceb 239/366: manual: Deal with texinfo cross reference idiocy, Jonas Bernoulli, 2022/01/25