Skip to content

Commit

Permalink
transient--describe-function: Refactor setting help buffer/window
Browse files Browse the repository at this point in the history
Bind `help-window-select' to select the window used to display the help
buffer.  Use `temp-buffer-window-setup-hook' to get our hands at that
buffer, despite `describe-function' (and the lower-level functions it
uses) neither returning the used buffer nor making it current.

`transient-show-help' expects the used buffer to be current after
calling functions such as this one, so that it can finish its own setup
of that buffer.
  • Loading branch information
tarsius committed Sep 29, 2024
1 parent 683e510 commit 732ec97
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -4226,15 +4226,13 @@ manpage, then try to jump to the correct location."
(transient--describe-function cmd))

(defun transient--describe-function (fn)
(describe-function fn)
(when-let* (((not (derived-mode-p 'help-mode)))
(buf (get-buffer "*Help*"))
(win (or (and buf (get-buffer-window buf))
(cl-find-if (lambda (win)
(with-current-buffer (window-buffer win)
(derived-mode-p 'help-mode)))
(window-list)))))
(select-window win)))
(let* ((buffer nil)
(help-window-select t)
(temp-buffer-window-setup-hook
(cons (lambda () (setq buffer (current-buffer)))
temp-buffer-window-setup-hook)))
(describe-function fn)
(set-buffer buffer)))

(defun transient--show-manual (manual)
(info manual))
Expand Down

0 comments on commit 732ec97

Please sign in to comment.