diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2025-05-16 09:40:42 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2025-05-16 09:40:42 +0200 |
| commit | c4e0cba65663b0a2dacd8531e779f2c09f778267 (patch) | |
| tree | 0c27b1fec1f1234f9eba52b1c51a55095e3cbdc2 /lisp | |
| parent | 7ba243e301f702bf8071ef394ceb7bb58321e6d1 (diff) | |
Require all key bindings to be specified as key descriptions
No longer support vectors. This change isn't backward compatible but
I haven't seen a vector being used even just once.
It also makes sense to take inspiration from `keymap-set' et al., which
didn't exist when Transient was created.
However, we continue to be more permissive than those functions, only
insisting on strings understood by `kbd', including strings that do not
satisfy `key-valid-p'. Being more permissive makes it possible, for
example, to write the key binding, which toggles the "-a" command line
argument, as "-a", instead of having to write "- a". Likewise
additional spaces can be added, which are not removed when displaying
the binding in the menu, which is useful for alignment purposes.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/transient.el | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/lisp/transient.el b/lisp/transient.el index ea13f1a..df46384 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1604,8 +1604,10 @@ See info node `(transient)Modifying Existing Transients'." (setq val nil)) (setq val (if loc (car mem) mem))))) (setq loc (car loc))) + (when (stringp loc) + (setq loc (kbd loc))) (if loc - (transient--layout-member-1 (transient--kbd loc) val remove) + (transient--layout-member-1 loc val remove) val))) (defun transient--layout-member-1 (loc layout remove) @@ -1629,19 +1631,11 @@ See info node `(transient)Modifying Existing Transients'." (cmd (plist-get def :command))) (if (symbolp loc) (eq cmd loc) - (equal (transient--kbd - (or (plist-get def :key) - (transient--command-key cmd))) + (equal (kbd (or (plist-get def :key) + (transient--command-key cmd))) loc))))) (aref group 3))) -(defun transient--kbd (keys) - (when (vectorp keys) - (setq keys (key-description keys))) - (when (stringp keys) - (setq keys (kbd keys))) - keys) - (defun transient--spec-key (spec) (let ((plist (nth 2 spec))) (or (plist-get plist :key) @@ -1894,9 +1888,8 @@ probably use this instead: ((length= suffixes 1) (car suffixes)) ((cl-find-if (lambda (obj) - (equal - (listify-key-sequence (transient--kbd (oref obj key))) - (listify-key-sequence (this-command-keys)))) + (equal (listify-key-sequence (kbd (oref obj key))) + (listify-key-sequence (this-command-keys)))) suffixes)) ;; COMMAND is only provided if `this-command' is meaningless, in ;; which case `this-command-keys' is also meaningless, making it @@ -2425,7 +2418,7 @@ value. Otherwise return CHILDREN as is.") (pcase-let* ((`(,level ,class ,args) spec) (cmd (plist-get args :command)) (_ (transient--load-command-if-autoload cmd)) - (key (transient--kbd (plist-get args :key))) + (key (kbd (plist-get args :key))) (proto (and cmd (transient--suffix-prototype cmd))) (level (or (alist-get (cons cmd key) levels nil nil #'equal) (alist-get cmd levels) |
