unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Philipp <p.stephani2@gmail.com>
Cc: 48584@debbugs.gnu.org
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	[thread overview]
Message-ID: <871r9uefvy.fsf@gnus.org> (raw)
In-Reply-To: <m2im3bvwsu.fsf@Philipps-MBP.fritz.box> (Philipp's message of "Sat, 22 May 2021 13:21:21 +0200")

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	other threads:[~2021-05-25 20:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-22 11:21 bug#48584: 28.0.50; Incorrect hook ordering between local and global hooks with depth Philipp
2021-05-25 20:07 ` Lars Ingebrigtsen [this message]
2021-05-25 20:23   ` Philipp Stephani
2021-05-26 21:50     ` Lars Ingebrigtsen
2021-06-04 13:20       ` Philipp
2021-06-06  9:12         ` Lars Ingebrigtsen
2021-07-05 18:37           ` Philipp
2021-07-06 13:58             ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871r9uefvy.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=48584@debbugs.gnu.org \
    --cc=p.stephani2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).