emacs-31 ba781ed7544: Fix blinking Eldoc messages

Eli Zaretskii <[email protected]> Tue, 7 Jul 2026 07:24:39 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit ba781ed7544e882f80400006aac62e66c90897fc
Author: Daniel Mendler <[email protected]>
Commit: Eli Zaretskii <[email protected]>

    Fix blinking Eldoc messages
    
    Ensure that `global-eldoc-mode' does not enable `eldoc-mode' in
    ephemeral Eldoc buffers and accidentally reset `eldoc-last-message'.
    This caused Eldoc message blinking (bug#81356).
    
    * lisp/emacs-lisp/eldoc.el (eldoc--supported-p): Exclude ephemeral Eldoc
    buffers to avoid blinking.
    (eldoc-help-at-pt): Add custom :set function.
    (eldoc-documentation-functions): Do not register `eldoc-show-help-at-pt'
    by default.
---
 lisp/emacs-lisp/eldoc.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 55f9fb1988b..d1c56b7f82f 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -144,6 +144,11 @@ This setting is an alternative to `help-at-pt-display-when-idle'.  If
 the value is non-nil, `eldoc-show-help-at-pt' will show help-at-point
 via Eldoc."
   :type 'boolean
+  :set (lambda (sym val)
+         (custom-set-default sym val)
+         (if val
+             (add-hook 'eldoc-documentation-functions #'eldoc-show-help-at-pt 90)
+           (remove-hook 'eldoc-documentation-functions #'eldoc-show-help-at-pt)))
   :version "31.1")
 
 (defface eldoc-highlight-function-argument
@@ -417,7 +422,7 @@ Also store it in `eldoc-last-message' and return that value."
                       (overlay-end show-paren--overlay)))))))
 
 
-(defvar eldoc-documentation-functions (list #'eldoc-show-help-at-pt)
+(defvar eldoc-documentation-functions nil
   "Hook of functions that produce doc strings.
 
 A doc string is typically relevant if point is on a function-like
@@ -813,7 +818,9 @@ all."
 
 (defun eldoc--supported-p ()
   "Non-nil if an ElDoc function is set for this buffer."
-  (and (not (memq eldoc-documentation-strategy '(nil ignore)))
+  ;; Exclude ephemeral *eldoc* buffers, to avoid blinking (bug#81356).
+  (and (not (string-prefix-p " *eldoc" (buffer-name)))
+       (not (memq eldoc-documentation-strategy '(nil ignore)))
        (or eldoc-documentation-functions
            ;; The old API had major modes set `eldoc-documentation-function'
            ;; to provide eldoc support.  It's impossible now to determine