* bug#31042: Emacs 27. Inserting a character doesn't always "deactivate" the mark.
@ 2018-04-03 13:42 Alan Mackenzie
2018-04-03 14:08 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2018-04-03 13:42 UTC (permalink / raw)
To: 31042
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).
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#31042: Emacs 27. Inserting a character doesn't always "deactivate" the mark.
2018-04-03 13:42 bug#31042: Emacs 27. Inserting a character doesn't always "deactivate" the mark Alan Mackenzie
@ 2018-04-03 14:08 ` Eli Zaretskii
2018-04-03 14:39 ` Alan Mackenzie
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2018-04-03 14:08 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 31042
> Date: Tue, 3 Apr 2018 13:42:46 +0000
> From: Alan Mackenzie <acm@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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#31042: Emacs 27. Inserting a character doesn't always "deactivate" the mark.
2018-04-03 14:08 ` Eli Zaretskii
@ 2018-04-03 14:39 ` Alan Mackenzie
2018-04-03 15:12 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2018-04-03 14:39 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 31042
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@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).
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#31042: Emacs 27. Inserting a character doesn't always "deactivate" the mark.
2018-04-03 14:39 ` Alan Mackenzie
@ 2018-04-03 15:12 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2018-04-03 15:12 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 31042
> Date: Tue, 3 Apr 2018 14:39:12 +0000
> Cc: 31042@debbugs.gnu.org
> From: Alan Mackenzie <acm@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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-04-03 15:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03 13:42 bug#31042: Emacs 27. Inserting a character doesn't always "deactivate" the mark Alan Mackenzie
2018-04-03 14:08 ` Eli Zaretskii
2018-04-03 14:39 ` Alan Mackenzie
2018-04-03 15:12 ` Eli Zaretskii
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).