GNU bug report logs - #18412
24.3.93 regression: undo boundary inserted by delete-selection-mode (CUA)

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: David Reitter <david.reitter@HIDDEN>; dated Fri, 5 Sep 2014 16:38:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 18412 <at> debbugs.gnu.org:


Received: (at 18412) by debbugs.gnu.org; 8 Sep 2014 02:04:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 07 22:04:38 2014
Received: from localhost ([127.0.0.1]:33079 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1XQoJq-0008Pr-2T
	for submit <at> debbugs.gnu.org; Sun, 07 Sep 2014 22:04:38 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.181]:3292)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1XQoJo-0008Pb-14
 for 18412 <at> debbugs.gnu.org; Sun, 07 Sep 2014 22:04:36 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AhAIAIDvNVNFpZEG/2dsb2JhbABZgwaDSghKvF2DDoEXF3SCJQEBAQECAQwXMyMFCwkCGgIYDgICFBgNJIgECJMDnBiifheBKY0eMweCb4FJBKkZgWqBcYFbIQ
X-IPAS-Result: AhAIAIDvNVNFpZEG/2dsb2JhbABZgwaDSghKvF2DDoEXF3SCJQEBAQECAQwXMyMFCwkCGgIYDgICFBgNJIgECJMDnBiifheBKY0eMweCb4FJBKkZgWqBcYFbIQ
X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="89046904"
Received: from 69-165-145-6.dsl.teksavvy.com (HELO ceviche.home)
 ([69.165.145.6])
 by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA;
 07 Sep 2014 22:04:29 -0400
Received: by ceviche.home (Postfix, from userid 20848)
 id C98D4660C4; Sun,  7 Sep 2014 22:04:29 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: David Reitter <david.reitter@HIDDEN>
Subject: Re: bug#18412: 24.3.93 regression: undo boundary inserted by
 delete-selection-mode (CUA)
Message-ID: <jwvwq9ekhep.fsf-monnier+emacsbugs@HIDDEN>
References: <DD830153-3AE7-4539-8935-1975B856DE03@HIDDEN>
Date: Sun, 07 Sep 2014 22:04:29 -0400
In-Reply-To: <DD830153-3AE7-4539-8935-1975B856DE03@HIDDEN> (David Reitter's
 message of "Fri, 5 Sep 2014 12:37:06 -0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 18412
Cc: 18412 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

> This is a regression in the 24.4 pretest compared to 24.3.
> M-x cua-mode
> (enter and) select a word =E2=80=9Chello", e.g., via double-click
> enter single char, e.g., =E2=80=9Cx=E2=80=9D
> C-_   (undo)
> In Emacs 24.3, the undo will restore =E2=80=9Chello=E2=80=9D.
> In Emacs 24.3.93 pretest, the undo will only delete =E2=80=9Cx=E2=80=9D, =
but not
> restore =E2=80=9Chello=E2=80=9D.
> An undo boundary is present in buffer-undo-list between the
>  delete-selection step and the insertion of =E2=80=9Cx=E2=80=9D.

Indeed, that's a difference between delete-selection-mode and cua's
earlier reimplementation of the feature.

To the extent that noone complained about it for delete-selection-mode,
I think this bug is not super-urgent to fix.  IOW, we should take the
time to think how to fix it right.

> Looking at how self-insert-command deletes the undo boundary to merge
> itself, we can either prevent the undo boundary from being inserted (I
> couldn=E2=80=99t figure out where that happens), or pretend that the
> delete-selection action was a self-insert-command.  The patch below is
> a proof of concept.

The undo-boundary is added by command_loop_1 in keyboard.c just before
calling command_execute.  Maybe the right fix is to change it so it's
push before running pre-command-hook?

Of course, maybe an even better fix is to change delete-selection-mode
so it doesn't rely on pre-command-hook.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#18412; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 5 Sep 2014 16:37:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 05 12:37:33 2014
Received: from localhost ([127.0.0.1]:60011 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1XPwVw-0002CE-Ol
	for submit <at> debbugs.gnu.org; Fri, 05 Sep 2014 12:37:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50884)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <david.reitter@HIDDEN>) id 1XPwVu-0002C0-Fe
 for submit <at> debbugs.gnu.org; Fri, 05 Sep 2014 12:37:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <david.reitter@HIDDEN>) id 1XPwVj-0005ya-SS
 for submit <at> debbugs.gnu.org; Fri, 05 Sep 2014 12:37:25 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:34590)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <david.reitter@HIDDEN>) id 1XPwVj-0005yU-PK
 for submit <at> debbugs.gnu.org; Fri, 05 Sep 2014 12:37:19 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52598)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <david.reitter@HIDDEN>) id 1XPwVe-0002xE-8j
 for bug-gnu-emacs@HIDDEN; Fri, 05 Sep 2014 12:37:19 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <david.reitter@HIDDEN>) id 1XPwVY-0005wQ-MT
 for bug-gnu-emacs@HIDDEN; Fri, 05 Sep 2014 12:37:14 -0400
