transient--describe-function: handle describe-function overrides#431
Merged
tarsius merged 1 commit intomagit:mainfrom Mar 10, 2026
Merged
Conversation
benthamite
added a commit
to benthamite/dotfiles
that referenced
this pull request
Mar 10, 2026
Submitted upstream as magit/transient#431.
Member
|
Do we even have to call |
8242b32 to
80f3779
Compare
Contributor
Author
|
Good point — updated. When the hook doesn't fire, the override's |
`transient--describe-function' captures the help buffer via `temp-buffer-window-setup-hook'. This works with the built-in `describe-function', which displays its output via `with-help-window' and therefore triggers the hook. However, a common pattern in the Emacs community is to override `describe-function' with a function provided by a packages like `helpful'. `helpful-function' creates and displays its buffer via `pop-to-buffer' rather than `with-help-window', so `temp-buffer-window-setup-hook' never fires and `buffer' stays nil, causing (set-buffer nil) to signal `wrong-type-argument'. See magit#431.
80f3779 to
56c601e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
transient--describe-functioncaptures the help buffer viatemp-buffer-window-setup-hook. This works with the built-indescribe-function, which displays its output viawith-help-windowand therefore triggers the hook.However, a common pattern in the Emacs community is to override
describe-functionwith packages like helpful:This is recommended by Doom Emacs, Spacemacs, and countless dotfiles.
helpful-functioncreates and displays its buffer viapop-to-bufferrather thanwith-help-window, sotemp-buffer-window-setup-hooknever fires,bufferstays nil, and(set-buffer nil)signals(wrong-type-argument stringp nil).This means pressing
?followed by a suffix key in any transient menu errors out for anyone using this pattern.Fix
When the hook fires (standard
describe-function), behavior is unchanged. When it doesn't (helpfulor any other override that bypasseswith-help-window), we skip theset-buffercall entirely — the override'spop-to-bufferalready selected the correct window and set the current buffer, so no further action is needed.Context
This is in the spirit of the robustness improvements in #208 and #213, which led to commit 732ec97 rewriting
transient--describe-functionbecause it was "too fragile" — it assumed(help-buffer)would return the correct buffer, which broke when packages like epithet renamed help buffers. The current implementation replaced that assumption withtemp-buffer-window-setup-hook, but this hook has the same fragility whendescribe-functionitself is replaced with something that doesn't usewith-help-window.