From: Drew Adams <drew.adams@oracle.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: RE: 1) (elisp) `Advising Named Functions', 2) search filtering example
Date: Mon, 17 Oct 2016 10:05:34 -0700 (PDT) [thread overview]
Message-ID: <6c7a705c-c810-49ec-a70c-376ba150205e@default> (raw)
In-Reply-To: <CAM-tV-97_4XKo8WZEvJX8L5F+ehnqvPFiPPkWR7kyK5EV4kDFg@mail.gmail.com>
> > I think that is wrong also. `add-hook' _can_ be used to modify a
> > _single function hook_. And the doc of `add-hook' tells you so,
> > in its last line - `C-h f add-hook':
> >
> > ...
> > If HOOK's value is a single function, it is changed to a list of
> > functions.
>
> If you do this, then you will break the callers, which expect the
> value of this variable to be a single function.
Tell that to the doc string for `add-hook', which has said what it
says in this regard for a very long time.
What has changed (what is new) is that this was added to node `Hooks':
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::).
And that is clearly false ("cannot be used" - it _can_ be so used).
This is what that doc used to say (e.g. Emacs 23.4):
By convention, abnormal hook names end in `-functions' or
`-hooks'. If the variable's name ends in `-function', then
its value is just a single function, not a list of functions.
There has thus also (apparently) been a change in policy here.
Whereas, before, this doc just let you know about the _naming
convention_ for a hook whose value is a single function, the
changed doc says (incorrectly) that you cannot use `add-hook'
with it.
I think that callers of such a hook should _use it as a hook_,
and not necessarily expect that the value is a single function.
Callers of a hook can, and should, I think, use one of the
`run-hook*' functions. And there too you will note that the
doc _explicitly_ talks about the non-list, single function case.
`C-h f run-hooks':
If a hook symbol has a non-nil value, that value may be a
function or a list of functions to be called to run the hook.
If the value is a function, it is called with no arguments.
If it is a list, the elements are called, in order, with no arguments.
`C-h f run-hook-with-args':
The value of HOOK may be nil, a function, or a list of functions.
Call each function in order with arguments ARGS.
(It used to say this:
If HOOK has a non-nil value, that value may be a function
or a list of functions to be called to run the hook. If the
value is a function, it is called with the given arguments
and its return value is returned. If it is a list of functions,
those functions are called, in order, with the given arguments ARGS.)
`C-h f run-hook-with-args-until-failure':
The value of HOOK may be nil, a function, or a list of functions.
Call each function in order with arguments ARGS, stopping at the
first one that returns nil, and return nil.
`C-h f run-hook-with-args-until-success': similar.
So do we have changes in policy wrt using hooks, or not?
(If yes, why?) Which doc needs to be fixed?
next prev parent reply other threads:[~2016-10-17 17:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 5:25 1) (elisp) `Advising Named Functions', 2) search filtering example Drew Adams
2016-10-17 12:20 ` Noam Postavsky
2016-10-17 14:02 ` Drew Adams
2016-10-17 14:37 ` Noam Postavsky
2016-10-17 14:52 ` Stefan Monnier
2016-10-17 15:40 ` Drew Adams
2016-10-17 15:51 ` Stefan Monnier
2016-10-17 17:05 ` Drew Adams
2016-10-17 17:47 ` Stefan Monnier
2016-10-17 15:40 ` Drew Adams
2016-10-17 16:16 ` Noam Postavsky
2016-10-17 17:05 ` Drew Adams [this message]
2016-10-17 17:53 ` Stefan Monnier
2016-10-17 18:41 ` Drew Adams
2016-10-17 19:25 ` Stefan Monnier
2016-10-18 19:47 ` Richard Stallman
2016-10-19 6:15 ` Eli Zaretskii
2016-10-19 20:00 ` Richard Stallman
2016-10-19 20:18 ` Stefan Monnier
2016-10-20 7:17 ` Eli Zaretskii
2016-10-20 7:06 ` Eli Zaretskii
2016-10-20 18:06 ` Richard Stallman
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6c7a705c-c810-49ec-a70c-376ba150205e@default \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=npostavs@users.sourceforge.net \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.