Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: helpful--navigate should respect display-buffer-alist #316

Open
ksqsf opened this issue Mar 20, 2023 · 1 comment
Open

Suggestion: helpful--navigate should respect display-buffer-alist #316

ksqsf opened this issue Mar 20, 2023 · 1 comment

Comments

@ksqsf
Copy link
Contributor

ksqsf commented Mar 20, 2023

I customize display-buffer-alist to control where windows and buffers should be placed inside a frame, and I use something like this for *help* buffers and helpful buffers:

(setq display-buffer-alist
  ("^\\*[Hh]elp"
    (display-buffer-reuse-window
     display-buffer-in-side-window)
    (side . right)
    (window-height . 0.4)
    (window-width . 80)
    (slot . 0)
    (dedicated . t)))

However, helpful does not respect the dedicated parameter, ie. when I press RET on a link, it opens the file in the same window as the helpful buffer, whereas the expected behavior is to visit this file in a window that is placed elsewhere, and keep the helpful window as-is. (*Help* does this correctly.)

The cause lies in helpful--navigate, which uses find-file. find-file internally uses pop-to-buffer-same-window. A corrected version is:

(defun helpful--navigate (button)
  "Navigate to the path this BUTTON represents."
  (pop-to-buffer (find-file-noselect (substring-no-properties (button-get button 'path))))
  ;; We use `get-text-property' to work around an Emacs 25 bug:
  ;; http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=f7c4bad17d83297ee9a1b57552b1944020f23aea
  (-when-let (pos (get-text-property button 'position
                                     (marker-buffer button)))
    (helpful--goto-char-widen pos)))
@jstamant
Copy link

jstamant commented Sep 28, 2023

I agree that helpful's navigation should be changed in this way. I don't use the display-buffer-alist variable, but I've found navigation with helpful to be unintuitive. Helpful keeps trying to open links in other windows, instead of reusing the same one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants