Wilfred / helpful

A better Emacs *help* buffer
1.12k stars 62 forks source link

Helpful doesn't seem to respect display-buffer-alist (or I am doing something wrong?) #346

Closed renbus closed 1 week ago

renbus commented 1 month ago

Hello,

If I click on a link in a Helpful buffer, or if I execute helpful-callable, or helpful-variable while an Helpful buffer is the active window, the new Helpful buffer will appear in the "other-window". If the Helpful window is the only window, it still launches itself in "other-window" (so it splits the screen). That makes using Helpful quite annoying.

I tried to prevent it from doing so with:

(add-to-list 'display-buffer-alist
             '((major-mode . helpful-mode)
              (display-buffer-reuse-window)
              (inhibit-same-window . nil)))

But it doesn't seem to prevent it from using the "other-window". Am I doing something wrong?

By the way, I set the helpful-max-buffers user option to 1, if that may explain anything.

IceAsteroid commented 1 week ago

@renbus, Hi!

Edit: I don't know exactly what happened, but the following methods work.

If someone knows this, please share its mechanism, thank you!

Method 1:

  (add-to-list 'display-buffer-alist
               '((major-mode . helpful-mode)
                 (display-buffer-reuse-mode-window)
                 (inhibit-same-window . nil)))

Method 1.1:

  (add-to-list 'display-buffer-alist
               '((major-mode . helpful-mode)
                 (display-buffer-reuse-window
                  display-buffer-reuse-mode-window)
                 (inhibit-same-window . nil)))

Method 2: Match buffer name instead

  (add-to-list 'display-buffer-alist
               '("\\*helpful.*"
                 (display-buffer-reuse-window
                  display-buffer-reuse-mode-window)
                 (inhibit-same-window . nil)))
IceAsteroid commented 1 week ago

It seems that display-buffer-reuse-window matches the exact same name with existing live window and the one to open, so use display-buffer-reuse-mode-window or both.

renbus commented 1 week ago

Hello!

Thanks for your reply. Your methods, at least 1 and 1.1, both work, so that's great. Although, at first it wasn't working for me, but then I found out that setting the helpful-max-buffers to 1 was an issue. When I think about it, it makes sense. Probably that this setting was doing that the helpful buffer would first get killed, before opening a new one, so the display-buffer-alist rule wouldn't be able to re-use the same window.