GNU bug report logs -
#10117
duplicate evaluation of after-change-functions hooks in revert-buffer
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10117 in the body.
You can then email your comments to 10117 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10117
; Package
emacs
.
(Wed, 23 Nov 2011 11:21:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Tiphaine Turpin <tiphaine.turpin <at> inria.fr>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 23 Nov 2011 11:21:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
I'm having a strange behavior while trying to track the modifications to
a buffer: calling revert-buffer triggers the following calls to my
after-change-functions hook
- a region deletion (which is exactly the changed region between the
buffer and the file)
- a region insertion (the new contents for the changed region)
- the same insertion again.
I don't care about how many modifications the reverting is splited into,
or whether these are minimal or all the buffer contents is considered
new, but the duplicate insertion leads me into invalid assumptions about
the new contents (I use this to maintain a exact mapping of the buffer
into an external tool).
Am I wrong when I assume that the sequence of modifications passed to
the after-change-functions is an exact trace of the buffer contents
evolution ? What could possibly cause such a duplicate event ?
Note: I'm not doing anything strange in the hook like changing the
buffers' contents. This is just a numeric computation which update some
buffer-local variables which track the set of "unprocessed"
modifications. The hook is added as buffer-local (and global value of
after-change-functions is nil).
Regards,
Tiphaine Turpin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10117
; Package
emacs
.
(Wed, 23 Nov 2011 14:45:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 10117 <at> debbugs.gnu.org (full text, mbox):
> Am I wrong when I assume that the sequence of modifications passed to the
> after-change-functions is an exact trace of the buffer contents evolution ?
Well, it should be, yes.
> What could possibly cause such a duplicate event ?
A bug in revert-buffer? revert-buffer modifies the buffer on its own
rather than via calls to delete and insert, so it runs those
change-functions "by hand". Do you have a small test case reproducing
the problem?
Stefan
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Thu, 01 Dec 2011 20:24:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Tiphaine Turpin <tiphaine.turpin <at> inria.fr>
:
bug acknowledged by developer.
(Thu, 01 Dec 2011 20:24:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 10117-done <at> debbugs.gnu.org (full text, mbox):
>> change-functions "by hand". Do you have a small test case reproducing
>> the problem?
> Here is an example:
> First open the attached file in Emacs and evaluate it. Then:
> echo ';Hi!' >>revert-bug.el
> The *Messages* buffer shows the following:
> modify [175, 180[ (old-len=0) [2 times]
Indeed, I see that too. I've installed the patch below which should
fix it. Thanks for the simple test case.
Stefan
=== modified file 'src/fileio.c'
--- src/fileio.c 2011-11-26 21:40:41 +0000
+++ src/fileio.c 2011-12-01 20:14:53 +0000
@@ -4100,6 +4100,16 @@
adjust_after_insert (PT, PT_BYTE, PT + inserted, PT_BYTE + inserted,
inserted);
+ /* Call after-change hooks for the inserted text, aside from the case
+ of normal visiting (not with REPLACE), which is done in a new buffer
+ "before" the buffer is changed. */
+ if (inserted > 0 && total > 0
+ && (NILP (visit) || !NILP (replace)))
+ {
+ signal_after_change (PT, 0, inserted);
+ update_compositions (PT, PT, CHECK_BORDER);
+ }
+
/* Now INSERTED is measured in characters. */
handled:
@@ -4270,16 +4280,6 @@
unbind_to (count1, Qnil);
}
- /* Call after-change hooks for the inserted text, aside from the case
- of normal visiting (not with REPLACE), which is done in a new buffer
- "before" the buffer is changed. */
- if (inserted > 0 && total > 0
- && (NILP (visit) || !NILP (replace)))
- {
- signal_after_change (PT, 0, inserted);
- update_compositions (PT, PT, CHECK_BORDER);
- }
-
if (!NILP (visit)
&& current_buffer->modtime == -1)
{
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 30 Dec 2011 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 227 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.