unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Distinguish between regional undo and undo to the beginning in undo-equiv-table
Date: Wed, 3 Mar 2021 16:59:52 -0500	[thread overview]
Message-ID: <A371A62F-E3D8-498A-A9F9-14FFA68D229C@gmail.com> (raw)
In-Reply-To: <jwvblc0orst.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1995 bytes --]



> On Mar 3, 2021, at 4:29 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
>> This patch applies on top of the first one. I added more docstrings since
>> you seem to appreciate it.
> 
> Great!
> 
>> I couldn’t wrap my head around the original tests so I started a new
>> one below.
> 
> That's perfectly fine.
> 
> Earlier you wrote:
>> if you undo-in-region, break the undo chain, then undo-in-region again
>> with undo-only, ulist would be set to t and it breaks at (setq
>> undo-elt (car ulist)).
> 
> I don't see which of the tests corresponds to this.
> Is it this one:
> 
>> +    (should (equal (buffer-string) "abcde")))
>> +  ;; Test undo/redo in region.
>> +  (with-temp-buffer
>> +    (buffer-enable-undo)
>> +    (dolist (x '("a" "b" "c" "d" "e"))
>> +      (insert x)
>> +      (undo-boundary))
>>     (should (equal (buffer-string) "abcde"))
>> -    ))
>> +    (simple-tests--exec '(move-beginning-of-line
>> +                          push-mark-command
>> +                          forward-char
>> +                          forward-char
>> +                          undo))
>> +    (should (equal (buffer-string) "acde"))
>> +    (simple-tests--exec '(undo-only))
>> +    (should (equal (buffer-string) "cde"))
>> +    (simple-tests--exec '(undo-redo))
>> +    (should (equal (buffer-string) "acde"))
>> +    (simple-tests--exec '(undo-redo))
>> +    (should (equal (buffer-string) "abcde"))))
> 
> ?

Yes, that was supposed to be the one. Just to be sure I ran the test with the old version and it didn’t error. Oops! I fixed the test, now it errors on the old version and passes after applying my fix (in the first patch). The test first runs undo in region, then breaks the undo chain (my 2nd patch failed to do that), then runs undo in region again. I’m not sure how to write the comment for that test. Maybe I could write “test for commit xxx” but there is no commit number to refer to right now.

Yuan


[-- Attachment #2: undo-in-region-3.patch --]
[-- Type: application/octet-stream, Size: 1515 bytes --]

From 8c4df349dd2b6c214679d44712a5de99e8a04183 Mon Sep 17 00:00:00 2001
From: Yuan Fu <casouri@gmail.com>
Date: Wed, 3 Mar 2021 16:50:08 -0500
Subject: [PATCH] checkpoint

---
 test/lisp/simple-tests.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index a4816951ce..eb1c0e53e2 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -479,12 +479,21 @@ simple-tests--undo
                           forward-char
                           undo))
     (should (equal (buffer-string) "acde"))
-    (simple-tests--exec '(undo-only))
-    (should (equal (buffer-string) "cde"))
+    (simple-tests--exec '(move-beginning-of-line
+                          push-mark-command
+                          forward-char
+                          forward-char
+                          undo-only))
+    (should (equal (buffer-string) "abcde"))
     (simple-tests--exec '(undo-redo))
     (should (equal (buffer-string) "acde"))
     (simple-tests--exec '(undo-redo))
-    (should (equal (buffer-string) "abcde"))))
+    (should (equal (buffer-string) "abcde"))
+    (deactivate-mark)
+    (simple-tests--exec '(move-beginning-of-line
+                          push-mark-command
+                          forward-char
+                          undo-only))))
 
 (defun simple-tests--sans-leading-nil (lst)
   "Return LST sans the leading nils."
-- 
2.24.3 (Apple Git-128)


  reply	other threads:[~2021-03-03 21:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 20:40 Distinguish between regional undo and undo to the beginning in undo-equiv-table Yuan Fu
2021-03-02 23:50 ` Stefan Monnier
2021-03-03 15:42   ` Yuan Fu
2021-03-03 16:50     ` Stefan Monnier
2021-03-03 20:33       ` Yuan Fu
2021-03-03 21:29         ` Stefan Monnier
2021-03-03 21:59           ` Yuan Fu [this message]
2021-03-03 22:08             ` Yuan Fu
2021-03-03 22:28             ` Stefan Monnier
2021-03-04 16:18               ` Yuan Fu
2021-03-05 15:57                 ` Stefan Monnier
2021-03-06 17:28                   ` Yuan Fu
2021-03-06 18:40                     ` Stefan Monnier
2021-03-11 17:50                       ` Yuan Fu
2021-03-11 17:54                         ` Stefan Monnier
2021-03-11 21:23                           ` Yuan Fu
2021-03-11 22:41                 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A371A62F-E3D8-498A-A9F9-14FFA68D229C@gmail.com \
    --to=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).