unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [n_schumacher@web.de: modification hooks called only once in c-mode]
@ 2007-07-17 15:06 Richard Stallman
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2007-07-17 15:06 UTC (permalink / raw)
  To: emacs-devel

Would someone please DTRT, then ack?
If the fix is simple enough, it should be installed in Emacs 22.

------- Start of forwarded message -------
X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY 
	autolearn=failed version=3.1.0
To: bug-gnu-emacs@gnu.org
From: Nikolaj Schumacher <n_schumacher@web.de>
Date: Mon, 16 Jul 2007 23:13:53 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Subject: modification hooks called only once in c-mode

Hello,


occasionally modification hooks seem to be called only once in c-mode
(and derivatives).

This happens in both released and CVS version of Emacs 22, but not in
Emacs 21.


To reproduce, evaluate the following:

(defun test-bug-hook (overlay afterp beg end &optional r)
  (message "%s hook called" (if afterp "after" "before")))

(defun test-bug ()
  (let ((beg (point))
        ov)
    (insert "foobar")
    (setq ov (make-overlay beg (point)))
    (overlay-put ov 'face 'highlight)
    (overlay-put ov 'insert-in-front-hooks '(test-bug-hook))))


1) Create a new buffer in fundamental-mode, evaluate (test-bug), and
insert a char before the overlay.

Result:
before hook called
after hook called


1) Create a new buffer in c-mode, evaluate (test-bug), and insert a char
before the overlay.

Result:
before hook called


The hook is never called after the change.



In GNU Emacs 22.1.1 (i386-apple-darwin8.10.1, Carbon Version 1.6.0)
 of 2007-07-16 on wednesday
Windowing system distributor `Apple Inc.', version 10.4.10
configured using `configure  '--prefix=/Applications/Emacs.app/Contents/Resources' '--with-carbon' '--without-x' '--libexecdir=/Applications/Emacs.app/Contents/MacOS/libexec' 'CFLAGS=-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -DUSE_ATSUI -O2''


regards,
Nikolaj Schumacher


