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

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

bug#25581: 25.1; Incorrect statement in (elisp) `Hooks'


From: Lars Ingebrigtsen
Subject: bug#25581: 25.1; Incorrect statement in (elisp) `Hooks'
Date: Mon, 24 Aug 2020 17:58:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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





reply via email to

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