Subject: Re: bug#10384: 23.2; Emacs Lisp Reference Manual - incorrect or unclear documentation about invocation condition of hooks pre-command-hook and post-command-hook

From: Glenn Morris <[email-masked]>
Date: Wed, 11 Jan 2012 15:40:14 -0500

Bruno Félix Rezende Ribeiro wrote:

> Unless this behavior is justified by the expression "The editor command
> loop runs", I guess there is a contradiction.

Yes, it's implicit in the phrase "editor command loop".

If you think about it, the alternative interpretation doesn't make
sense. When called non-interactively, a command is just any old Lisp
function. So for it work the way you thought it might, Emacs would have
to check every single Lisp function call to see if that function was a
command, and if so run a hook before and after it. This would be pretty
impractical. Also what if a hook function called a function that
happened to be a command? :)

> When I press `C-h v pre-command-hook <RET>' I get
>
> Documentation:
> Normal hook run before each command is executed.

I could perhaps change this to say:

   Normal hook run before any command is executed interactively.

and similarly for post-command-hook.

I don't know what else to change. Perhaps add a note somewhere
(commandp?) that when a command is called non-interactively, it behaves
like any other Lisp function, and gets no special treatment.