emacs-devel
[Top][All Lists]
Advanced

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

Re: 1) (elisp) `Advising Named Functions', 2) search filtering example


From: Stefan Monnier
Subject: Re: 1) (elisp) `Advising Named Functions', 2) search filtering example
Date: Mon, 17 Oct 2016 15:25:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)

> That's one interpretation.  There is no mention of the fact that
> the hook it is talking about is necessarily a "multiple-function
> hook" that happens to have a single function as value.

That's because you misunderstand its doc.  The confusion comes from the
multiple uses of the name "hook".  There are basically two uses of
the word "hook" in the context of Emacs:

- a very generic sense, which refers to some kind of way to influence
  the behavior of something.  Used also sometimes as a verb "you can
  hook directly into ..." which might be used even in cases where the
  "hooking" is done by modifying some chunk of code.  Sometimes
  "hook" is even used to just mean a customization point ("that package
  doesn't give me any hook to specify which char to insert").
- a specific sense, which refers to an "object" implemented as a symbol
  where the symbol-value slot holds a list of functions (and the "hook"
  is really the symbol, not the list of functions, because we can also use
  its various buffer-local values).

The second subsumes the first.

So *-function is a hook in the first sense but not in the second.
Whereas *-functions and *-hook are hooks in both senses.
add-hook and remove-hook only apply to hooks in the second sense.

The advice mechanism treats every symbol's function definition as a hook
(in the first sense), whether the author intended it that way (as is the
case for `ask-user-about-supersession-threat') or not.


        Stefan



reply via email to

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