Subject: bug#48278: [kisara.moe] 28.0.50; Allow eldoc-echo-area-prefer-doc-buffer to work across all-frames

From: "Basil L. Contovounesios" <[email-masked]>
Date: Fri, 07 May 2021 17:36:43 +0100

mohsin kaleem <[email-masked]> writes:

> `eldoc-echo-area-prefer-doc-buffer` is a user option added a short while
> back that lets you avoid eldoc showing in the minibuffer when an
> equivalent buffer containing the eldoc output is currently visible.
> However the current implementation only works for the current frame and
> if eldoc-doc-buffer is visible in another emacsclient frame the
> echo-area still shows eldoc messages in the current frame.

[...]

> We oould do this by modifying adding a new user-option or modifying
> the existing option and allowing a new `'all-frames` value.
>
> Thoughts?

I'd personally consider this a bug, since the first line of
eldoc-echo-area-prefer-doc-buffer's docstring says:

  Prefer ElDoc's documentation buffer if it is showing in some frame.

In which case I'd advocate for this simple fix:

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index b4f068cf3a..cec89cf3bc 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -538,7 +538,7 @@ eldoc--echo-area-prefer-doc-buffer-p
            (and truncatedp
                 (eq eldoc-echo-area-prefer-doc-buffer
                     'maybe)))
-       (get-buffer-window eldoc--doc-buffer)))
+       (get-buffer-window eldoc--doc-buffer 'visible)))
 
 (defun eldoc-display-in-echo-area (docs _interactive)
   "Display DOCS in echo area.

WDYT?  João?

Thanks,

-- 
Basil