From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#39680: 27.0.60; electric-pair-mode broken by undo Date: Wed, 11 Mar 2020 11:31:45 -0400 Message-ID: References: <87pneaifya.fsf@gmail.com> <20200225193451.GA5896@ACM> <87o8t4vhbh.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="29603"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Alan Mackenzie , 39680@debbugs.gnu.org To: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 11 16:32:16 2020 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 1jC3LD-0007Z1-PI for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Mar 2020 16:32:15 +0100 Original-Received: from localhost ([::1]:54258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jC3LC-0000zY-OX for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Mar 2020 11:32:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58006) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jC3L1-0000wT-3l for bug-gnu-emacs@gnu.org; Wed, 11 Mar 2020 11:32:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jC3L0-00064t-0c for bug-gnu-emacs@gnu.org; Wed, 11 Mar 2020 11:32:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49388) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jC3Kz-000642-QB for bug-gnu-emacs@gnu.org; Wed, 11 Mar 2020 11:32:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jC3Kz-00026g-NM for bug-gnu-emacs@gnu.org; Wed, 11 Mar 2020 11:32: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, 11 Mar 2020 15:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39680 X-GNU-PR-Package: emacs Original-Received: via spool by 39680-submit@debbugs.gnu.org id=B39680.15839407188089 (code B ref 39680); Wed, 11 Mar 2020 15:32:01 +0000 Original-Received: (at 39680) by debbugs.gnu.org; 11 Mar 2020 15:31:58 +0000 Original-Received: from localhost ([127.0.0.1]:55361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jC3Kv-00026P-Tu for submit@debbugs.gnu.org; Wed, 11 Mar 2020 11:31:58 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27335) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jC3Kt-000261-Te for 39680@debbugs.gnu.org; Wed, 11 Mar 2020 11:31:56 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4F24E80513; Wed, 11 Mar 2020 11:31:50 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 37ED8810B2; Wed, 11 Mar 2020 11:31:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1583940708; bh=Mfm7azjqy+E5iRpfACFg8aGEBX093lrlxwabYBKnWLY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=gpnSDadOx0oQfmRVdgCSg6ZiMzpq6J4H4rhMZ18e9ZxmRoA/KdhfSLVzMd2Ly07Zp Ky3CyH7VVfxCZlqVOpwsf+d8o9gp14kt1bPbCzmT1124+4J+I73hQDQu5mX/3LTHQd TaMBr1miXII4zzj4I8wV//SVl9ndT+KHXaeTLUVi69+KTauIy7Qx1/PsPo+Y6CoXP9 YiJqMyttQYHQ+DWyZBdccaqeb2lSrQ/SsjeAO4iAxxDbkd9LYBH47u8D6vVeNSMz9e Bi8DSMrFa9EfkBGczRAg52aHaeXPO9aijBkjcy+51ZJCdrlQaBAH8e2bX+JXjAPW/d ODh2wtL+zP27A== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1F6D212066A; Wed, 11 Mar 2020 11:31:48 -0400 (EDT) In-Reply-To: <87o8t4vhbh.fsf@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Tue, 10 Mar 2020 07:45:38 +0100") 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: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:177180 Archived-At: >> I think we need something like the patch below (not really tested yet). >> WDYT? > > FWIW, I applied it and AFAICT I can't reproduce the issue. Thanks. I think the patch wasn't quite right and was overly complicated: `undo` is already responsible for dealing with the freshness of `pending-undo-list`. So I think the better patch is the one below. Eli, is the patch below OK for `emacs-27`? Stefan [ BTW, I accidentally installed the previous patch on `master`, and I'm waiting for "the right solution" to clean up. ] diff --git a/lisp/subr.el b/lisp/subr.el index 5b94343e499..4c69c9dd044 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2964,13 +2964,18 @@ cancel-change-group ;; the body of `atomic-change-group' all changes can be undone. (widen) (let ((old-car (car-safe elt)) - (old-cdr (cdr-safe elt))) + (old-cdr (cdr-safe elt)) + ;; Use `pending-undo-list' temporarily since `undo-more' needs + ;; it, but restore it afterwards so as not to mess with an + ;; ongoing sequence of `undo's. + (pending-undo-list + ;; Use `buffer-undo-list' unconditionally (bug#39680). + buffer-undo-list)) (unwind-protect (progn ;; Temporarily truncate the undo log at ELT. (when (consp elt) (setcar elt nil) (setcdr elt nil)) - (unless (eq last-command 'undo) (undo-start)) ;; Make sure there's no confusion. (when (and (consp elt) (not (eq elt (last pending-undo-list)))) (error "Undoing to some unrelated state"))