Error if window with link is deleted while following a link
dsedivec opened this issue · 2 comments
Steps to reproduce:
- Start with a fresh Emacs.
- Configure MELPA.
- Install link-hint and window-purpose from MELPA.
- Eval
(progn (purpose-mode 1) (purpose-x-popwin-setup))
to turn on window-purpose and install its popwin-like emulation. popwin will make "popup windows", such as windows containing help buffers, automatically go away. - Bring up any help that contains a link, such as C-h f
auto-fill-mode
RET. - Select the "*Help*" buffer/window, e.g. C-x o.
- M-x
link-hint-open-link
RET
link-hint does successfully follow the link, but you get an error such as internal--before-with-selected-window: Wrong type argument: window-valid-p, #<window 18>
. Here's the backtrace:
Debugger entered--Lisp error: (wrong-type-argument window-valid-p #<window 24>)
window-frame(#<window 24>)
internal--before-with-selected-window(#<window 24>)
link-hint--action(:open (:pos 61 :win #<window 24> :args "(auto-fill-mode /Users/dale/Applications/Emacs.app..." :type link-hint-help-link))
link-hint--one(:open)
link-hint-open-link()
funcall-interactively(link-hint-open-link)
call-interactively(link-hint-open-link record nil)
command-execute(link-hint-open-link record)
execute-extended-command(nil "link-hint-open-link" "link-hint-open-link")
funcall-interactively(execute-extended-command nil "link-hint-open-link" "link-hint-open-link")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
I believe this happens because window-purpose's popwin emulation deletes the window containing "*Help*" in the middle of link-hint following the link.
Specifically, I am guessing that link-hint follows the link around line 993 in link-hint--action
, which involves changing the window configuration, which in turn triggers window-purpose to close the popup "*Help*" window. But then link-hint tries to use the now-invalid link-win
window at line 1006 in with-selected-window
. (internal--before-with-selected-window
is part of with-selected-window
.)
I'm not sure what the appropriate fix is here. Change line 1006 to (with-selected-window (if (window-valid-p link-win) (current-window)) ...)
? Or avoid this branch of the cond
entirely if the link-win
is no longer valid? There's also the comment right around here about using a "temporary window" that I don't fully understand.
Which is to say, I can't open a PR because I don't know how you would like to fix this! But please let me know if you have any problems understanding or reproducing the above.
I am using Emacs 27.0.50 (rebuilt from master earlier today) on macOS with the latest link-hint and window-purpose from MELPA.
Thanks for the detailed report. I've updated it to handle this situation. It should work with the last commit; let me know if you have any issues.
FYI this seems fixed to me, thank you very much!