From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: doc on define-minor-mode hook variable(s)
Date: Mon, 6 Mar 2006 11:10:47 -0800 [thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICIEGGDDAA.drew.adams@oracle.com> (raw)
In-Reply-To: <E1FGKYb-0001BN-Hl@fencepost.gnu.org>
> In the past, hook variables were used, and the new notion
> that a hook need not be associated with a variable should
> be explained in the doc.
A hook IS a variable--that is to say, a symbol whose value is used.
It is a mistake to think that a hook is not a variable.
You quoted me, but I got the idea from Stefan - possibly I misunderstood
him.
IIUC, what Stefan meant was this (he will correct me):
- What makes a hook a hook is its use: if `run-hooks' uses it, then it's a
hook.
- A symbol used as a hook need not necessarily be bound before it is run.
That is, you can call `run-hooks' on a symbol that has never been bound -
nothing happens.
- Such an unbound symbol is not a variable. Of course, to do anything
useful as a hook, it must be bound.
- The way to set up a symbol to serve as a useful hook is to use
`add-hook'. Binding the symbol is not the way to go.
- For these reasons (I think), Stefan doesn't like to refer to "variable"
in this context: 1) The symbol can be run as an (inert) hook without being
bound. 2) Simply binding a symbol is not the way to make it useful as a
hook.
I don't know or care what terminology is used to describe the behavior of
hooks - I'm just learning.
To me, reading the `define-minor-mode' doc about `MODE-hook', I expected to
find existing (bound) variables named `MODE-hook' after calling
`define-minor-mode'. When I searched for them, I found none and I wondered
what the doc really meant.
It turns out (IIUC) that the doc simply meant that the created minor mode
command does (run-hooks 'MODE-hook). And, given an understanding of hooks
(which, in my case was incomplete), this means:
1. IF someone does (add-hook `MODE-hook' <something>) THEN <something> will
be run when the mode is entered and exited.
2. OTHERWISE, nothing will happen, because (run-hooks 'MODE-hook) does
nothing if `MODE-hook' is not bound or is bound to nil. I should say,
instead of speaking of binding, "if either `add-hook' was never called on it
or `remove-hook' was called to remove everything that `add-hook' had added".
I called this an "empty" hook, but Stefan didn't like that term.
IOW, in Stefan's terminology (IIUC): because `run-hooks' runs it, the hook
exists, even though the hook symbol might not be bound (so, no variable).
All this was not clear to me when I read the `define-minor-mode' doc. I
think it would be good if it were explained (using whatever terminology you
like) in the Hooks nodes of the manuals.
Again, I don't claim that my understanding is correct on this. My message
really is that I was confused by the current doc. Do with that feedback what
you will.
prev parent reply other threads:[~2006-03-06 19:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-05 19:40 doc on define-minor-mode hook variable(s) Drew Adams
2006-03-05 21:01 ` Stefan Monnier
2006-03-05 21:14 ` Drew Adams
2006-03-05 23:33 ` Stefan Monnier
2006-03-06 0:40 ` Drew Adams
2006-03-06 5:05 ` Stefan Monnier
2006-03-06 18:35 ` Richard Stallman
2006-03-06 19:09 ` Stefan Monnier
2006-03-08 21:06 ` Kevin Rodgers
2007-10-29 10:55 ` Juanma Barranquero
2006-03-06 19:10 ` Drew Adams [this message]
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=DNEMKBNJBGPAOPIJOOICIEGGDDAA.drew.adams@oracle.com \
--to=drew.adams@oracle.com \
/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.