diff options
| author | Roshan Shariff <roshan.shariff@gmail.com> | 2021-10-02 16:02:02 -0600 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2021-12-26 10:43:11 -0800 |
| commit | f865f17ad04cd270685187b0a5331ec8eb06e541 (patch) | |
| tree | bd1c526b16b2f5b350d83bc3ed23010de074152f /helpful.el | |
| parent | 2afbde902742b1aa64daa31a635ba564f14b35ae (diff) | |
Update buffers before switching to them.
Calls `helpful-update` in the help buffer before switching to it with
`helpful-switch-buffer-function`. Currently, this is done in the
opposite order.
Switching to an empty buffer prevents window resize logic from working
properly. For example, it makes the window too small when the
`window-height` action alist key is set to
`#'shrink-window-if-larger-than-buffer` or `#'fit-window-to-buffer` in
`display-buffer-alist`.
Diffstat (limited to 'helpful.el')
| -rw-r--r-- | helpful.el | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -2574,6 +2574,13 @@ Returns the symbol." predicate t nil nil default-val))) +(defun helpful--update-and-switch-buffer (symbol callable-p) + "Update and switch to help buffer for SYMBOL." + (let ((buf (helpful--buffer symbol callable-p))) + (with-current-buffer buf + (helpful-update)) + (funcall helpful-switch-buffer-function buf))) + ;;;###autoload (defun helpful-function (symbol) "Show help for function named SYMBOL. @@ -2584,8 +2591,7 @@ See also `helpful-macro', `helpful-command' and `helpful-callable'." "Function: " (helpful--callable-at-point) #'functionp))) - (funcall helpful-switch-buffer-function (helpful--buffer symbol t)) - (helpful-update)) + (helpful--update-and-switch-buffer symbol t)) ;;;###autoload (defun helpful-command (symbol) @@ -2597,8 +2603,7 @@ See also `helpful-function'." "Command: " (helpful--callable-at-point) #'commandp))) - (funcall helpful-switch-buffer-function (helpful--buffer symbol t)) - (helpful-update)) + (helpful--update-and-switch-buffer symbol t)) ;;;###autoload (defun helpful-key (key-sequence) @@ -2611,8 +2616,7 @@ See also `helpful-function'." (user-error "No command is bound to %s" (key-description key-sequence))) ((commandp sym) - (funcall helpful-switch-buffer-function (helpful--buffer sym t)) - (helpful-update)) + (helpful--update-and-switch-buffer sym t)) (t (user-error "%s is bound to %s which is not a command" (key-description key-sequence) @@ -2626,8 +2630,7 @@ See also `helpful-function'." "Macro: " (helpful--callable-at-point) #'macrop))) - (funcall helpful-switch-buffer-function (helpful--buffer symbol t)) - (helpful-update)) + (helpful--update-and-switch-buffer symbol t)) ;;;###autoload (defun helpful-callable (symbol) @@ -2639,8 +2642,7 @@ See also `helpful-macro', `helpful-function' and `helpful-command'." "Callable: " (helpful--callable-at-point) #'fboundp))) - (funcall helpful-switch-buffer-function (helpful--buffer symbol t)) - (helpful-update)) + (helpful--update-and-switch-buffer symbol t)) (defun helpful--variable-p (symbol) "Return non-nil if SYMBOL is a variable." @@ -2729,8 +2731,7 @@ See also `helpful-callable' and `helpful-variable'." "Variable: " (helpful--variable-at-point) #'helpful--variable-p))) - (funcall helpful-switch-buffer-function (helpful--buffer symbol nil)) - (helpful-update)) + (helpful--update-and-switch-buffer symbol nil)) (defun helpful--variable-at-point-exactly () "Return the symbol at point, if it's a bound variable." |
