all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: David Kastrup <dak@gnu.org>
Cc: cyd@stupidchicken.com, rms@gnu.org, emacs-devel@gnu.org
Subject: Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
Date: Thu, 16 Aug 2007 16:46:21 -0400	[thread overview]
Message-ID: <jwv3ayjyzqw.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <85odhc3rgh.fsf@lola.goethe.zz> (David Kastrup's message of "Mon\, 13 Aug 2007 07\:59\:26 +0200")

>> A side benefit of the change is that now
>> (after|before)-change-function keep their values while they run, so
>> we can change (after|before)-change-functions from an
>> (after|before)-change-function (syntax.el enjoys doing that).

> Might need an Elisp manual update.

Indeed, thanks.  I've installed the patch below,


        Stefan


Index: lispref/text.texi
===================================================================
RCS file: /sources/emacs/emacs/lispref/text.texi,v
retrieving revision 1.145
diff -u -r1.145 text.texi
--- lispref/text.texi	27 Jun 2007 00:36:54 -0000	1.145
+++ lispref/text.texi	16 Aug 2007 20:45:39 -0000
@@ -4278,35 +4278,6 @@
 functions.
 @end defmac
 
-The two variables above are temporarily bound to @code{nil} during the
-time that any of these functions is running.  This means that if one of
-these functions changes the buffer, that change won't run these
-functions.  If you do want a hook function to make changes that run
-these functions, make it bind these variables back to their usual
-values.
-
-One inconvenient result of this protective feature is that you cannot
-have a function in @code{after-change-functions} or
-@code{before-change-functions} which changes the value of that variable.
-But that's not a real limitation.  If you want those functions to change
-the list of functions to run, simply add one fixed function to the hook,
-and code that function to look in another variable for other functions
-to call.  Here is an example:
-
-@example
-(setq my-own-after-change-functions nil)
-(defun indirect-after-change-function (beg end len)
-  (let ((list my-own-after-change-functions))
-    (while list
-      (funcall (car list) beg end len)
-      (setq list (cdr list)))))
-
-@group
-(add-hooks 'after-change-functions
-           'indirect-after-change-function)
-@end group
-@end example
-
 @defvar first-change-hook
 This variable is a normal hook that is run whenever a buffer is changed
 that was previously in the unmodified state.
@@ -4318,6 +4289,13 @@
 described above in this section, as well as the hooks attached to
 certain special text properties (@pxref{Special Properties}) and overlay
 properties (@pxref{Overlay Properties}).
+
+Also, this variable is bound to non-@code{nil} while running those
+same hook variables, so that by default modifying the buffer from
+a modification hook does not cause other modification hooks to be run.
+If you do want modification hooks to be run in a particular piece of
+code that is itself run from a modification hook, then rebind locally
+@code{inhibit-modification-hooks} to @code{nil}.
 @end defvar
 
 @ignore

  reply	other threads:[~2007-08-16 20:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-08  4:55 [n_schumacher@web.de: modification hooks called only once in c-mode] Richard Stallman
2007-08-11  0:46 ` Chong Yidong
2007-08-12  4:14   ` Richard Stallman
2007-08-12  5:50   ` Stefan Monnier
2007-08-13  0:52     ` Richard Stallman
2007-08-13  4:10       ` Stefan Monnier
2007-08-13  5:59         ` David Kastrup
2007-08-16 20:46           ` Stefan Monnier [this message]
2007-08-13  9:40         ` martin rudalics
2007-08-13 14:01           ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2007-07-31 20:22 Richard Stallman
2007-07-24 22:17 Richard Stallman
2007-08-01  9:16 ` Johan Bockgård
2007-08-02 15:45   ` Richard Stallman
2007-07-17 15:06 Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv3ayjyzqw.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=cyd@stupidchicken.com \
    --cc=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.