diff options
| author | Stefan Monnier | 2007-08-21 18:22:03 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-08-21 18:22:03 +0000 |
| commit | 97c4ef2a204f2be3db8de5c900046abe09d0582a (patch) | |
| tree | d70157d7cbda014f388718d4992374bc0341e913 /lispref | |
| parent | d5dac3b9bd5baa34ebb0506d0cd4460397a03d81 (diff) | |
| download | emacs-97c4ef2a204f2be3db8de5c900046abe09d0582a.tar.gz emacs-97c4ef2a204f2be3db8de5c900046abe09d0582a.zip | |
(reset_var_on_error): New fun.
(signal_before_change, signal_after_change):
Use it to reset (after|before)-change-functions to nil in case of error.
Bind inhibit-modification-hooks to t.
Don't bind (after|before)-change-functions to nil while they run.
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/text.texi | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/lispref/text.texi b/lispref/text.texi index 4448e1cc402..bad68b7f8ae 100644 --- a/lispref/text.texi +++ b/lispref/text.texi | |||
| @@ -4364,35 +4364,6 @@ because it may lead to inefficient behavior for some change hook | |||
| 4364 | functions. | 4364 | functions. |
| 4365 | @end defmac | 4365 | @end defmac |
| 4366 | 4366 | ||
| 4367 | The two variables above are temporarily bound to @code{nil} during the | ||
| 4368 | time that any of these functions is running. This means that if one of | ||
| 4369 | these functions changes the buffer, that change won't run these | ||
| 4370 | functions. If you do want a hook function to make changes that run | ||
| 4371 | these functions, make it bind these variables back to their usual | ||
| 4372 | values. | ||
| 4373 | |||
| 4374 | One inconvenient result of this protective feature is that you cannot | ||
| 4375 | have a function in @code{after-change-functions} or | ||
| 4376 | @code{before-change-functions} which changes the value of that variable. | ||
| 4377 | But that's not a real limitation. If you want those functions to change | ||
| 4378 | the list of functions to run, simply add one fixed function to the hook, | ||
| 4379 | and code that function to look in another variable for other functions | ||
| 4380 | to call. Here is an example: | ||
| 4381 | |||
| 4382 | @example | ||
| 4383 | (setq my-own-after-change-functions nil) | ||
| 4384 | (defun indirect-after-change-function (beg end len) | ||
| 4385 | (let ((list my-own-after-change-functions)) | ||
| 4386 | (while list | ||
| 4387 | (funcall (car list) beg end len) | ||
| 4388 | (setq list (cdr list))))) | ||
| 4389 | |||
| 4390 | @group | ||
| 4391 | (add-hooks 'after-change-functions | ||
| 4392 | 'indirect-after-change-function) | ||
| 4393 | @end group | ||
| 4394 | @end example | ||
| 4395 | |||
| 4396 | @defvar first-change-hook | 4367 | @defvar first-change-hook |
| 4397 | This variable is a normal hook that is run whenever a buffer is changed | 4368 | This variable is a normal hook that is run whenever a buffer is changed |
| 4398 | that was previously in the unmodified state. | 4369 | that was previously in the unmodified state. |
| @@ -4404,6 +4375,13 @@ disabled; none of them run. This affects all the hook variables | |||
| 4404 | described above in this section, as well as the hooks attached to | 4375 | described above in this section, as well as the hooks attached to |
| 4405 | certain special text properties (@pxref{Special Properties}) and overlay | 4376 | certain special text properties (@pxref{Special Properties}) and overlay |
| 4406 | properties (@pxref{Overlay Properties}). | 4377 | properties (@pxref{Overlay Properties}). |
| 4378 | |||
| 4379 | Also, this variable is bound to non-@code{nil} while running those | ||
| 4380 | same hook variables, so that by default modifying the buffer from | ||
| 4381 | a modification hook does not cause other modification hooks to be run. | ||
| 4382 | If you do want modification hooks to be run in a particular piece of | ||
| 4383 | code that is itself run from a modification hook, then rebind locally | ||
| 4384 | @code{inhibit-modification-hooks} to @code{nil}. | ||
| 4407 | @end defvar | 4385 | @end defvar |
| 4408 | 4386 | ||
| 4409 | @ignore | 4387 | @ignore |