emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#31073: closed (27.0.50; query-replace undo might c


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#31073: closed (27.0.50; query-replace undo might change the word case)
Date: Mon, 09 Apr 2018 02:56:02 +0000

Your message dated Mon, 09 Apr 2018 11:55:00 +0900
with message-id <address@hidden>
and subject line Re: bug#31073: 27.0.50; query-replace undo might change the 
word case
has caused the debbugs.gnu.org bug report #31073,
regarding 27.0.50; query-replace undo might change the word case
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
31073: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31073
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 27.0.50; query-replace undo might change the word case Date: Fri, 06 Apr 2018 14:02:31 +0900
X-Debbugs-CC: Juri Linkov <address@hidden>

The undo feature shouldn't change the case; it must return
to the original words.

emacs -Q
<
M-% t RET FOO RET SPC SPC SPC SPC U
;; The first line shows upcase 'T' at several positions, for instance
;; it shows 'TexT', originally shown as 'text'.


--8<-----------------------------cut here---------------start------------->8---
commit 6fcb746c4efcbc2afce6a520f4a8b67a8d40cdd1
Author: Tino Calancha <address@hidden>
Date:   Fri Apr 6 13:40:06 2018 +0900

    Preserve case in query-replace undo
    
    If the user query and replaces 'foo' with 'BAR', then
    undo must comeback to 'foo', not to 'FOO'.
    * lisp/replace.el (perform-replace): Bind nocasify to non-nil
    value during undo/undo-all actions.
    * test/lisp/replace-tests.el (query-replace-undo-bug31073): Add test.

diff --git a/lisp/replace.el b/lisp/replace.el
index c28c9b36f0..a147c8dd86 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2619,6 +2619,7 @@ perform-replace
                           (let ((stack-idx         0)
                                  (stack-len         (length stack))
                                  (num-replacements  0)
+                                 (nocasify t) ; Bug#31073.
                                  search-string
                                  next-replacement)
                              (while (and (< stack-idx stack-len)
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index 66c6842660..d6043e297c 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -380,4 +380,24 @@ replace-tests--query-replace-undo
   (should (string= "211" (replace-tests--query-replace-undo)))
   (should (string= "211" (replace-tests--query-replace-undo 'comma))))
 
+(ert-deftest query-replace-undo-bug31073 ()
+  "Test for https://debbugs.gnu.org/31073 ."
+  (let ((text "The teeth must be cleaned after every meal.")
+        (count 0))
+    (with-temp-buffer
+      (insert text)
+      (goto-char 1)
+      (cl-letf (((symbol-function 'read-event)
+                 (lambda (&rest args)
+                   (cl-incf count)
+                   (let ((val (pcase count
+                                ('4 ?U) ; undo-all
+                                ('5 ?q) ; exit
+                                (_ ?\s)))) ; replace current and go next
+                     val))))
+        (perform-replace "t" "FOO" t nil nil))
+      ;; After undo text must be the same.
+      (should (string= text (buffer-string))))))
+
+
 ;;; replace-tests.el ends here
--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 27.0.50 (build 25, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2018-04-03 built on calancha-pc
Repository revision: 10ef466a9eb621a3752de69930fcb14bf1af4887



--- End Message ---
--- Begin Message --- Subject: Re: bug#31073: 27.0.50; query-replace undo might change the word case Date: Mon, 09 Apr 2018 11:55:00 +0900 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
Eli Zaretskii <address@hidden> writes:

>> The patch is pretty obvious: just 1 line:
>
> Thanks.  This is indeed OK for the emacs-26 branch, but please wait
> with pushing this until Emacs 26.1 is released, hopefully soon enough.
>
> Alternatively, feel free to push to master and cherry-pick to emacs-26
> later, after the 26.1 release.
Pushed fix into master branch as commit
"Preserve case in query-replace undo"
(32dc0cb1b5ae895d237c7118ccaeb084715934fd).

I will backport the fix to emacs-26 after 26.1 release.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]