aboutsummaryrefslogtreecommitdiffstats
path: root/lispref
diff options
context:
space:
mode:
authorStefan Monnier2007-08-21 18:22:03 +0000
committerStefan Monnier2007-08-21 18:22:03 +0000
commit97c4ef2a204f2be3db8de5c900046abe09d0582a (patch)
treed70157d7cbda014f388718d4992374bc0341e913 /lispref
parentd5dac3b9bd5baa34ebb0506d0cd4460397a03d81 (diff)
downloademacs-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.texi36
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
4364functions. 4364functions.
4365@end defmac 4365@end defmac
4366 4366
4367The two variables above are temporarily bound to @code{nil} during the
4368time that any of these functions is running. This means that if one of
4369these functions changes the buffer, that change won't run these
4370functions. If you do want a hook function to make changes that run
4371these functions, make it bind these variables back to their usual
4372values.
4373
4374One inconvenient result of this protective feature is that you cannot
4375have a function in @code{after-change-functions} or
4376@code{before-change-functions} which changes the value of that variable.
4377But that's not a real limitation. If you want those functions to change
4378the list of functions to run, simply add one fixed function to the hook,
4379and code that function to look in another variable for other functions
4380to 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
4397This variable is a normal hook that is run whenever a buffer is changed 4368This variable is a normal hook that is run whenever a buffer is changed
4398that was previously in the unmodified state. 4369that was previously in the unmodified state.
@@ -4404,6 +4375,13 @@ disabled; none of them run. This affects all the hook variables
4404described above in this section, as well as the hooks attached to 4375described above in this section, as well as the hooks attached to
4405certain special text properties (@pxref{Special Properties}) and overlay 4376certain special text properties (@pxref{Special Properties}) and overlay
4406properties (@pxref{Overlay Properties}). 4377properties (@pxref{Overlay Properties}).
4378
4379Also, this variable is bound to non-@code{nil} while running those
4380same hook variables, so that by default modifying the buffer from
4381a modification hook does not cause other modification hooks to be run.
4382If you do want modification hooks to be run in a particular piece of
4383code 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