GNU bug report logs -
#31042
Emacs 27. Inserting a character doesn't always "deactivate" the mark.
Previous Next
Reported by: Alan Mackenzie <acm <at> muc.de>
Date: Tue, 3 Apr 2018 13:44:02 UTC
Severity: minor
Tags: notabug
Done: Alan Mackenzie <acm <at> muc.de>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31042 in the body.
You can then email your comments to 31042 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#31042
; Package
emacs
.
(Tue, 03 Apr 2018 13:44:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alan Mackenzie <acm <at> muc.de>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 03 Apr 2018 13:44:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello, Emacs.
In master, evaluate the following definition:
(defun no-deactivate-mark-bug (arg)
(interactive "P")
(transient-mark-mode 1)
(set-mark (point))
(forward-char)
(let ((inhibit-modification-hooks arg))
(insert "a"))
(message "deactivate-mark is %s" deactivate-mark))
. In a non-empty buffer, with point not at end of buffer, do
M-x no-deactivate-mark-bug
. The character "a" will have been inserted, the region will not be
"active", and the message in the message area will confirm that
deactivate-mark had been set to t. This is as it should be.
Now do
C-u M-x no-deactivate-mark-bug
. This time, after the insertion of "a", the region WILL spuriously be
"active", and the message will indicate that deactivate-mark was still
nil. This is a bug.
I found this bug whilst integrating the new combine-change-calls macro
into Emacs.
What triggers this bug is inhibit-modification-hooks being non-nil.
The place where the bug is is in prepare_to_modify_buffer_1 in
.../src/insdel.c. The test there of inhibit_modification_hooks rudely
exits before setting deactivate-mark to t. A patch which fixes this
(still not tidied up; it's left as simple as possible to read) is:
diff --git a/src/insdel.c b/src/insdel.c
index 173c243834..1f45ccd28a 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1951,9 +1951,10 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
else
base_buffer = current_buffer;
- if (inhibit_modification_hooks)
- return;
-
+ /* if (inhibit_modification_hooks) */
+ /* return; */
+ if (!inhibit_modification_hooks)
+ {
if (!NILP (BVAR (base_buffer, file_truename))
/* Make binding buffer-file-name to nil effective. */
&& !NILP (BVAR (base_buffer, filename))
@@ -1973,6 +1974,7 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
= call1 (Fsymbol_value (Qregion_extract_function), Qnil);
signal_before_change (start, end, preserve_ptr);
+ }
Fset (Qdeactivate_mark, Qt);
}
On a related note, it appears that in the same function, the file
locking is done for the first change in a buffer. This locking would
appear not to be done if that first change to the buffer happens when
inhibit-modification-hooks is non-nil. I haven't tested this, but it
would appear to be part of the same bug.
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31042
; Package
emacs
.
(Tue, 03 Apr 2018 14:09:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 31042 <at> debbugs.gnu.org (full text, mbox):
> Date: Tue, 3 Apr 2018 13:42:46 +0000
> From: Alan Mackenzie <acm <at> muc.de>
>
> On a related note, it appears that in the same function, the file
> locking is done for the first change in a buffer. This locking would
> appear not to be done if that first change to the buffer happens when
> inhibit-modification-hooks is non-nil. I haven't tested this, but it
> would appear to be part of the same bug.
This is a feature, see the doc string of inhibit-modification-hooks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31042
; Package
emacs
.
(Tue, 03 Apr 2018 14:40:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 31042 <at> debbugs.gnu.org (full text, mbox):
Hello, Eli.
On Tue, Apr 03, 2018 at 17:08:00 +0300, Eli Zaretskii wrote:
> > Date: Tue, 3 Apr 2018 13:42:46 +0000
> > From: Alan Mackenzie <acm <at> muc.de>
> > On a related note, it appears that in the same function, the file
> > locking is done for the first change in a buffer. This locking would
> > appear not to be done if that first change to the buffer happens when
> > inhibit-modification-hooks is non-nil. I haven't tested this, but it
> > would appear to be part of the same bug.
> This is a feature, see the doc string of inhibit-modification-hooks.
Yes, the whole thing is a feature. :-(
I now see that inhibit-modification-hooks is a special purpose facility,
only suited for applying text properties to the buffer. Perhaps it has
other uses, too.
It is most definitely not suitable for when "real" buffer modifications
are done. For that, presumably, one needs to bind
before/after-change-functions to nil, as used to be done before i-m-h
was invented.
I will need to modify the new combine-change-calls, which is no great
hardship.
How about me modifying the documentation and the doc string to point out
the disadvantages of inhibit-modification-hooks when used for actual
textual buffer changes?
I will close this bug.
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31042
; Package
emacs
.
(Tue, 03 Apr 2018 15:13:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 31042 <at> debbugs.gnu.org (full text, mbox):
> Date: Tue, 3 Apr 2018 14:39:12 +0000
> Cc: 31042 <at> debbugs.gnu.org
> From: Alan Mackenzie <acm <at> muc.de>
>
> How about me modifying the documentation and the doc string to point out
> the disadvantages of inhibit-modification-hooks when used for actual
> textual buffer changes?
This is stuff for the manual, not for the doc string, I think.
Added tag(s) notabug.
Request was from
Alan Mackenzie <acm <at> muc.de>
to
control <at> debbugs.gnu.org
.
(Tue, 03 Apr 2018 15:38:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
31042 <at> debbugs.gnu.org and Alan Mackenzie <acm <at> muc.de>
Request was from
Alan Mackenzie <acm <at> muc.de>
to
control <at> debbugs.gnu.org
.
(Tue, 03 Apr 2018 15:38:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 02 May 2018 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 52 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.