Skip to content

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

@ksqsf

Description

@ksqsf

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)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions