[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Any convention for the suffix of hook functions?
From: |
Stefan Monnier |
Subject: |
Re: Any convention for the suffix of hook functions? |
Date: |
Thu, 27 Sep 2012 09:06:09 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) |
> I don't know if this is a standard, but it looks like the use
> of this convention is pretty consistent in Emacs Lisp.
Yes, it's a convention, documented in the Elisp manual ("-hook" is
a normal hook: no args, no return values; "-functions" is a non-normal
hook: can have args, can pay attention to the return values; "-function"
is not manipulated with add/remove-hook but just a place to put a single
function with setq(-local)).
> My question is: is there a naming convention for naming hook
> functions?
Not really, no. It's frequent to see a function for use on FOO-hook to
be named PACKAGE-FOO-hook (which should be read as "PACKAGE's function
for use on FOO-hook") and for FOO-functions the name is often
PACKAGE-FOO-function, but while I don't want to explicitly discourage
such names (I use them myself), they're not very good since they don't
describe what the function does but only who calls them.
Still, it's a "natural" choice when you can't come up with a good way to
describe what the function actually does; and that happens often because
it's in the nature of the functions we add to hooks to be ad-hoc and
strongly depend on who calls them.
Stefan