_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [n_schumacher@web.de: modification hooks called only once in c-mode]
@ 2007-07-24 22:17 Richard Stallman
  2007-08-01  9:16 ` Johan Bockgård
  0 siblings, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2007-07-24 22:17 UTC (permalink / raw)
  To: emacs-devel

[I sent this message a week ago but did not get a response.]

Would someone please DTRT, then ack?
If the fix is simple enough, it should be installed in Emacs 22.

------- Start of forwarded message -------
X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY 
	autolearn=failed version=3.1.0
To: bug-gnu-emacs@gnu.org
From: Nikolaj Schumacher <n_schumacher@web.de>
Date: Mon, 16 Jul 2007 23:13:53 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Subject: modification hooks called only once in c-mode

Hello,


occasionally modification hooks seem to be called only once in c-mode
(and derivatives).

This happens in both released and CVS version of Emacs 22, but not in
Emacs 21.


To reproduce, evaluate the following:

(defun test-bug-hook (overlay afterp beg end &optional r)
  (message "%s hook called" (if afterp "after" "before")))

(defun test-bug ()
  (let ((beg (point))
        ov)
    (insert "foobar")
    (setq ov (make-overlay beg (point)))
    (overlay-put ov 'face 'highlight)
    (overlay-put ov 'insert-in-front-hooks '(test-bug-hook))))


1) Create a new buffer in fundamental-mode, evaluate (test-bug), and
insert a char before the overlay.

Result:
before hook called
after hook called


1) Create a new buffer in c-mode, evaluate (test-bug), and insert a char
before the overlay.

Result:
before hook called


The hook is never called after the change.



In GNU Emacs 22.1.1 (i386-apple-darwin8.10.1, Carbon Version 1.6.0)
 of 2007-07-16 on wednesday
Windowing system distributor `Apple Inc.', version 10.4.10
configured using `configure  '--prefix=/Applications/Emacs.app/Contents/Resources' '--with-carbon' '--without-x' '--libexecdir=/Applications/Emacs.app/Contents/MacOS/libexec' 'CFLAGS=-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -DUSE_ATSUI -O2''


regards,
Nikolaj Schumacher


_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [n_schumacher@web.de: modification hooks called only once in c-mode]
@ 2007-07-31 20:22 Richard Stallman
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2007-07-31 20:22 UTC (permalink / raw)
  To: emacs-devel

[I sent this message twice but did not get a response.]

Would someone please DTRT, then ack?
If the fix is simple enough, it should be installed in Emacs 22.

------- Start of forwarded message -------
X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY 
	autolearn=failed version=3.1.0
To: bug-gnu-emacs@gnu.org
From: Nikolaj Schumacher <n_schumacher@web.de>
Date: Mon, 16 Jul 2007 23:13:53 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Subject: modification hooks called only once in c-mode

Hello,


occasionally modification hooks seem to be called only once in c-mode
(and derivatives).

This happens in both released and CVS version of Emacs 22, but not in
Emacs 21.


To reproduce, evaluate the following:

(defun test-bug-hook (overlay afterp beg end &optional r)
  (message "%s hook called" (if afterp "after" "before")))

(defun test-bug ()
  (let ((beg (point))
        ov)
    (insert "foobar")
    (setq ov (make-overlay beg (point)))
    (overlay-put ov 'face 'highlight)
    (overlay-put ov 'insert-in-front-hooks '(test-bug-hook))))


1) Create a new buffer in fundamental-mode, evaluate (test-bug), and
insert a char before the overlay.

Result:
before hook called
after hook called


1) Create a new buffer in c-mode, evaluate (test-bug), and insert a char
before the overlay.

Result:
before hook called


The hook is never called after the change.



In GNU Emacs 22.1.1 (i386-apple-darwin8.10.1, Carbon Version 1.6.0)
 of 2007-07-16 on wednesday
Windowing system distributor `Apple Inc.', version 10.4.10
configured using `configure  '--prefix=/Applications/Emacs.app/Contents/Resources' '--with-carbon' '--without-x' '--libexecdir=/Applications/Emacs.app/Contents/MacOS/libexec' 'CFLAGS=-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -DUSE_ATSUI -O2''


regards,
Nikolaj Schumacher


_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-07-24 22:17 Richard Stallman
@ 2007-08-01  9:16 ` Johan Bockgård
  2007-08-02 15:45   ` Richard Stallman
  0 siblings, 1 reply; 15+ messages in thread
From: Johan Bockgård @ 2007-08-01  9:16 UTC (permalink / raw)
  To: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> If the fix is simple enough, it should be installed in Emacs 22.

I don't have a fix, but here's a recipe that doesn't depends on c
mode.

;; emacs -Q

(defun test-bug-hook (overlay afterp beg end &optional r)
  (message "%s hook called" (if afterp "after" "before")))

(defun test-bug-after-change (beg end old-len)
  (remove-text-properties beg end nil))

(defun test-bug ()
  (interactive)
  (switch-to-buffer (get-buffer-create "*test*"))

  (kill-all-local-variables)
  (add-hook 'after-change-functions 'test-bug-after-change nil t)
  (setq font-lock-defaults '(nil t))

  (let ((beg (point)) ov)
    (insert "foobar")
    (setq ov (make-overlay beg (point)))
    (overlay-put ov 'face 'highlight)
    (overlay-put ov 'insert-in-front-hooks '(test-bug-hook)))
  (goto-char (point-min)))

(test-bug)

;; M-x eval-buffer RET
;; Insert char before overlay
;; => only before hook is called

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-08-01  9:16 ` Johan Bockgård
@ 2007-08-02 15:45   ` Richard Stallman
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2007-08-02 15:45 UTC (permalink / raw)
  To: Johan Bockgård; +Cc: emacs-devel

Thanks for finding a simpler test case -- that is progress.

Can someone please DTRT and ack?

Mail-Followup-To: emacs-devel@gnu.org
To: emacs-devel@gnu.org
From: bojohan+news@dd.chalmers.se (Johan =?utf-8?Q?Bockg=C3=A5rd?=)
Date: Wed, 01 Aug 2007 11:16:08 +0200
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Mail-Copies-To: never
Subject: Re: [n_schumacher@web.de: modification hooks called only once in
	c-mode]

Richard Stallman <rms@gnu.org> writes:

> If the fix is simple enough, it should be installed in Emacs 22.

I don't have a fix, but here's a recipe that doesn't depends on c
mode.

;; emacs -Q

(defun test-bug-hook (overlay afterp beg end &optional r)
  (message "%s hook called" (if afterp "after" "before")))

(defun test-bug-after-change (beg end old-len)
  (remove-text-properties beg end nil))

(defun test-bug ()
  (interactive)
  (switch-to-buffer (get-buffer-create "*test*"))

  (kill-all-local-variables)
  (add-hook 'after-change-functions 'test-bug-after-change nil t)
  (setq font-lock-defaults '(nil t))

  (let ((beg (point)) ov)
    (insert "foobar")
    (setq ov (make-overlay beg (point)))
    (overlay-put ov 'face 'highlight)
    (overlay-put ov 'insert-in-front-hooks '(test-bug-hook)))
  (goto-char (point-min)))

(test-bug)

;; M-x eval-buffer RET
;; Insert char before overlay
;; => only before hook is called

-- 
Johan Bockgård



_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [n_schumacher@web.de: modification hooks called only once in c-mode]
@ 2007-08-08  4:55 Richard Stallman
  2007-08-11  0:46 ` Chong Yidong
  0 siblings, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2007-08-08  4:55 UTC (permalink / raw)
  To: emacs-devel

