From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#45029: 27.1.50; Regression: Yanking into externally modified file with delete-selection-mode Date: Wed, 13 Sep 2023 13:59:55 -0400 Message-ID: References: <581f7e67-db12-ba3a-2354-de8061789861@matholka.se> <87360lnabu.fsf@gnus.org> <83a6uscwv2.fsf@gnu.org> <87eek4gl3p.fsf@mail.linkov.net> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9853"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 45029@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 13 20:02:22 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 1qgUBx-0002Jk-0Y for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Sep 2023 20:02:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgUBd-0004ZB-HS; Wed, 13 Sep 2023 14:02:01 -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 1qgUBY-0004On-Rb for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 14:01:58 -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 1qgUBY-0007Mo-K0 for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 14:01:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgUBd-0003ex-TN for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 14:02:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Sep 2023 18:02:01 +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.169462807914018 (code B ref 45029); Wed, 13 Sep 2023 18:02:01 +0000 Original-Received: (at 45029) by debbugs.gnu.org; 13 Sep 2023 18:01:19 +0000 Original-Received: from localhost ([127.0.0.1]:35981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgUAx-0003dz-3h for submit@debbugs.gnu.org; Wed, 13 Sep 2023 14:01:19 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:36234) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgUAv-0003dm-7F for 45029@debbugs.gnu.org; Wed, 13 Sep 2023 14:01:17 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 82669441EB8; Wed, 13 Sep 2023 14:01:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1694628065; bh=DnE5mxWlchj/5dPicxcuitVpCuG4SJMwxyawd0cEYFI=; h=From:To:Subject:In-Reply-To:References:Date:From; b=RoFBUV+OizxNi0rYT5883AyJZvi45fQM3ZZMObVxQwOiZDBAfJhmiyHSltutGlmC4 NFkVRt+JCZ9xo/dhDIoxvMeMBXB7zoc9XXcf6lUAk+CX7z55G2E9WSq2l1vWkLMUYl CO0cs/R+kVb2AO4MmwyILaL0HmrBJGwtgN5SSA2pklguMMMpN1YohhBmMwDmb6v7RR 2MqzzjdpOhWHjzaQjPiKTR+oy1o25w1lIJFIKsiBIFZET78MV7UGoQ1eXqfnQvAEu5 67btJG9TEO3SmdOXQSeLFiODVcoQsbiD8DZuOCF2frlqKU0SSE0IsEx4zluzuHk+vO 37UxSgg6kxwLg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 23CDF441EA7; Wed, 13 Sep 2023 14:01:05 -0400 (EDT) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 184321202E6; Wed, 13 Sep 2023 14:01:05 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Wed, 13 Sep 2023 13:36:54 -0400") 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:270343 Archived-At: Stefan Monnier [2023-09-13 13:36:54] wrote: > 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. > 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`. Stefan