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

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

bug#45617: <query-replace> loses the edit region. Works in 23.3, broke i


From: Bob Floyd
Subject: bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3
Date: Fri, 15 Jan 2021 10:09:46 -0800

PS: The 1st patch has the same wrong behavior also!

-----Original Message-----
From: Juri Linkov [mailto:juri@linkov.net] 
Sent: Wednesday, January 13, 2021 10:54 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617@debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3

> Perhaps another way to think about this is that emacs is "mode-less".
>
> I can begin a command, recurse into another, pop out and resume the first
> command.
>
> Without the patch, or minibuffer fix, <query-replace> breaks that design.

So here is a simpler patch that fixes all query-replace commands:

diff --git a/lisp/replace.el b/lisp/replace.el
index d41dc98a0d..16b80a8fd1 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -327,6 +336,7 @@ query-replace-read-to
 (defun query-replace-read-args (prompt regexp-flag &optional noerror)
   (unless noerror
     (barf-if-buffer-read-only))
+  (save-mark-and-excursion
   (let* ((from (query-replace-read-from prompt regexp-flag))
         (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
               (query-replace-read-to from prompt regexp-flag))))
@@ -334,7 +344,7 @@ query-replace-read-args
          (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
               (and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
                    (get-text-property 0 'isearch-regexp-function from)))
-         (and current-prefix-arg (eq current-prefix-arg '-)))))
+         (and current-prefix-arg (eq current-prefix-arg '-))))))
 
 (defun query-replace (from-string to-string &optional delimited start end
backward region-noncontiguous-p)
   "Replace some occurrences of FROM-STRING with TO-STRING.






reply via email to

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