unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philipp <p.stephani2@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 48584@debbugs.gnu.org
Subject: bug#48584: 28.0.50; Incorrect hook ordering between local and global hooks with depth
Date: Mon, 5 Jul 2021 20:37:16 +0200	[thread overview]
Message-ID: <06A4701F-78A8-4904-AD18-ECBE4617ECDC@gmail.com> (raw)
In-Reply-To: <87o8cjuzk7.fsf@gnus.org>



> Am 06.06.2021 um 11:12 schrieb Lars Ingebrigtsen <larsi@gnus.org>:
> 
> Philipp <p.stephani2@gmail.com> writes:
> 
>>> If I'm reading run_hook_with_args correctly, it'll loop over the local
>>> hook first (in order), and when it happens upon a t in that value, it'll
>>> then loop over the global value (in order), and then finish up the rest
>>> of the local ones.
>> 
>> Yes - and that's a reasonable behavior to expect, and we should document it.
> 
> I think it's an implementation detail that users should not depend on.
> Where that `t' ends up being depends on many subtle things like the
> order of your add-hook/remove-hook calls in your .emacs file.

What we think about this doesn't matter much.  As I explained, people depend on observable/observed behavior.

Besides, hook ordering for abnormal hooks is crucial, so we can't just say "don't depend on it."

> 
>> Correct hook ordering is crucial for abnormal hooks.  We already rely
>> on the very specific ordering behavior several times in the Emacs
>> codebase alone.  I've searched a bit through the Emacs codebase, and
>> found the following places where Emacs runs an abnormal hook with
>> `run-hook-with-args-until-success/failure' that also gains a local
>> part somewhere the codebase:
> 
> [...]
> 
>> That is, we rely on this "undefined" behavior already in very basic
>> operations such as saving buffers to file.  In Eldoc, we even
>> explicitly tell users to add functions to the local part of this
>> abnormal hook (eldoc-documentation-functions), thereby telling them to
>> rely on "undefined" behavior!  This hopefully shows that the behavior
>> is far from being undefined.
> 
> I don't think it shows any such thing.

Why not?  Clearly there are hooks that are both abnormal and partially-local in the Emacs codebase, and for those hooks this issue arises.

> 
> I think it'd be a good idea to implement (and document) something in
> this area that actually allows users to control the hook running order
> properly, which currently just isn't possible.
> 

Yes, and arguably the current implementation with the "shadow" ordering stored in a private symbol property is already kind of a hack.  However, the second-best option is still to document the current behavior.  As I've tried to explain, just stating "it's undefined" won't fly.






  reply	other threads:[~2021-07-05 18:37 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
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 [this message]
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=06A4701F-78A8-4904-AD18-ECBE4617ECDC@gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=48584@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /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).