[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient ed2febd005 16/19: Support use of an infix arg
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient ed2febd005 16/19: Support use of an infix argument following a prefix argument |
Date: |
Mon, 2 May 2022 05:08:26 -0400 (EDT) |
branch: externals/transient
commit ed2febd0056932689da00414af9db0260ea08ead
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Support use of an infix argument following a prefix argument
Using a prefix argument activates `universal-argument--mode' whose
keymap, `universal-argument-map', binds "-" to `negative-argument'.
That binding conflicts with the prefix key used for most infix
arguments.
Counter that by "remapping" `negative-argument' to `transient-update',
using a dedicated pre-command, but only if `negative-argument' was
invoked using "-". "C--", own binding for that command, remains
functional.
When remapped from `negative-argument', `transient-update' has to
preserve the prefix argument for the next command. This cannot happen
earlier in the pre-command, because Emacs consumes `prefix-arg' in
between `pre-command-hook' and the actual invocation of the command
itself.
`prefix-arg' has to be set directly because the function normally used
to do so, `prefix-command-preserve-state', sets `this-command' to
`last-command', which would mess with `transient--post-command'.
Otherwise if the sequence of commands is (1) transient prefix command,
(2) prefix argument, (3) infix argument, then `transient--post-command'
would then act as if the prefix and infix arguments were never invoked.
---
lisp/transient.el | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index c740c4779f..6213ccebaf 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1605,7 +1605,7 @@ to `transient-predicate-map'. Also see
`transient-base-map'.")
(define-key map [transient-history-prev] #'transient--do-stay)
(define-key map [transient-history-next] #'transient--do-stay)
(define-key map [universal-argument] #'transient--do-stay)
- (define-key map [negative-argument] #'transient--do-stay)
+ (define-key map [negative-argument] #'transient--do-minus)
(define-key map [digit-argument] #'transient--do-stay)
(define-key map [transient-quit-all] #'transient--do-quit-all)
(define-key map [transient-quit-one] #'transient--do-quit-one)
@@ -2416,6 +2416,14 @@ to `transient--do-warn'."
(setq this-command 'transient-popup-navigation-help))
transient--stay)
+(defun transient--do-minus ()
+ "Call `negative-argument' or pivot to `transient-update'.
+If `negative-argument' is invoked using \"-\" then preserve the
+prefix argument and pivot to `transient-update'."
+ (when (equal (this-command-keys) "-")
+ (setq this-command 'transient-update))
+ transient--stay)
+
(put 'transient--do-stay 'transient-color 'transient-red)
(put 'transient--do-noop 'transient-color 'transient-red)
(put 'transient--do-warn 'transient-color 'transient-red)
@@ -2429,6 +2437,7 @@ to `transient--do-warn'."
(put 'transient--do-quit-one 'transient-color 'transient-blue)
(put 'transient--do-quit-all 'transient-color 'transient-blue)
(put 'transient--do-move 'transient-color 'transient-red)
+(put 'transient--do-minus 'transient-color 'transient-red)
;;; Commands
@@ -2496,7 +2505,9 @@ transient is active."
(defun transient-update ()
"Redraw the transient's state in the popup buffer."
- (interactive))
+ (interactive)
+ (when (equal this-original-command 'negative-argument)
+ (setq prefix-arg current-prefix-arg)))
(defun transient-show ()
"Show the transient's state in the popup buffer."
- [elpa] externals/transient 19cf9bef5d 02/19: Revert "transient--insert-group: Support multi-row cells", (continued)
- [elpa] externals/transient 19cf9bef5d 02/19: Revert "transient--insert-group: Support multi-row cells", Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient 158d023bd0 04/19: Use pcase's quote upattern, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient 22ef906b5a 07/19: Use string-search instead of string-match-p, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient 35c4b73419 10/19: Refresh library header, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient 5ae3c4014e 05/19: Depend on compat package from GNU Elpa, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient fabd8c9b61 14/19: Put eval-when-compile and require on one line, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient d4fb853d49 15/19: transient--show: Also hide the header-line, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient 8c0d827319 12/19: make: Improve creation of autoloads file, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient cf37817bb5 06/19: Use string-replace instead of replace-regexp-in-string, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient 71de86e8ea 17/19: Fix invoking the suffix the cursor is on in the transient buffer, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient ed2febd005 16/19: Support use of an infix argument following a prefix argument,
Jonas Bernoulli <=
- [elpa] externals/transient 2ef62fac89 13/19: transient--insert-group: Support multi-row cells, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient 84f2d12ef3 19/19: Fix doc-string typo, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient 62ba30e7d8 11/19: make: Right-align target verbs, Jonas Bernoulli, 2022/05/02
- [elpa] externals/transient d02b4f23e0 18/19: Change key binding for invoking the current suffix, Jonas Bernoulli, 2022/05/02