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: Fri, 15 Sep 2023 09:17:14 -0400 Message-ID: References: <581f7e67-db12-ba3a-2354-de8061789861@matholka.se> <87360lnabu.fsf@gnus.org> <83a6uscwv2.fsf@gnu.org> <87eek4gl3p.fsf@mail.linkov.net> <86zg1puupr.fsf@mail.linkov.net> <868r986k8n.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="33026"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 45029@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 15 15:18: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 1qh8iD-0008L3-JQ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Sep 2023 15:18:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qh8hw-0006IQ-0Y; Fri, 15 Sep 2023 09:18:04 -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 1qh8hp-0006HP-EH for bug-gnu-emacs@gnu.org; Fri, 15 Sep 2023 09:18:01 -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 1qh8ho-0005vp-78 for bug-gnu-emacs@gnu.org; Fri, 15 Sep 2023 09:17:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qh8hu-00084x-AV for bug-gnu-emacs@gnu.org; Fri, 15 Sep 2023 09:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Sep 2023 13:18: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.169478385231016 (code B ref 45029); Fri, 15 Sep 2023 13:18:02 +0000 Original-Received: (at 45029) by debbugs.gnu.org; 15 Sep 2023 13:17:32 +0000 Original-Received: from localhost ([127.0.0.1]:42428 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qh8hQ-00084C-BT for submit@debbugs.gnu.org; Fri, 15 Sep 2023 09:17:32 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qh8hO-00083z-J1 for 45029@debbugs.gnu.org; Fri, 15 Sep 2023 09:17:31 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3E5144422BA; Fri, 15 Sep 2023 09:17:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1694783836; bh=XVqmSzLCCJLbiBxHuyUm5YF6GupU77GpL6ksAhb2boU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=JtKdsXBwy2lcaI99HrdKKuD0fzf0VRWXK+wVtw+U8OlhKM7N+w+6+dEMjwWjWVDYE BFe4oLsy9XKlpnS7NlzzKG3AUIjC/Ez0hixw39p0vuR64kDV0NyuYeVp+jo1WTYKAQ dOexOIrj4gsxAyyh6b7KtfOMsOA7oL8LWTuiFhZ2ZzW8yNZq5hjR2uhRPYC7CXNnRV 0DotBY4jdSGO2fNm5vcDWmrt0/hrIhcAM9CCXVnVGf5+0byumyYxdrNeLovve5yjTW eaEjqfOucDdg5EZ14k2xJDws+qb6yxEjJnW5nrAHfmEU0NcxnANdLuzMtIa1/OPGZG r2PieDPRz2FKA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 913AA44010C; Fri, 15 Sep 2023 09:17:16 -0400 (EDT) Original-Received: from pastel (unknown [104.247.237.102]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 710BA12027A; Fri, 15 Sep 2023 09:17:16 -0400 (EDT) In-Reply-To: <868r986k8n.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 15 Sep 2023 09:36:12 +0300") 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:270539 Archived-At: >> The let-binding of `this-command` fixes the problem, doesn't it? > But might other uses of a recursive edit break it again? What do you mean by `it`? There's only one recursive edit associated with `read-char-from-minibuffer-insert-char`, so no definitely not that (unless the user binds (or somehow uses) that command in keymaps used in other recursive edits, of course). And AFAICT, the bug see is that `delete-selection-mode` ends up running a command (originally run inside a recursive edit) a second time. IOW it's not "recursive edit broke `read-char-from-minibuffer-insert-char`" but "recursive edit broke `delete-selection-mode`". This can/will cause problems with loads of commands, not just `read-char-from-minibuffer-insert-char`. So yes, other uses of recursive edits can break `delete-selection-mode` as well, but no amount of changing `read-char-from-minibuffer-insert-char` will hide the problem because those other uses will use other commands. OTOH, the let-binding of `this-command` should fix the problem once and for all uses of recursive edit *if* it's placed deep enough that it affects all recursive edits. > I guess `when (minibufferp)` can't be removed from > `read-char-from-minibuffer-insert-other` until all cases below > are fixed. I don't see the "cases below" you're referring to. > I see, so this problem is more general and not specific to > `read-char-from-minibuffer`? Exactly. Any recursive edit happening from the `pre-command-hook`. > It would be nice to find a test case for other commands to confirm > that a change in `recursive_edit_1` fixes them. Even without trying to reproduce the specific problem that caused this bug report, think of this scenario: - User causes COMMAND to be run. - `this-command` is thus set to COMMAND. - We run the `pre-command-hook`. - One of the functions on `pre-command-hook` use a recursive edit. - `this-command` is now set to whichever command was run last in the recursive edit, which is just plain wrong. I remember seeing places in the code where we try and circumvent this problem, but this bug report makes it clear what is the real source of the problem. Stefan