Skip to content

Commit

Permalink
Fix advice for elisp--company-doc-buffer (#539)
Browse files Browse the repository at this point in the history
The advice `radian--advice-company-elisp-use-helpful` replaces
`(help-buffer)` with `(current-buffer)` assuming that a helpful command
will be called.

However, this is only true for functions and variables. If
`elisp--company-doc-buffer` is called with a feature or a face, the
current, unrelated, buffer is used when standard `help-*` commands are
called, leading to the current buffer content being overwritten.

The change in the PR gets around that issue but not overriding
`help-buffer`. The solution fixes the issue, but it still feels hacky
and a better solution might be to patch `elisp--company-doc-buffer`
instead.
  • Loading branch information
raxod502 authored Oct 3, 2024
2 parents ae0e928 + 85f22aa commit c6db1ea
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions emacs/radian.el
Original file line number Diff line number Diff line change
Expand Up @@ -3963,10 +3963,17 @@ bizarre reason."
(func &rest args)
:around #'elisp--company-doc-buffer
"Cause `company' to use Helpful to show Elisp documentation."
(cl-letf (((symbol-function #'describe-function) #'helpful-function)
((symbol-function #'describe-variable) #'helpful-variable)
((symbol-function #'help-buffer) #'current-buffer))
(apply func args))))
(cl-letf* ((helpful-buffer nil)
((symbol-function #'describe-function)
(lambda (&rest args)
(apply 'helpful-function args)
(setq helpful-buffer (current-buffer))))
((symbol-function #'describe-variable)
(lambda (&rest args)
(apply 'helpful-variable args)
(setq helpful-buffer (current-buffer))))
(buf (apply func args)))
(or helpful-buffer buf))))

(radian-defadvice radian--advice-fill-elisp-docstrings-correctly (&rest _)
:before-until #'fill-context-prefix
Expand Down

0 comments on commit c6db1ea

Please sign in to comment.