GNU bug report logs - #78180
31.0.50; Since ab71699e5f2, global value of post-command-hook is useless

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Thu, 1 May 2025 08:46:01 UTC

Severity: normal

Found in version 31.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ihor Radchenko <yantar92 <at> posteo.net>
Subject: bug#78180: closed (Re: bug#78180: 31.0.50; Since ab71699e5f2,
 global value of post-command-hook is useless)
Date: Sat, 17 May 2025 08:05:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#78180: 31.0.50; Since ab71699e5f2, global value of post-command-hook is useless

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 78180 <at> debbugs.gnu.org.

-- 
78180: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78180
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: michael_heerdegen <at> web.de, 78180-done <at> debbugs.gnu.org
Subject: Re: bug#78180: 31.0.50; Since ab71699e5f2, global value of
 post-command-hook is useless
Date: Sat, 17 May 2025 11:04:15 +0300
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 78180 <at> debbugs.gnu.org
> Date: Fri, 02 May 2025 06:54:08 +0000
> 
> Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> 
> > Just to be sure: you are aware that in the normal case the global hook
> > binding will always be executed (additionally), as long as the symbol t
> > is not removed from the local hook binding, as explained in
> > (info "(elisp) Setting Hooks")?
> 
> I was not aware! That's embarrassing.
> 
> Now, I see
> 
>      If the hook variable is buffer-local, the buffer-local variable
>      will be used instead of the global variable.  However, if the
>      buffer-local variable contains the element ‘t’, the global hook
>      variable will be run as well.
> 
> IMHO, that detail might look good in 24.1 Hooks section itself, as it
> appears to be important. But maybe it is just me who did not notice
> this.
> 
> In any case, there is no bug in what I reported. Just my
> misunderstanding. Feel free to close.

No further comments, so I'm now closing this bug.

[Message part 3 (message/rfc822, inline)]
From: Ihor Radchenko <yantar92 <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; Since ab71699e5f2, global value of post-command-hook is
 useless
Date: Thu, 01 May 2025 08:44:01 +0000
Hi,

Before commit ab71699e5f2, global-eldoc-mode (enabled by default) did
nothing in most buffers and only activated when a given major mode
defined `eldoc-documentation-functions' (so that `eldoc--supported-p'
returns non-nil).

One can easily see this via
1. emacs -Q
2. C-x b *Messages* RET
3. M-: post-command-hook (nil)

After ab71699e5f2, `eldoc-documentation-functions' is no longer nil by
default, with immediate effect of *every single buffer* having
eldoc-mode enabled.

Enabling eldoc-mode itself is not a big deal. What is a big deal is the
fact that it is no longer possible to setup post-command-hook globally,
not just in current buffer, but also in all the future new buffers.
It is also not possible to setup transient hooks (self-removed upon
first execution) as long as current command ends up in different buffer.

(It was technically not exactly possible in the past as well, for
buffers holding their buffer-local post-command-hook value, but the
problem was less obvious as most buffers had post-command-hook set to
its default value)

The problem may affect:
1. Org mode (that's how I found the problem)
2. vcursor.el, vc.el, type-break.el, transient.el, xterm.el,
   scroll-all.el, global-reveal-mode, repeat-mode, gud.el, flymake,
   elisp-mode.el, and basically any other part of Emacs setting global
   default value of post-command-hook.

I do no think that ab71699e5f2 itself is doing anything wrong, but
rather that the design of post-command-hook is not ideal for its
purpose. The fact that we were able to get along with the current design
is by pure chance and the fact that most buffers did not set
buffer-local value of post-command-hook.

Maybe we should introduce post-command-global-hook that will be
evaluated in every single buffer and leave post-command-hook to be used
locally (maybe even rename it to post-command-local-hook for
clarity). Maybe similar for pre-command-hook.

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.49, cairo version 1.18.4) of 2025-04-29 built on localhost
Repository revision: 3a514005d153df429b0ed58ac64300296b9d5aac
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: Gentoo Linux
-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



This bug report was last modified 1 day ago.

Previous Next


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