From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 35508@debbugs.gnu.org
Subject: bug#35508: 27.0.50; Fine-ordering of functions on hooks
Date: Wed, 01 May 2019 16:29:00 -0400 [thread overview]
Message-ID: <jwvo94mlyjf.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <831s1iqclm.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 01 May 2019 21:00:21 +0300")
>> Occasionally it's important to control the relative ordering of
>> functions on hooks. It's usually a bad idea, but sometimes alternatives
>> are worse.
> Could you please give a couple of examples?
The patch includes the post-self-insert-hook example, I already mentioned
the after-change-functions example (where cc-mode wants his hook to
come before font-lock's), and I could add the case of
syntax-propertize's before-change-functions which needs to "come last".
> I agree that it's usually a bad idea, so maybe we should resist the
> temptation.
So far people haven't resisted the temptation, but have instead worked
around the lack of direct support for it, either by ad-hoc ways to
detect mis-ordering and re-set the ordering accordingly, or by hoping
for the best.
> If the worse comes to worst, a Lisp program could concoct
> the entire hook list in any order it sees fit, right?
I don't understand what you mean here.
>> +The place where the function is added depends on the DEPTH
>> +parameter. DEPTH defaults to 0.
>
> So from now on, omitting DEPTH will not necessarily put the function
> at the beginning of the hook list?
Indeed. Same for `t` not always going to the very end.
> That's backward-incompatible, no?
Sure.
> In any case, this default is insufficiently tested by the tests
> you propose.
What other tests do you suggest?
> So using 100 more than once makes the last one "win"?
Yes. This is so that when using `t` more than once, the last one wins,
just as it used to.
>> +For backward compatibility reasons, a symbol other than nil is
>> +interpreted as a DEPTH of 90.
> This is not explicitly tested by the test.
I can a test to try and check that `90` corresponds to `t`, if you want,
although this property is trivially verified by looking at the code.
[ I tend to prefer tests that try and catch tricky interactions rather
than straightforward bases cases. E.g. the tests I included are the
ones that failed during development ;-) ]
Stefan
next prev parent reply other threads:[~2019-05-01 20:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 20:37 bug#35508: 27.0.50; Fine-ordering of functions on hooks Stefan Monnier
2019-04-30 21:37 ` Drew Adams
2019-04-30 22:31 ` Stefan Monnier
2019-05-01 18:00 ` Eli Zaretskii
2019-05-01 20:29 ` Stefan Monnier [this message]
2019-05-08 18:32 ` Stefan Monnier
2019-05-11 12:05 ` Eli Zaretskii
2019-05-11 13:26 ` Stefan Monnier
2019-05-11 13:54 ` Eli Zaretskii
2019-05-13 13:29 ` Stefan Monnier
2019-05-29 19:56 ` Stefan Monnier
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=jwvo94mlyjf.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=35508@debbugs.gnu.org \
--cc=eliz@gnu.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).