From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#21523: 25.0.50; Undo with active region adds extra text Date: Thu, 05 May 2022 16:37:45 +0200 Message-ID: <87y1zgniyu.fsf@gnus.org> References: <48592862-1630-4c61-aeed-1e3b720824de@default> <87czqdd0ng.fsf@gnus.org> <83eeat8rd5.fsf@gnu.org> <874kbpa424.fsf@gnus.org> <831r6t8i8i.fsf@gnu.org> <878s0ydglj.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24760"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 21523@debbugs.gnu.org, Barry O'Reilly , drew.adams@oracle.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 05 16:38:15 2022 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 1nmccP-0006Cv-IO for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 May 2022 16:38:14 +0200 Original-Received: from localhost ([::1]:45208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmccO-0004PF-0m for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 May 2022 10:38:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmccF-0004P5-0H for bug-gnu-emacs@gnu.org; Thu, 05 May 2022 10:38:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nmccE-0008E5-O6 for bug-gnu-emacs@gnu.org; Thu, 05 May 2022 10:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nmccE-0004W8-Fv for bug-gnu-emacs@gnu.org; Thu, 05 May 2022 10:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 May 2022 14:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21523 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 21523-submit@debbugs.gnu.org id=B21523.165176148017355 (code B ref 21523); Thu, 05 May 2022 14:38:02 +0000 Original-Received: (at 21523) by debbugs.gnu.org; 5 May 2022 14:38:00 +0000 Original-Received: from localhost ([127.0.0.1]:46160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmccB-0004Vr-QW for submit@debbugs.gnu.org; Thu, 05 May 2022 10:38:00 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:54464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmccA-0004Vf-Do for 21523@debbugs.gnu.org; Thu, 05 May 2022 10:37:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5Lk+87FWBOccqOZOXTn+Imt6ILbvqB64ASknWLDKZNg=; b=kTPU1xesaEtVD5RsTmMTCotrlc 9YU5LcyjyVl6/YMHMPZcse1rJt9liM5qi00gfbscx8/PP0hYH1jUcmN2Bej7nEerYCwa66mXukJ71 o/bxaDebUdmR7wsM3l1zTTBY84XZ5OOQ+/Dz2PY8ZOkiFTT8m6YVs7san+SZPNFCP9xg=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nmcbz-000391-EX; Thu, 05 May 2022 16:37:49 +0200 X-Now-Playing: Aural Exciters's _Mutant Disco Vol 4_: "Marathon Runner" In-Reply-To: <878s0ydglj.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 18 Aug 2021 15:31:36 +0200") 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" Xref: news.gmane.io gmane.emacs.bugs:231437 Archived-At: Lars Ingebrigtsen writes: > Actually, the problem seems to be in undo-adjust-elt, which was > rewritten in 2014 to fix bug#17235. > > I've now added a test case (commented out), but I don't quite understand > the logic in undo-adjust-elt... anybody see something obviously wrong? (defun undo-adjust-elt (elt deltas) [...] ;; (TEXT . POSITION) (`(,(and text (pred stringp)) . ,(and pos (pred integerp))) (cons text (* (if (< pos 0) -1 1) (undo-adjust-pos (abs pos) deltas)))) The problem seems to be here. In my test case, this make the ("This" . 1) entry into a ("This" . 5) entry, which is then included in the region. Using < instead if <= works for this particular test case, but not for undo-test-region-eob. I've added Barry to the CCs; perhaps he has some insights here. For reference, this is the test case: (ert-deftest test-undo-region () (with-temp-buffer (insert "This is a test\n") (goto-char (point-min)) (setq buffer-undo-list nil) (downcase-word 1) (should (= (length (delq nil (undo-make-selective-list 1 9))) 2)) ;; FIXME: These should give 0, but currently give 1. ;;(should (= (length (delq nil (undo-make-selective-list 4 9))) 0)) ;;(should (= (length (delq nil (undo-make-selective-list 5 9))) 0)) (should (= (length (delq nil (undo-make-selective-list 6 9))) 0)))) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no