Go to the first, previous, next, last section, table of contents.

Change Hooks

These hook variables let you arrange to take notice of all changes in all buffers (or in a particular buffer, if you make them buffer-local).

The functions you use in these hooks should save and restore the match data if they do anything that uses regular expressions; otherwise, they will interfere in bizarre ways with the editing operations that call them.

Buffer changes made while executing the following hooks don't themselves cause any change hooks to be invoked.

Variable: before-change-functions
This variable holds a list of a functions to call before any buffer modification. Each function gets two arguments, the beginning and end of the region that is about to change, represented as integers. The buffer that is about to change is always the current buffer.

Variable: after-change-functions
This variable holds a list of a functions to call after any buffer modification. Each function receives three arguments: the beginning and end of the region just changed, and the length of the text that existed before the change. (To get the current length, subtract the region beginning from the region end.) All three arguments are integers. The buffer that's about to change is always the current buffer.

Variable: before-change-function
This obsolete variable holds one function to call before any buffer modification (or nil for no function). It is called just like the functions in before-change-functions.

Variable: after-change-function
This obsolete variable holds one function to call after any buffer modification (or nil for no function). It is called just like the functions in after-change-functions.

Variable: first-change-hook
This variable is a normal hook that is run whenever a buffer is changed that was previously in the unmodified state.


Go to the first, previous, next, last section, table of contents.