Skip to content

Commit

Permalink
transient-{set,save}-and-exit: New commands
Browse files Browse the repository at this point in the history
Actually they are just aliases.  The separate entries
in `transient-predicate-map' is what makes the different.

These are intended for use in, e.g., `magit-diff-refresh'
and `magit-log-refresh', which use specialized classes whose
`transient-set-value' and `transient-save-value' additionally refresh
the buffer containing the diff/log.  I.e., there this commands serve
as variants of `magit-refresh', and all these commands are expected to
exit the transient.

Previously these transients instead bound `transient-set-value'
to "s" and `transient-save-value' to "w", and explicitly set their
`transient' slot to nil, but that was surprising because that also
causes the regular "C-x s" and "C-x C-s" bindings to behave that
way.
  • Loading branch information
tarsius committed Sep 19, 2023
1 parent 7c08beb commit 04f87b4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,9 @@ of the corresponding object."
"<transient-update>" #'transient--do-stay
"<transient-toggle-common>" #'transient--do-stay
"<transient-set>" #'transient--do-call
"<transient-set-and-exit>" #'transient--do-exit
"<transient-save>" #'transient--do-call
"<transient-save-and-exit>" #'transient--do-exit
"<transient-reset>" #'transient--do-call
"<describe-key-briefly>" #'transient--do-stay
"<describe-key>" #'transient--do-stay
Expand Down Expand Up @@ -2655,15 +2657,21 @@ transient is active."
(transient-undefined))))

(defun transient-set ()
"Save the value of the active transient for this Emacs session."
"Set active transient's value for this Emacs session."
(interactive)
(transient-set-value (or transient--prefix transient-current-prefix)))

(defalias 'transient-set-and-exit 'transient-set
"Set active transient's value for this Emacs session and exit.")

(defun transient-save ()
"Save the value of the active transient persistenly across Emacs sessions."
"Save active transient's value for this and future Emacs sessions."
(interactive)
(transient-save-value (or transient--prefix transient-current-prefix)))

(defalias 'transient-save-and-exit 'transient-save
"Save active transient's value for this and future Emacs sessions and exit.")

(defun transient-reset ()
"Clear the set and saved values of the active transient."
(interactive)
Expand Down

0 comments on commit 04f87b4

Please sign in to comment.