From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: 25581@debbugs.gnu.org
Subject: bug#25581: 25.1; Incorrect statement in (elisp) `Hooks'
Date: Mon, 24 Aug 2020 17:58:19 +0200 [thread overview]
Message-ID: <87zh6k6nok.fsf@gnus.org> (raw)
In-Reply-To: <CADwFkmnNsJMRQQ+vhVcCMJoj2OudQku39xzgXnWmZcbUHxhdvA@mail.gmail.com> (Stefan Kangas's message of "Mon, 24 Aug 2020 11:54:28 -0400")
Stefan Kangas <stefankangas@gmail.com> writes:
>>> If the variable’s name ends in ‘-function’, then its value is just a
>>> single function, not a list of functions. ‘add-hook’ cannot be used to
>>> modify such a _single function hook_, and you have to use ‘add-function’
>>> instead (*note Advising Functions::).
>>>
>>> You CAN use `add-hook' to modify such a single-function hook.
>>> Nothing prevents you from doing so. And nothing even suggests
>>> that you should not. And you have always been able to do so.
>
> I'm not sure the above makes sense. Doesn't it usually work like:
>
> (setq foo-function 'message)
> (add-hook 'foo-function 'error) ; should work?
> (funcall foo-function) ; => Lisp error: (invalid-function (error message))
run-hooks is very permissive -- you can set the value of a -hooks
variable to a single function, and it'll still work:
(setq my-hook (lambda () (message "foo")))
(run-hooks 'my-hook)
So I think Drew is assuming that this -function variable would be run by
run-hook, and then things would still indeed work.
> It sort of makes sense when read next to the paragraph before, doesn't
> it? There the concept "abnormal hook" is defined with an explanation of
> variables ending in '-functions', and the paragraph about variables
> ending in '-function' is written mostly in contrast to that.
>
> I think the confusing thing here is that there are two ways to modify
> these single function hooks: setq and add-function.
But -functions variables are abnormal hooks. -function variables aren't
hooks at all.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2020-08-24 15:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-30 16:51 bug#25581: 25.1; Incorrect statement in (elisp) `Hooks' Drew Adams
2017-01-31 3:05 ` npostavs
2017-01-31 3:36 ` Mark Oteiza
2017-01-31 4:06 ` Drew Adams
2017-01-31 3:55 ` Drew Adams
2017-01-31 4:16 ` npostavs
2017-01-31 16:02 ` Drew Adams
2017-02-01 3:35 ` npostavs
2017-02-01 17:01 ` Drew Adams
2017-02-04 21:00 ` npostavs
2017-02-05 2:11 ` Drew Adams
2017-02-10 1:42 ` npostavs
2017-02-10 3:00 ` Drew Adams
2020-10-11 2:26 ` Lars Ingebrigtsen
2020-10-11 14:12 ` Drew Adams
2020-08-24 15:22 ` Lars Ingebrigtsen
2020-08-24 15:54 ` Stefan Kangas
2020-08-24 15:58 ` Lars Ingebrigtsen [this message]
2020-08-24 16:20 ` Drew Adams
2020-08-24 16:13 ` Drew Adams
2020-08-24 16:18 ` Drew Adams
2020-08-26 1:50 ` Richard Stallman
2020-08-26 18:27 ` Drew Adams
2020-08-24 16:01 ` Drew Adams
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=87zh6k6nok.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=25581@debbugs.gnu.org \
--cc=stefankangas@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).