bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#48584: 28.0.50; Incorrect hook ordering between local and global hoo


From: Lars Ingebrigtsen
Subject: bug#48584: 28.0.50; Incorrect hook ordering between local and global hooks with depth
Date: Tue, 25 May 2021 22:07:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Philipp <p.stephani2@gmail.com> writes:

> Evaluate these forms:
>
> (add-hook 'my-hook (lambda () (message "Outer")) 20)
> (with-temp-buffer
>   (add-hook 'my-hook (lambda () (message "Inner")) 10 :local)
>   (run-hooks 'my-hook))
>
> Then in the *Messages* buffer, "Inner" appears *after* "Outer" even
> though the local function's depth is lower than the global one's.

Looking at the code, the order is computed by `add-hook' by stashing
data in the symbol plist of my-hook, but the hook function is then
pushed onto either the local or the global version of the variable.  So
the ordering isn't global -- it's one ordering for the local and one for
the global, and `run-hooks' doesn't say anything about what order the
local and global values are run in?

(The global value is run when `t' appears in the local value.)

So...  I don't see any obvious way to fix this, and perhaps we should
just document that the order is undefined when you have both local and
global hooks with the same name.

Any opinions?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]