[I sent this message three times but did not get a response.]

Would someone please DTRT, then ack?
If the fix is simple enough, it should be installed in Emacs 22.

------- Start of forwarded message -------
X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY 
	autolearn=failed version=3.1.0
To: bug-gnu-emacs@gnu.org
From: Nikolaj Schumacher <n_schumacher@web.de>
Date: Mon, 16 Jul 2007 23:13:53 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Subject: modification hooks called only once in c-mode

Hello,


occasionally modification hooks seem to be called only once in c-mode
(and derivatives).

This happens in both released and CVS version of Emacs 22, but not in
Emacs 21.


To reproduce, evaluate the following:

(defun test-bug-hook (overlay afterp beg end &optional r)
  (message "%s hook called" (if afterp "after" "before")))

(defun test-bug ()
  (let ((beg (point))
        ov)
    (insert "foobar")
    (setq ov (make-overlay beg (point)))
    (overlay-put ov 'face 'highlight)
    (overlay-put ov 'insert-in-front-hooks '(test-bug-hook))))


1) Create a new buffer in fundamental-mode, evaluate (test-bug), and
insert a char before the overlay.

Result:
before hook called
after hook called


1) Create a new buffer in c-mode, evaluate (test-bug), and insert a char
before the overlay.

Result:
before hook called


The hook is never called after the change.



In GNU Emacs 22.1.1 (i386-apple-darwin8.10.1, Carbon Version 1.6.0)
 of 2007-07-16 on wednesday
Windowing system distributor `Apple Inc.', version 10.4.10
configured using `configure  '--prefix=/Applications/Emacs.app/Contents/Resources' '--with-carbon' '--without-x' '--libexecdir=/Applications/Emacs.app/Contents/MacOS/libexec' 'CFLAGS=-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -DUSE_ATSUI -O2''


regards,
Nikolaj Schumacher


_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  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
  0 siblings, 2 replies; 15+ messages in thread
From: Chong Yidong @ 2007-08-11  0:46 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> Would someone please DTRT, then ack?
> If the fix is simple enough, it should be installed in Emacs 22.
> ....
>
> (defun test-bug-hook (overlay afterp beg end &optional r)
>   (message "%s hook called" (if afterp "after" "before")))
>
> (defun test-bug ()
>   (let ((beg (point))
>         ov)
>     (insert "foobar")
>     (setq ov (make-overlay beg (point)))
>     (overlay-put ov 'face 'highlight)
>     (overlay-put ov 'insert-in-front-hooks '(test-bug-hook))))
>
> 1) Create a new buffer in c-mode, evaluate (test-bug), and insert a char
> before the overlay.
>
> Result:
> before hook called
>
> The hook is never called after the change.

The problem is in report_overlay_modification in buffer.c.  This
function, which is called both before and after a modification,
compiles a list of modification-hooks to run and executes them.  When
called before modification, it first does

      last_overlay_modification_hooks_used = 0;

to reset the list of modification hooks to run.  

The bug arises when you have an after-change hook that does buffer
changes (in this case, this is c-after-change, which calls
c-invalidate-sws-region-after).  The sequence of events is:

 1. User issues command to modify the buffer.

 2. Before the change is applied, report_overlay_modification is
    called.  It resets last_overlay_modification_hooks_used to zero,
    then compiles a list of hooks to run.  This includes both the
    insert-in-front hook and the after-change hook.

 3. The insert-in-front hook runs.

 4. The buffer modification is applies.

 5. The after-change hook runs, modifying the buffer elsewhere.

 6. This results in report_overlay_modification being called, which
    resets last_overlay_modification_hooks_used to zero.  The
    insert-in-front hook, which was scheduled to run next, gets rubbed
    out.

One simple fix is to bind inhibit-modification-hooks in
c-after-change.

A deeper fix would be to make report_overlay_modification check if it
is being called in a modification hook, and take steps to prevent
scheduled hooks from being rubbed out.  I'm not sure this behavior is
significantly more "correct" than the existing one, however; it may be
better to leave it as is.

