[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient 95389b31ec 137/366: transient-init-value: Alw
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient 95389b31ec 137/366: transient-init-value: Always prefer saved over default value |
Date: |
Tue, 25 Jan 2022 18:54:35 -0500 (EST) |
branch: externals/transient
commit 95389b31ec45984e3ff0849f4216adbd183d946f
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
transient-init-value: Always prefer saved over default value
The previous implementation would have worked if only `slot-boundp'
returned nil for slots that have a default value that is *not*
shadowed by an explicitly set value. But that is not so; the slot
is considered bound in that case too.
So we need two slots -- one for the default and one for the actual
value. We keep using `value' for the actual value because that is
used much more often. Only when implementing a `transient-init-value'
method should one have to deal with the new `default-value' slot.
Note that `value' now has no initarg and that `default-value's initarg
is `:value'; but luckily that is an implementation detail that users
of the `define-transient-command' macro don't have to know about that.
Closes #68.
---
lisp/transient.el | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index f7d9e260cb..94c2d75992 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -451,7 +451,7 @@ If `transient-save-history' is nil, then do nothing."
(command :initarg :command)
(level :initarg :level)
(variable :initarg :variable :initform nil)
- (value :initarg :value)
+ (value) (default-value :initarg :value)
(scope :initarg :scope :initform nil)
(history :initarg :history :initform nil)
(history-pos :initarg :history-pos :initform 0)
@@ -2113,13 +2113,14 @@ Non-infix suffix commands usually don't have a value."
nil)
(cl-defmethod transient-init-value ((obj transient-prefix))
- (if (slot-boundp obj 'value)
- (let ((value (oref obj value)))
- (when (functionp value)
- (oset obj value (funcall value))))
- (oset obj value
- (if-let ((saved (assq (oref obj command) transient-values)))
- (cdr saved)
+ (oset obj value
+ (if-let ((saved (assq (oref obj command) transient-values)))
+ (cdr saved)
+ (if-let ((default (and (slot-boundp obj 'default-value)
+ (oref obj default-value))))
+ (if (functionp default)
+ (funcall default)
+ default)
nil))))
(cl-defmethod transient-init-value ((obj transient-switch))
- [elpa] externals/transient 2e33f96cf0 326/366: transient--post-command: Cosmetics, (continued)
- [elpa] externals/transient 2e33f96cf0 326/366: transient--post-command: Cosmetics, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 76b77e01ac 328/366: magit--{pre, post}-command: Add emergency exits, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 41521a5c93 331/366: transient--get-predicate-for: Always return a function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 69f42f9e89 334/366: transient--make-predicate-map: Cosmetics, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 8d8ed1965f 345/366: Hide infix commands from execute-extended-command, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 22e032ae65 343/366: Move obsolete variable declaration, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 804feb3b41 361/366: transient--{push, pop}-keymap: Do nothing if keymap is void, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 6d721f7490 348/366: Don't use convert-standard-filename when defining path variables, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 2c9cef1f5a 352/366: Bump copyright years, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 427e36046a 131/366: transient-force-fixed-pitch: New option, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 95389b31ec 137/366: transient-init-value: Always prefer saved over default value,
Jonas Bernoulli <=
- [elpa] externals/transient 700719723d 047/366: magit--history-push: Add optional SLOT argument, Jonas Bernoulli, 2022/01/25
- [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