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


View this message in rfc822 format

From: Stéphane Marks <shipmints <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 79404 <at> debbugs.gnu.org, me <at> lua.blog.br
Subject: bug#79404: [BUG] eldoc-last-message should be a buffer-local variable
Date: Sat, 13 Sep 2025 12:39:47 -0400
[Message part 1 (text/plain, inline)]
On Sat, Sep 13, 2025 at 12:31 PM Stefan Monnier via Bug reports for GNU
Emacs, the Swiss army knife of text editors <bug-gnu-emacs <at> gnu.org> wrote:

> >> 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)
> [...]
> > Stefan, does this sound right to you?  If not, why is
> > eldoc-last-message a global var?
>
> I don't think anyone thought very deeply about whether it should be
> global or buffer-local when writing the code.  The above suggest making
> it buffer-local could make sense, yet the actual display of the message
> is "global" in the sense that it's displayed in the echo area that is
> shared by all buffers.
>
> So, I'm personally not sure which of global or buffer-local is The
> Right Choice.  The code that handles *re*displaying and *un*displaying
> the eldoc info is a bit too complex for me to figure out.
>
> OTOH, if the var is global, I can't see why the buffer-local
> `eldoc-mode` should set it to nil.  Furthermore, maybe we should also
> look into why `eldoc-mode` is enabled during
> `eldoc-doc-buffer-separator`.  E.g. it might make sense to change
> `eldoc--supported-p` so it returns nil in temp buffers.
>

FWIW, I clear `eldoc-last-message` via `window-buffer-change-functions` to
avoid cross-buffer cruft and would welcome the upgrade to a buffer-local.
[Message part 2 (text/html, inline)]

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.