In either case, I'd suggest not putting the fix for this in Emacs
22.2.  The first fix can cause subtle problems since c-after-change is
a core part of cc-mode, and the second one is also somewhat delicate.
It can go in the trunk, and be merged into the branch for 22.3 if no
problems are found.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-08-11  0:46 ` Chong Yidong
@ 2007-08-12  4:14   ` Richard Stallman
  2007-08-12  5:50   ` Stefan Monnier
  1 sibling, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2007-08-12  4:14 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

    One simple fix is to bind inhibit-modification-hooks in
    c-after-change.

    A deeper fix would be to make report_overlay_modification check if it
    is being called in a modification hook, and take steps to prevent
    scheduled hooks from being rubbed out.  I'm not sure this behavior is
    significantly more "correct" than the existing one, however; it may be
    better to leave it as is.

It seems to me that the cleanest kind of fix is to save the relevant
data around actually invoking the hooks.  How hard or ugly is that?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  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
  1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2007-08-12  5:50 UTC (permalink / raw)
  To: Chong Yidong; +Cc: rms, emacs-devel

> The bug arises when you have an after-change hook that does buffer
> changes (in this case, this is c-after-change, which calls
> c-invalidate-sws-region-after).  The sequence of events is:
[...]
> One simple fix is to bind inhibit-modification-hooks in
> c-after-change.

Actually, why not bind inhibit-modification-hooks to t while running
after-change-functions (and friends)?

Those very rare hooks where modification hooks should not be inhibited
(don't know of any, but let's assume they may exist), they can rebind
inhibit-modification-hooks to nil.

This is an idea comparable to binding inhibit-quit while running timers,
filters, and sentinels.


        Stefan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-08-12  5:50   ` Stefan Monnier
@ 2007-08-13  0:52     ` Richard Stallman
  2007-08-13  4:10       ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2007-08-13  0:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: cyd, emacs-devel

    Actually, why not bind inhibit-modification-hooks to t while running
    after-change-functions (and friends)?

It does seem to make sense in general.
Let's try it.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-08-13  0:52     ` Richard Stallman
@ 2007-08-13  4:10       ` Stefan Monnier
  2007-08-13  5:59         ` David Kastrup
  2007-08-13  9:40         ` martin rudalics
  0 siblings, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2007-08-13  4:10 UTC (permalink / raw)
  To: rms; +Cc: cyd, emacs-devel

>     Actually, why not bind inhibit-modification-hooks to t while running
>     after-change-functions (and friends)?

> It does seem to make sense in general.
> Let's try it.

Installed,
Actually, the code already did something very much alike: while running
(after|before)-change-functions, those two variables were temporarily set
to nil.  This was done before inhibit-modification-hooks was invented and it
seems that it simply hadn't been updated to use inhibit-modification-hooks
instead.

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).


        Stefan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-08-13  4:10       ` Stefan Monnier
@ 2007-08-13  5:59         ` David Kastrup
  2007-08-16 20:46           ` Stefan Monnier
  2007-08-13  9:40         ` martin rudalics
  1 sibling, 1 reply; 15+ messages in thread
From: David Kastrup @ 2007-08-13  5:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: cyd, rms, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> 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.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-08-13  4:10       ` Stefan Monnier
  2007-08-13  5:59         ` David Kastrup
@ 2007-08-13  9:40         ` martin rudalics
  2007-08-13 14:01           ` Stefan Monnier
  1 sibling, 1 reply; 15+ messages in thread
From: martin rudalics @ 2007-08-13  9:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: cyd, rms, emacs-devel

 > 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).
 >
 > 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).

In the particular case `c-after-change' uses `c-save-buffer-state' which
binds (after|before)-change-functions to nil (probably for XEmacs
compatibility).  Wouldn't syntax.el be affected by that?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-08-13  9:40         ` martin rudalics
@ 2007-08-13 14:01           ` Stefan Monnier
  0 siblings, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2007-08-13 14:01 UTC (permalink / raw)
  To: martin rudalics; +Cc: cyd, rms, emacs-devel

>> 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).
>> 
>> 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).

> In the particular case `c-after-change' uses `c-save-buffer-state' which
> binds (after|before)-change-functions to nil (probably for XEmacs
> compatibility).  Wouldn't syntax.el be affected by that?

syntax.el sometimes does an add-hook/remove-hook on before-change-functions
from code which may be run from modification hooks.  The remove-hook is only
an optimization so if it's ignored/thrown out it doesn't impact correctness.
If the add-hook is ignored (it's run from syntax-ppss), it may OTOH impact
correctness, in which case the code that calls syntax-ppss under these
conditions may have to do the add-hook manually or somehow call
syntax-ppss-flush-cache manually when needed.


        Stefan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [n_schumacher@web.de: modification hooks called only once in c-mode]
  2007-08-13  5:59         ` David Kastrup
@ 2007-08-16 20:46           ` Stefan Monnier
  0 siblings, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2007-08-16 20:46 UTC (permalink / raw)
  To: David Kastrup; +Cc: cyd, rms, emacs-devel

>> 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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-08-16 20:46 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).