From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#45029: 27.1.50; Regression: Yanking into externally modified file with delete-selection-mode Date: Thu, 14 Sep 2023 09:39:48 +0300 Organization: LINKOV.NET Message-ID: <86zg1puupr.fsf@mail.linkov.net> References: <581f7e67-db12-ba3a-2354-de8061789861@matholka.se> <87360lnabu.fsf@gnus.org> <83a6uscwv2.fsf@gnu.org> <87eek4gl3p.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2126"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 45029@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 14 09:01:32 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qggLz-0000Ox-UF for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Sep 2023 09:01:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qggLS-0006We-ET; Thu, 14 Sep 2023 03:00:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qggLR-0006TH-63 for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 03:00:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qggLQ-0003QZ-Sk for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 03:00:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qggLW-0006QB-HR for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 03:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Sep 2023 07:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45029 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed confirmed Original-Received: via spool by 45029-submit@debbugs.gnu.org id=B45029.169467484424632 (code B ref 45029); Thu, 14 Sep 2023 07:01:02 +0000 Original-Received: (at 45029) by debbugs.gnu.org; 14 Sep 2023 07:00:44 +0000 Original-Received: from localhost ([127.0.0.1]:36653 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qggLD-0006PE-NG for submit@debbugs.gnu.org; Thu, 14 Sep 2023 03:00:44 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:48499) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qggL8-0006Op-NX for 45029@debbugs.gnu.org; Thu, 14 Sep 2023 03:00:41 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 1328CC000D; Thu, 14 Sep 2023 07:00:24 +0000 (UTC) In-Reply-To: (Stefan Monnier via's message of "Wed, 13 Sep 2023 13:59:55 -0400") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270400 Archived-At: >> Here is a brief trace that explains the cause of the problem: >> >> 1. C-y (yank) calls delete-selection-pre-hook from pre-command-hook >> 2. delete-selection-helper calls delete-active-region >> 3. this activates ask-user-about-supersession-threat on a modified file >> 4. it calls read-char-from-minibuffer ('this-command' is still 'yank') >> 5. read-char-from-minibuffer waits when user types 'y' >> (bound to the command 'read-char-from-minibuffer-insert-char') >> 6. after typing 'y', read-char-from-minibuffer returns 'y', but >> now 'this-command' is 'read-char-from-minibuffer-insert-char' >> 7. when delete-selection-pre-hook finishes, due to 'this-command' >> 'read-char-from-minibuffer-insert-char' is called again, >> and this time operates on the buffer as if it's the minibuffer > > Yuck! > And thanks for the investigation. > >> Anyway, here is a patch with two fixes: >> 1. Guards read-char-from-minibuffer-insert-char against inadvertent >> operating on the non-minibuffer buffer; > > I suspect this will/would just hide a problem (such as the current one) > under the rug. I admit this is a workaround, but I have no idea what would be a proper fix. >> 2. Prevents read-char-from-minibuffer from changing the value of >> 'this-command' by read-from-minibuffer: > > Right, but I think that this needs to apply to all recursive edits > rather than only `read-char-from-minibuffer`. I tried to test recursive commands at the read-char-from-minibuffer's prompt, but can't reproduce the same problem.