diff options
| author | Stefan Monnier | 2007-08-16 20:46:34 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-08-16 20:46:34 +0000 |
| commit | b9c520997ee12e698739c3faca9bf7532a1076f7 (patch) | |
| tree | 300987cdb7737ab37a8feb77291c30ef2e3b81b0 | |
| parent | 44a0e58612792466d9277b253ead9c398b7bf714 (diff) | |
| download | emacs-b9c520997ee12e698739c3faca9bf7532a1076f7.tar.gz emacs-b9c520997ee12e698739c3faca9bf7532a1076f7.zip | |
*** empty log message ***
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lispref/text.texi | 36 |
2 files changed, 12 insertions, 29 deletions
| @@ -175,6 +175,11 @@ supported on other platforms, but not on Windows due to using the winsock | |||
| 175 | 175 | ||
| 176 | * Lisp Changes in Emacs 23.1 | 176 | * Lisp Changes in Emacs 23.1 |
| 177 | 177 | ||
| 178 | +++ | ||
| 179 | ** inhibit-modification-hooks is bound to t while running modification hooks. | ||
| 180 | As a happy consequence, after-change-functions and before-change-functions | ||
| 181 | are not bound to nil any more while running an (after|before)-change-function. | ||
| 182 | |||
| 178 | ** Non-breaking space now acts as whitespace. | 183 | ** Non-breaking space now acts as whitespace. |
| 179 | 184 | ||
| 180 | +++ | 185 | +++ |
diff --git a/lispref/text.texi b/lispref/text.texi index b3cd6cb4a92..430c48133ee 100644 --- a/lispref/text.texi +++ b/lispref/text.texi | |||
| @@ -4278,35 +4278,6 @@ because it may lead to inefficient behavior for some change hook | |||
| 4278 | functions. | 4278 | functions. |
| 4279 | @end defmac | 4279 | @end defmac |
| 4280 | 4280 | ||
| 4281 | The two variables above are temporarily bound to @code{nil} during the | ||
| 4282 | time that any of these functions is running. This means that if one of | ||
| 4283 | these functions changes the buffer, that change won't run these | ||
| 4284 | functions. If you do want a hook function to make changes that run | ||
| 4285 | these functions, make it bind these variables back to their usual | ||
| 4286 | values. | ||
| 4287 | |||
| 4288 | One inconvenient result of this protective feature is that you cannot | ||
| 4289 | have a function in @code{after-change-functions} or | ||
| 4290 | @code{before-change-functions} which changes the value of that variable. | ||
| 4291 | But that's not a real limitation. If you want those functions to change | ||
| 4292 | the list of functions to run, simply add one fixed function to the hook, | ||
| 4293 | and code that function to look in another variable for other functions | ||
| 4294 | to call. Here is an example: | ||
| 4295 | |||
| 4296 | @example | ||
| 4297 | (setq my-own-after-change-functions nil) | ||
| 4298 | (defun indirect-after-change-function (beg end len) | ||
| 4299 | (let ((list my-own-after-change-functions)) | ||
| 4300 | (while list | ||
| 4301 | (funcall (car list) beg end len) | ||
| 4302 | (setq list (cdr list))))) | ||
| 4303 | |||
| 4304 | @group | ||
| 4305 | (add-hooks 'after-change-functions | ||
| 4306 | 'indirect-after-change-function) | ||
| 4307 | @end group | ||
| 4308 | @end example | ||
| 4309 | |||
| 4310 | @defvar first-change-hook | 4281 | @defvar first-change-hook |
| 4311 | This variable is a normal hook that is run whenever a buffer is changed | 4282 | This variable is a normal hook that is run whenever a buffer is changed |
| 4312 | that was previously in the unmodified state. | 4283 | that was previously in the unmodified state. |
| @@ -4318,6 +4289,13 @@ disabled; none of them run. This affects all the hook variables | |||
| 4318 | described above in this section, as well as the hooks attached to | 4289 | described above in this section, as well as the hooks attached to |
| 4319 | certain special text properties (@pxref{Special Properties}) and overlay | 4290 | certain special text properties (@pxref{Special Properties}) and overlay |
| 4320 | properties (@pxref{Overlay Properties}). | 4291 | properties (@pxref{Overlay Properties}). |
| 4292 | |||
| 4293 | Also, this variable is bound to non-@code{nil} while running those | ||
| 4294 | same hook variables, so that by default modifying the buffer from | ||
| 4295 | a modification hook does not cause other modification hooks to be run. | ||
| 4296 | If you do want modification hooks to be run in a particular piece of | ||
| 4297 | code that is itself run from a modification hook, then rebind locally | ||
| 4298 | @code{inhibit-modification-hooks} to @code{nil}. | ||
| 4321 | @end defvar | 4299 | @end defvar |
| 4322 | 4300 | ||
| 4323 | @ignore | 4301 | @ignore |