branch: externals/transient commit 55050b60da8b1c5efedf45c885e5e8daf26e2499 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
transient-post-exit-hook: New hook --- docs/transient.org | 8 +++++++- docs/transient.texi | 8 +++++++- lisp/transient.el | 19 ++++++++++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/docs/transient.org b/docs/transient.org index f14929a6ca..97a3f9e2d3 100644 --- a/docs/transient.org +++ b/docs/transient.org @@ -802,7 +802,13 @@ These options are mainly intended for developers. - Variable: transient-exit-hook :: - This hook is run after a transient is exited. + This hook is run after a transient menu is exited, even if another + transient menu becomes active at the same time. + +- Variable: transient-post-exit-hook :: + + This hook is run after a transient menu is exited, provided no other + transient menu becomes active at the same time. - Variable: transient-setup-buffer-hook :: diff --git a/docs/transient.texi b/docs/transient.texi index 9c1723f741..bb4100d2f4 100644 --- a/docs/transient.texi +++ b/docs/transient.texi @@ -949,7 +949,13 @@ same customization. @subheading Hook Variables @defvar transient-exit-hook -This hook is run after a transient is exited. +This hook is run after a transient menu is exited, even if another +transient menu becomes active at the same time. +@end defvar + +@defvar transient-post-exit-hook +This hook is run after a transient menu is exited, provided no other +transient menu becomes active at the same time. @end defvar @defvar transient-setup-buffer-hook diff --git a/lisp/transient.el b/lisp/transient.el index d9a1421db0..0fd61ee017 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1671,7 +1671,14 @@ values. In complex cases it might be necessary to use this variable instead.") (defvar transient-exit-hook nil - "Hook run after exiting a transient.") + "Hook run after exiting a transient menu. +Unlike `transient-post-exit-hook', this runs even if another transient +menu becomes active at the same time. ") + +(defvar transient-post-exit-hook nil + "Hook run after exiting all transient menus. +Unlike `transient-exit-hook', this does not run if another transient +menu becomes active at the same time.") (defvar transient-setup-buffer-hook nil "Hook run when setting up the transient buffer. @@ -2832,9 +2839,10 @@ value. Otherwise return CHILDREN as is.") (remove-hook 'pre-command-hook #'transient--pre-command) (remove-hook 'post-command-hook #'transient--post-command) (advice-remove 'recursive-edit #'transient--recursive-edit)) - (let ((resume (and transient--stack + (let ((replace (eq transient--exitp 'replace)) + (resume (and transient--stack (not (memq transient--exitp '(replace suspend)))))) - (unless (or resume (eq transient--exitp 'replace)) + (unless (or resume replace) (setq transient--showp nil)) (setq transient--exitp nil) (setq transient--helpp nil) @@ -2847,8 +2855,9 @@ value. Otherwise return CHILDREN as is.") (setq transient-current-command nil) (setq transient-current-suffixes nil) (setq transient--current-suffix nil)) - (when resume - (transient--stack-pop)))) + (cond (resume (transient--stack-pop)) + ((not replace) + (run-hooks 'transient-post-exit-hook))))) (defun transient--stack-push () (transient--debug 'stack-push)