From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#31042: Emacs 27. Inserting a character doesn't always "deactivate" the mark. Date: Tue, 3 Apr 2018 13:42:46 +0000 Message-ID: <20180403134246.GA5363@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1522762966 1192 195.159.176.226 (3 Apr 2018 13:42:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 3 Apr 2018 13:42:46 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) To: 31042@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 03 15:42:42 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f3MCv-0000D5-Lv for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Apr 2018 15:42:41 +0200 Original-Received: from localhost ([::1]:35771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3MEz-0000hB-CA for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Apr 2018 09:44:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3MEI-0000Jh-QU for bug-gnu-emacs@gnu.org; Tue, 03 Apr 2018 09:44:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3MEE-0000bc-U3 for bug-gnu-emacs@gnu.org; Tue, 03 Apr 2018 09:44:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56362) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f3MEE-0000bV-OM for bug-gnu-emacs@gnu.org; Tue, 03 Apr 2018 09:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f3MEE-0002Uk-He for bug-gnu-emacs@gnu.org; Tue, 03 Apr 2018 09:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Apr 2018 13:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31042 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15227630139547 (code B ref -1); Tue, 03 Apr 2018 13:44:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Apr 2018 13:43:33 +0000 Original-Received: from localhost ([127.0.0.1]:36026 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f3MDl-0002Tv-MW for submit@debbugs.gnu.org; Tue, 03 Apr 2018 09:43:33 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38427) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f3MDj-0002Ti-Gj for submit@debbugs.gnu.org; Tue, 03 Apr 2018 09:43:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3MDd-0000Jg-C6 for submit@debbugs.gnu.org; Tue, 03 Apr 2018 09:43:26 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:40822) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f3MDd-0000Ja-8V for submit@debbugs.gnu.org; Tue, 03 Apr 2018 09:43:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3MDa-0008K2-7Y for bug-gnu-emacs@gnu.org; Tue, 03 Apr 2018 09:43:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3MDW-0000HR-UR for bug-gnu-emacs@gnu.org; Tue, 03 Apr 2018 09:43:22 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:46727 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1f3MDW-0000Gr-Ig for bug-gnu-emacs@gnu.org; Tue, 03 Apr 2018 09:43:18 -0400 Original-Received: (qmail 30814 invoked by uid 3782); 3 Apr 2018 13:43:16 -0000 Original-Received: from acm.muc.de (p5B147293.dip0.t-ipconnect.de [91.20.114.147]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 03 Apr 2018 15:43:16 +0200 Original-Received: (qmail 7691 invoked by uid 1000); 3 Apr 2018 13:42:46 -0000 Content-Disposition: inline X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:144848 Archived-At: 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).