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

From: Stefan Kangas <[email-masked]>
Date: Mon, 24 Aug 2020 11:54:28 -0400

Lars Ingebrigtsen <[email-masked]> writes:

> Drew Adams <[email-masked]> writes:
>
>> The second sentence here is incorrect:
>>
>>  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))

> Well, the name -function suggests that you shouldn't.
>
> I think the confusing thing here is that foo-function isn't a hook at
> all -- variables ending with -function are normally not executed with
> run-hooks at all, so using add-hook on such a variable will normally
> break.
>
> So I'm not sure what that section is doing in the Hooks node at all.  It
> origin starts here, where unfortunately vc-region-history gives up.
>
> My preference here would be just to remove the paragraph, which is
> pretty confusing.

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.