[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient 51585b8dd7 344/366: transient-reset: New comm
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient 51585b8dd7 344/366: transient-reset: New command |
Date: |
Tue, 25 Jan 2022 18:54:53 -0500 (EST) |
branch: externals/transient
commit 51585b8dd765066fc0d8a629c9b26f9be6fa73e7
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
transient-reset: New command
Also add new generic function `transient-default-value' and
`transient-reset-value'.
---
lisp/transient.el | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index 34cc603faf..a349046fc8 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1551,6 +1551,7 @@ to `transient-predicate-map'. Also see
`transient-base-map'.")
["Value commands"
("C-x s " "Set" transient-set)
("C-x C-s" "Save" transient-save)
+ ("C-x C-k" "Reset" transient-reset)
("C-x p " "Previous value" transient-history-prev)
("C-x n " "Next value" transient-history-next)]
["Sticky commands"
@@ -1585,6 +1586,7 @@ to `transient-predicate-map'. Also see
`transient-base-map'.")
(define-key map [transient-toggle-common] #'transient--do-stay)
(define-key map [transient-set] #'transient--do-call)
(define-key map [transient-save] #'transient--do-call)
+ (define-key map [transient-reset] #'transient--do-call)
(define-key map [describe-key-briefly] #'transient--do-stay)
(define-key map [describe-key] #'transient--do-stay)
(define-key map [transient-scroll-up] #'transient--do-stay)
@@ -2498,6 +2500,11 @@ transient is active."
(interactive)
(transient-save-value (or transient--prefix transient-current-prefix)))
+(defun transient-reset ()
+ "Clear the set and save value of the active transient."
+ (interactive)
+ (transient-reset-value (or transient--prefix transient-current-prefix)))
+
(defun transient-history-next ()
"Switch to the next value used for the active transient."
(interactive)
@@ -2608,12 +2615,7 @@ Otherwise call the primary method according to object's
class."
(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)))))
+ (transient-default-value obj)))))
(cl-defmethod transient-init-value ((obj transient-argument))
(oset obj value
@@ -2640,6 +2642,20 @@ Otherwise call the primary method according to object's
class."
(car (member (oref obj argument)
(oref transient--prefix value)))))
+;;;; Default
+
+(cl-defgeneric transient-default-value (_)
+ "Return the default value."
+ nil)
+
+(cl-defmethod transient-default-value ((obj transient-prefix))
+ (if-let ((default (and (slot-boundp obj 'default-value)
+ (oref obj default-value))))
+ (if (functionp default)
+ (funcall default)
+ default)
+ nil))
+
;;;; Read
(cl-defgeneric transient-infix-read (obj)
@@ -2893,6 +2909,17 @@ prompt."
(transient-save-values))
(transient--history-push obj))
+;;;; Reset
+
+(cl-defmethod transient-reset-value ((obj transient-prefix))
+ (let ((value (transient-default-value obj)))
+ (oset obj value value)
+ (oset (oref obj prototype) value value)
+ (setf (alist-get (oref obj command) transient-values nil 'remove) nil)
+ (transient-save-values))
+ (transient--history-push obj)
+ (mapc #'transient-init-value transient--suffixes))
+
;;;; Get
(defun transient-args (prefix)
- [elpa] externals/transient 791588d118 294/366: transient--emergency-exit: Fix doc-string, (continued)
- [elpa] externals/transient 791588d118 294/366: transient--emergency-exit: Fix doc-string, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 0695b617cc 310/366: manual: No longer use dissolvable sections, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 61af234d41 314/366: make: Update stats target, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 09b436fad0 329/366: transient--debug: Ignore error in transient--suffix-symbol, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 4a36b1d922 336/366: Interpret t and nil for sub-prefixes in define-transient-prefix, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 714e348296 337/366: No longer always suspend when handle-switch-frame is called, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 6c9ae1f46a 346/366: manual: Replace some inaccurate information, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 12097b72d7 351/366: manual: Regenerate, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient b466cd9aab 360/366: transient-toggle-debug: New command, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 4c31a10113 350/366: Remove unnecessary with-eval-after-load, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 51585b8dd7 344/366: transient-reset: New command,
Jonas Bernoulli <=
- [elpa] externals/transient 45241225cf 355/366: transient-common-commands: Evaluate lambdas, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient a35177475c 200/366: transient-suffixes: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient d76f73f884 205/366: transient-arg-value: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 0d79ccfaf8 218/366: transient--parse-suffix: Don't fallback to read-string for options, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 94582a3fd9 228/366: license: Update URLs and cleanup whitespace, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 6af9f8c3c0 254/366: Backport commit 12bab20920 from Emacs, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient b47e9d7d76 256/366: Release version 0.3.4, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient b711543401 261/366: Release version 0.3.5, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 99e48369a5 269/366: transient--invalid: Add heisenbug catcher, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient e90481000f 271/366: Explicitly call transient--pre-command in button action, Jonas Bernoulli, 2022/01/25