Variable: post-command-hook

post-command-hook is a buffer-local variable defined in keyboard.c.

Documentation

Normal hook run after each command is executed.

If an unhandled error happens in running this hook, the function in which the error occurred is unconditionally removed, since otherwise the error might happen repeatedly and make Emacs nonfunctional.

It is a bad idea to use this hook for expensive processing. If unavoidable, wrap your code in (while-no-input (redisplay) CODE) to avoid making Emacs unresponsive while the user types.

Note that, when long-line-optimizations-p is non-nil in the buffer, these functions are called as if they were in a with-restriction form, with a long-line-optimizations-in-command-hooks label and with the buffer narrowed to a portion around point whose size is specified by long-line-optimizations-region-size.

See also pre-command-hook.

View in manual

Probably introduced at or before Emacs version 19.18.

Source Code

// Defined in /usr/src/emacs/src/keyboard.c
  DEFVAR_LISP ("post-command-hook", Vpost_command_hook,
	       doc: /* Normal hook run after each command is executed.

If an unhandled error happens in running this hook, the function in
which the error occurred is unconditionally removed, since otherwise
the error might happen repeatedly and make Emacs nonfunctional.

It is a bad idea to use this hook for expensive processing.  If
unavoidable, wrap your code in `(while-no-input (redisplay) CODE)' to
avoid making Emacs unresponsive while the user types.

Note that, when `long-line-optimizations-p' is non-nil in the buffer,
these functions are called as if they were in a `with-restriction' form,
with a `long-line-optimizations-in-command-hooks' label and with the
buffer narrowed to a portion around point whose size is specified by
`long-line-optimizations-region-size'.

See also `pre-command-hook'.  */);