GNU bug report logs - #79404
[BUG] eldoc-last-message should be a buffer-local variable

Previous Next

Package: emacs;

Reported by: me <at> lua.blog.br

Date: Sun, 7 Sep 2025 21:53:01 UTC

Severity: normal

Full log


Message #8 received at 79404 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: me <at> lua.blog.br, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 79404 <at> debbugs.gnu.org
Subject: Re: bug#79404: [BUG] eldoc-last-message should be a buffer-local
 variable
Date: Sat, 13 Sep 2025 12:51:11 +0300
> From: Lua Viana Reis <me <at> lua.blog.br>
> Date: Sun,  7 Sep 2025 21:51:33 +0000 (UTC)
> 
> Hi all,
> 
> Today I was wondering why the Eldoc echo area message kept flickering 
> when I moved around the file. After inpecting eldoc.el, I found from the 
> comment above the function "eldoc-pre-command-refresh-echo-area" that 
> this should not be the case and something was broken:
> 
> > ;; This function goes on pre-command-hook.
> > ;; Motion commands clear the echo area for some reason,
> > ;; which make eldoc messages flicker or disappear just before motion
> > ;; begins.  This function reprints the last eldoc message immediately
> > ;; before the next command executes, which does away with the flicker.
> > ;; This doesn't seem to be required for Emacs 19.28 and earlier.
> > ;; FIXME: The above comment suggests we don't really understand why
> > ;; this is needed.  Maybe it's not needed any more, but if it is
> > ;; we should figure out why.
> > (defun eldoc-pre-command-refresh-echo-area ()
> >   "Reprint `eldoc-last-message' in the echo area."
> >   (and eldoc-last-message
> >        (not (minibufferp))      ;We don't use the echo area when in 
> > minibuffer.
> >        (if (and (eldoc-display-message-no-interference-p)
> >         (eldoc--message-command-p this-command))
> >        (eldoc--message eldoc-last-message)
> >          ;; No need to call eldoc--message since the echo area will be 
> > cleared
> >          ;; for us, but do note that the last-message will be gone.
> >          (setq eldoc-last-message nil))))
> 
> So I used debug-on-variable-change to find out what was going on, and 
> found that the variable eldoc-last-message was being set to nil 
> immediately after being set. This variable is not buffer-local, and the 
> "(special-mode)" call in eldoc-doc-buffer-separator (called on every 
> eldoc message) would trigger "(global-eldoc-mode-enable-in-buffer)" 
> which in turn resets the global value to nil.
> 
> This is the bug, and I think the simple solution is to make it 
> buffer-local, which fixes the issue:
> 
> (make-variable-buffer-local 'eldoc-last-message)
> 
> I don't see why this variable should be global, but if there is a good 
> reason, then perhaps eldoc-last-message should not be set to nil in the 
> (eldoc-mode) function, or something else should be done to prevent this 
> feedback loop from happening.
> 
> Perhaps this bug report can also serve as an explanation for the person 
> who wrote "FIXME", because eldoc-pre-command-refresh-echo-area is still 
> necessary to prevent the flicker (given that the main issue is solved).

Thanks.  Sounds right to me, but I'm not familiar with ElDoc enough to
be sure.

Stefan, does this sound right to you?  If not, why is
eldoc-last-message a global var?




This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.