Subject: bug#31073: 27.0.50; query-replace undo might change the word case

From: Tino Calancha <[email-masked]>
Date: Sun, 08 Apr 2018 11:46:15 +0900

Eli Zaretskii <[email-masked]> writes:

>> this feature was introduced for Emacs-26 release.  Should the fix go
>> into that branch (Emacs-26)?
>
> It's too late for Emacs 26.1.  For the other 26.x, I'd need to see the
> patch first.
I see.
The patch is pretty obvious: just 1 line:

--8<-----------------------------cut here---------------start------------->8---
commit a70414e82048f425cdb00e3cd30c15fcb9fbab86
Author: Tino Calancha <[email-masked]>
Date:   Fri Apr 6 14:03:55 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' (Bug#31073).
    * lisp/replace.el (perform-replace): Bind nocasify to non-nil
    value during undo/undo-all actions.

diff --git a/lisp/replace.el b/lisp/replace.el
index c28c9b36f0..2b0555d580 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)

--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 27.0.50 (build 25, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
Repository revision: 8df23a82042fa7dbaaa4377bc376d705595b073f