[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient 9617b6c77c 35/41: transient--make-predicate-m
|
From: |
Jonas Bernoulli |
|
Subject: |
[elpa] externals/transient 9617b6c77c 35/41: transient--make-predicate-map: Support shorthands |
|
Date: |
Sun, 12 Nov 2023 20:04:09 -0500 (EST) |
branch: externals/transient
commit 9617b6c77c36b2e49895d5626c895cc4b8660873
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
transient--make-predicate-map: Support shorthands
---
docs/transient.org | 3 ++-
docs/transient.texi | 3 ++-
lisp/transient.el | 16 +++++++++++++---
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/docs/transient.org b/docs/transient.org
index 615adbbcab..8b13efb4fc 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -1262,7 +1262,8 @@ The default behavior while a transient is active is as
follows:
The behavior can be changed for all suffixes of a particular prefix
and/or for individual suffixes. The values should nearly always be
booleans, but certain functions, called “pre-commands”, can also be
-used.
+used. These functions are named ~transient--do-VERB~, and the symbol
+~VERB~ can be used as a shorthand.
A boolean is interpreted as answering the question "does the
transient stay active, when this command is invoked?" ~t~ means that
diff --git a/docs/transient.texi b/docs/transient.texi
index 9c4730fd4d..bed2501e63 100644
--- a/docs/transient.texi
+++ b/docs/transient.texi
@@ -1450,7 +1450,8 @@ warning. This does not ``deactivate'' the transient.
The behavior can be changed for all suffixes of a particular prefix
and/or for individual suffixes. The values should nearly always be
booleans, but certain functions, called “pre-commands”, can also be
-used.
+used. These functions are named @code{transient--do-VERB}, and the symbol
+@code{VERB} can be used as a shorthand.
A boolean is interpreted as answering the question "does the
transient stay active, when this command is invoked?" @code{t} means that
diff --git a/lisp/transient.el b/lisp/transient.el
index 2b81822baf..e015678c28 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1760,7 +1760,8 @@ of the corresponding object."
map))
(defun transient--make-predicate-map ()
- (let* ((default (oref transient--prefix transient-suffix))
+ (let* ((default (transient--resolve-pre-command
+ (oref transient--prefix transient-suffix)))
(return (eq default t))
(map (make-sparse-keymap)))
(set-keymap-parent map transient-predicate-map)
@@ -1777,7 +1778,9 @@ of the corresponding object."
(define-key map (vector cmd) #'transient--do-warn-inapt))
((slot-boundp obj 'transient)
(define-key map (vector cmd)
- (pcase (list kind (oref obj transient) return)
+ (pcase (list kind
+ (transient--resolve-pre-command (oref obj transient))
+ return)
(`(prefix t ,_) #'transient--do-recurse)
(`(prefix nil ,_) #'transient--do-stack)
(`(infix t ,_) #'transient--do-stay)
@@ -2151,12 +2154,19 @@ value. Otherwise return CHILDREN as is."
(or (ignore-errors
(lookup-key transient--predicate-map (vector cmd)))
(and (not suffix-only)
- (let ((pred (oref transient--prefix transient-non-suffix)))
+ (let ((pred (transient--resolve-pre-command
+ (oref transient--prefix transient-non-suffix))))
(pcase pred
('t #'transient--do-stay)
('nil #'transient--do-warn)
(_ pred))))))
+(defun transient--resolve-pre-command (pre)
+ (cond ((booleanp pre) pre)
+ ((string-match-p "--do-" (symbol-name pre)) pre)
+ ((let ((sym (intern (format "transient--do-%s" pre))))
+ (if (functionp sym) sym pre)))))
+
(defun transient--pre-exit ()
(transient--debug 'pre-exit)
(transient--delete-window)
- [elpa] externals/transient 8e15a29b59 31/41: transient-format-description: Support function as value of face slot, (continued)
- [elpa] externals/transient 8e15a29b59 31/41: transient-format-description: Support function as value of face slot, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 533578b6b2 32/41: transient-information: Use a space as the fake key, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 59d8c0342a 18/41: transient--unset-incompatible: Remove unnecessary variable, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient ed5bd6fdc3 23/41: transient-infix-set(argument): Fix disabling incompatible options, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient bad91f79ec 29/41: transient-with-shadowed-buffer: Move definition, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient cf32cf6f98 39/41: transient--get-face: Favor face over function, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 4b9d831d28 10/41: transient--make-predicate-map: Drop obsolete condition, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 784887b781 14/41: Account for t as transient-suffix for nested prefixes, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 2eb214a6ec 24/41: transient-infix-set(argument): Also disable based on concrete value, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 94661e0ccd 34/41: transient--do-replace: Replace with two variants, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 9617b6c77c 35/41: transient--make-predicate-map: Support shorthands,
Jonas Bernoulli <=
- [elpa] externals/transient 3a2b936a67 36/41: Fix highlighting infix for which user input is being read, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 222c2bfbeb 38/41: transient--get-face: New function, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 02607dd9d9 04/41: manual: Move comparisons to wiki, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 0677e2c3d8 26/41: transient-format-description: Operate in transient--shadowed-buffer, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient b4a2963636 33/41: transient-format(around:suffix): Update for transient-information, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient d44c4fce39 40/41: transient--get-face: Use for inapt-face, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient eaf062a921 11/41: transient--make-predicate-map: Refactor, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 5ad5b627f6 15/41: transient--setup-recursion: When initiated by outer transient-suffix, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 2b7219cf6a 28/41: transient--current-buffer: Fix obsolete variable alias, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 0a0ba1aa90 01/41: transient--do-leave: Actually behave as documented, Jonas Bernoulli, 2023/11/12