emacs-devel
[Top][All Lists]
Advanced

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

RE: questions about blink-cursor-mode


From: Drew Adams
Subject: RE: questions about blink-cursor-mode
Date: Thu, 19 Nov 2009 09:17:31 -0800

> > Thanks, Juanma. Now that I see that explanation, I recall 
> > that I knew this at one time - but I guess I forgot it.
> > Note that not only is it not declared (e.g.  defvar), it
> > is also not bound, which is why `C-h v' doesn't recognize it.
> 
> The first problem is in the docstring:
>   "It finishes by running the mode hook variable `MODE-hook'."
> this repeats a very widespread misconception, which is that 
> those hooks are variables.  They're not: a hook is a symbol,
> not a variable. That's why it can work even if the variable
> by that name is not bound.

1. Yes, fine, correct the doc string if you like. Similarly, the Emacs manual
and Elisp manual need to be corrected, if you deem this important. The Emacs
manual, node Hooks, defined "hook" in its very first sentence this way:

  "Hooks" are an important mechanism for customizing Emacs.
  A hook is a Lisp variable which holds a list of functions,
  to be called on some well-defined occasion.

And the Elisp manual, node Hooks, repeats the same thing (why such repetition,
BTW?):

  A "hook" is a variable where you can store a function or functions
  to be called on a particular occasion by an existing program.

The entire Hooks node in each manual then explains more about such "variables"
("symbol" is never used). If the distinction is truly important here, then we
shouldn't be defining hooks in a way that loses the distinction.

However, for a hook to actually be _used_, `add-hook' or similar must have been
called, so the symbol must have a value. (And even if you then use
`remove-hook', the symbol is not unbound.)

IOW, for any discussion or explanation of the real use of a hook symbol, which
pretty much means for all practical purposes, the symbol is a variable (it has a
value - it must have a value to be useful).

The nuanced explanation helps users like me who forget or are unaware of the
fact that hooks are not bound initially, but I don't know what purpose it serves
otherwise.

So what is the reason that hook symbols are not initialized to nil? Is it simply
to save a little memory? If they were initialized (e.g. by such as
`define-minor-mode'), then they would show up for things like `C-h v', which
helps user discovery. IOW, what is the benefit of not initializing them?


2. My main questions are still out there - the discussion about hooks being
possibly unbound symbols is ancillary. The questions are about
`blink-cursor-mode'. It is a global minor mode. Is there a way (how?) to turn it
on only locally - e.g. for a particular buffer or mode? (`make-local-variable'
won't help.)

If not, what's a good way to get something like that effect? Currently, I just
turn it on when my particular major mode is turned on, and then turn it off when
that mode is exited (or, via `blink-cursor-mode-hook', when the user turns it
off). This is an ugly, approximative hack - I'd love to learn a better approach.





reply via email to

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