Received: from mail-qc0-x22a.google.com ([2607:f8b0:400d:c01::22a]:46572)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <david.reitter@HIDDEN>) id 1XPwVY-0005wC-I2
 for bug-gnu-emacs@HIDDEN; Fri, 05 Sep 2014 12:37:08 -0400
Received: by mail-qc0-f170.google.com with SMTP id r5so12858847qcx.1
 for <bug-gnu-emacs@HIDDEN>; Fri, 05 Sep 2014 09:37:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=from:content-type:content-transfer-encoding:subject:message-id:date
 :to:mime-version;
 bh=M0fCyQZAjJmkGpBJj9GNkMrMru4uFPserSrW8xgzOgM=;
 b=MY8uc0yGAhWy/JFSBly6/nHbe5zMV6zUXKyGt5lZ0r3VQjpyDVKygsv0HDHYGRIYuk
 lTpcGUESQkv9NktS2mGbfiB8gozzc5efvVeXDSTZePB6MZ7D9Mqylhp8Omih3dZ8xvBY
 dEa9inJpMWrqGPaEXUAybdiUc/5F81Zv3Q/yts3eVgx8eMCJkAt26OWU+hnx+81C59nD
 +MhOwaN1Mzc83stTYaOjuAXaJGZ5tuu9kiKNICBC1XNzZZLX2TUSnuJeq5ojqLVxzVTl
 C0iJz080z0EUEWK89p5LYNshb/xZ3vMbk3PWziyOOLFsZha5i3QlPHYc5NdsIkYy5VfA
 cAnA==
X-Received: by 10.224.88.3 with SMTP id y3mr20267459qal.65.1409935027349;
 Fri, 05 Sep 2014 09:37:07 -0700 (PDT)
Received: from [130.203.154.138] ([130.203.154.138])
 by mx.google.com with ESMTPSA id w8sm1211099qag.2.2014.09.05.09.37.06
 for <bug-gnu-emacs@HIDDEN>
 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
 Fri, 05 Sep 2014 09:37:06 -0700 (PDT)
From: David Reitter <david.reitter@HIDDEN>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable
Subject: 24.3.93 regression: undo boundary inserted by delete-selection-mode
 (CUA)
Message-Id: <DD830153-3AE7-4539-8935-1975B856DE03@HIDDEN>
Date: Fri, 5 Sep 2014 12:37:06 -0400
To: Bug-Gnu-Emacs <bug-gnu-emacs@HIDDEN>
Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\))
X-Mailer: Apple Mail (2.1878.6)
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

This is a regression in the 24.4 pretest compared to 24.3.

M-x cua-mode
(enter and) select a word =93hello", e.g., via double-click
enter single char, e.g., =93x=94
C-_   (undo)



In Emacs 24.3, the undo will restore =93hello=94.

In Emacs 24.3.93 pretest, the undo will only delete =93x=94, but not =
restore =93hello=94.
An undo boundary is present in buffer-undo-list between the =
delete-selection step and the insertion of =93x=94.


The relevant change, I think, were changes to CUA on Dec 8 and 11, 2013:

commit f38bbfce43b11667ee1a09acf4f4f932bf7c9043
Author: Stefan Monnier <monnier@HIDDEN>
Date:   Sun Dec 8 01:24:54 2013 -0500

    Use delete-selection-mode in cya-mode.


As a fix...

Looking at how self-insert-command deletes the undo boundary to merge =
itself, we can either prevent the undo boundary from being inserted (I =
couldn=92t figure out where that happens), or pretend that the =
delete-selection action was a self-insert-command.  The patch below is a =
proof of concept.

I think the right fix would be not to insert the undo boundary in the =
first place, if this is reasonably doable.





commit abf13771ad1b3dbc542a35393230eb43baa55d1c
Author: David Reitter <david.reitter@HIDDEN>
Date:   Fri Sep 5 12:26:11 2014 -0400

    delsel: delete-active-region: avoid undo boundary
   =20
    Set last-command so that self-insert-command removes any
    undo boundary.



diff --git a/lisp/delsel.el b/lisp/delsel.el
index 1ada027..c1b1eba 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -80,6 +80,8 @@ If KILLP in not-nil, the active region is killed =
instead of deleted."
       (let (this-command)
 	(kill-region (point) (mark) t))
     (funcall region-extract-function 'delete-only))
+  ;; do not add undo-boundary in self-insert-command:
+  (setq last-command this-command)
   t)
=20
 (defun delete-selection-helper (type)





Acknowledgement sent to David Reitter <david.reitter@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#18412; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.