From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [n_schumacher@web.de: modification hooks called only once in c-mode] Date: Thu, 16 Aug 2007 16:46:21 -0400 Message-ID: References: <874pj6j3te.fsf@stupidchicken.com> <85odhc3rgh.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1187297436 22075 80.91.229.12 (16 Aug 2007 20:50:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 16 Aug 2007 20:50:36 +0000 (UTC) Cc: cyd@stupidchicken.com, rms@gnu.org, emacs-devel@gnu.org To: David Kastrup Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 16 22:50:32 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ILmIa-00072D-6t for ged-emacs-devel@m.gmane.org; Thu, 16 Aug 2007 22:50:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ILmIZ-0000UN-NA for ged-emacs-devel@m.gmane.org; Thu, 16 Aug 2007 16:50:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ILmF2-00072h-2N for emacs-devel@gnu.org; Thu, 16 Aug 2007 16:46:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ILmEn-0006tA-MM for emacs-devel@gnu.org; Thu, 16 Aug 2007 16:46:51 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ILmEn-0006sz-G6 for emacs-devel@gnu.org; Thu, 16 Aug 2007 16:46:37 -0400 Original-Received: from mercure.iro.umontreal.ca ([132.204.24.67]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ILmEe-0001Yv-Oe; Thu, 16 Aug 2007 16:46:29 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 2B2AE2CEF7F; Thu, 16 Aug 2007 16:46:27 -0400 (EDT) Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 118A93FE0; Thu, 16 Aug 2007 16:46:22 -0400 (EDT) Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id E71986C1AD; Thu, 16 Aug 2007 16:46:21 -0400 (EDT) In-Reply-To: <85odhc3rgh.fsf@lola.goethe.zz> (David Kastrup's message of "Mon\, 13 Aug 2007 07\:59\:26 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-Detected-Kernel: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:76643 Archived-At: >> 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