GNU bug report logs - #25581
25.1; Incorrect statement in (elisp) `Hooks'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Mon, 30 Jan 2017 16:52:02 UTC

Severity: minor

Tags: fixed

Found in version 25.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 25581 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: bug#25581: 25.1; Incorrect statement in (elisp) `Hooks'
Date: Mon, 24 Aug 2020 17:58:19 +0200
Stefan Kangas <stefankangas <at> 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




This bug report was last modified 4 years and 285 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.