Skip to content

Commit

Permalink
transient--prefix: New environment slot
Browse files Browse the repository at this point in the history
This is experimental and to avoid advertising also not documented yet.
You are welcome to use it but should be prepared to deal with breaking
changes.
  • Loading branch information
tarsius committed Oct 18, 2024
1 parent bfa6ce2 commit 9037dc3
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ If `transient-save-history' is nil, then do nothing."
(transient-non-suffix :initarg :transient-non-suffix :initform nil)
(transient-switch-frame :initarg :transient-switch-frame)
(refresh-suffixes :initarg :refresh-suffixes :initform nil)
(environment :initarg :environment :initform nil)
(incompatible :initarg :incompatible :initform nil)
(suffix-description :initarg :suffix-description)
(variable-pitch :initarg :variable-pitch :initform nil)
Expand Down Expand Up @@ -2069,12 +2070,15 @@ EDIT may be non-nil."
(edit
;; Returning from help to edit.
(setq transient--editp t)))
(transient--init-transient name layout params)
(transient--history-init transient--prefix)
(setq transient--original-window (selected-window))
(setq transient--original-buffer (current-buffer))
(setq transient--minibuffer-depth (minibuffer-depth))
(transient--redisplay)
(transient--env-apply
(lambda ()
(transient--init-transient name layout params)
(transient--history-init transient--prefix)
(setq transient--original-window (selected-window))
(setq transient--original-buffer (current-buffer))
(setq transient--minibuffer-depth (minibuffer-depth))
(transient--redisplay))
(get name 'transient--prefix))
(transient--setup-transient)
(transient--suspend-which-key-mode)))

Expand All @@ -2087,6 +2091,11 @@ value. Otherwise return CHILDREN as is."
(funcall (oref group setup-children) children)
children))

(defun transient--env-apply (fn &optional prefix)
(if-let ((env (oref (or prefix transient--prefix) environment)))
(funcall env fn)
(funcall fn)))

(defun transient--init-transient (&optional name layout params)
(unless name
;; Re-init.
Expand Down Expand Up @@ -2568,14 +2577,14 @@ value. Otherwise return CHILDREN as is."
;; argument is in effect.
(not prefix-arg)))
(transient--refreshp
(transient--refresh-transient))
(transient--env-apply #'transient--refresh-transient))
((let ((old transient--redisplay-map)
(new (transient--make-redisplay-map)))
(unless (equal old new)
(transient--pop-keymap 'transient--redisplay-map)
(setq transient--redisplay-map new)
(transient--push-keymap 'transient--redisplay-map))
(transient--redisplay)))))
(transient--env-apply #'transient--redisplay)))))
(setq transient-current-prefix nil)
(setq transient-current-command nil)
(setq transient-current-suffixes nil)))
Expand Down

0 comments on commit 9037dc3

Please sign in to comment.