* Re: Terminology change/nameing conventions?
[not found] <87pr0fledo.fsf@rapttech.com.au>
@ 2010-05-29 3:10 ` Barry Margolin
2010-05-29 6:21 ` Helmut Eller
1 sibling, 0 replies; 2+ messages in thread
From: Barry Margolin @ 2010-05-29 3:10 UTC (permalink / raw)
To: help-gnu-emacs
In article <87pr0fledo.fsf@rapttech.com.au>,
Tim X <timx@nospam.dev.null> wrote:
> I was recently doing some work with elisp and noticed what appears to be
> differences in conventions regarding nameing.
>
> In general, I've always thought of the term 'hook' as indicating a
> special variable that you could add function names to and that all those
> functions would be executed when the hook runs. However, I've noticed
> that some modes, e.g. comint mode, uses the term -functions i.e.
> comint-output-functions. You use add-hook to add new functions to this
> variable.
>
> So, my question is why isn't this just comint-output-hook?
A hook is just for users to add customizations that are done in addition
to the normal behavior. E.g. XXX-mode-hook is a place for users to add
extra functions to run after XXX-mode. By default, the hook will be
empty.
comint-output-functions is used as part of the normal behavior of
comint. Comint initializes it with some default functions, which users
can add to or remove. Subsidiary modes use this to refine the behavior.
>
> I find this a bit inconsistent and frustrating. Often, when dealing with
> a new mode, I will do a regexp of the mode variables to find all the
> hooks I can use to customize it. However, now it seems I need to look
> for -functions as well.
>
> While on the topic of nameing, another one which seems a bit silly is
> the new functions that have been added with the name -command i.e.
> scroll-up-command. Is the additonal -command really necessary? I realise
> we have scroll-up (which ironically, is also a command!) and adding
> -command may have just been an easy suffix to distinguish it from the
> existing scroll-up command, but I still find it a bad choice. In fact,
> why do we have scroll-up and scroll-up-command? My view was that any
> function defined with (interactive) was a command. I find the addition
> of -command a bit pointless and the fact we have scroll-up and
> scroll-up-command potentially confusing - which one should I use? What
> next - adding -function suffixes!
I don't know if this is why the above functions are named like this, but
I think that XXX-command should be used for functions that are generally
intended ONLY for interactive use, not for use within other functions.
For instance, the end-of-buffer function would be better called
end-of-buffer-command, because it has the side effect of setting the
mark to the old location, which is specifically done for the benefit of
interactive users.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 2+ messages in thread