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

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

bug#36328: 26.2; Args out of range on search-and-replace of *.cc file


From: Juri Linkov
Subject: bug#36328: 26.2; Args out of range on search-and-replace of *.cc file
Date: Tue, 25 Jun 2019 22:58:56 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

Hello, Alan.

> My feeling is that perform-replace (or, possibly, replace-highlight) is
> the best place to put a save-match-data.

Doing this in perform-replace means adding save-match-data in all places
where replace-highlight is called, so maybe better to add it only once
in replace-highlight like Jayden proposed initially.

But then it's important to add an explanatory comment since
the need of using of save-match-data is not self-evident here.

Do you think this comment is clear enough?

diff --git a/lisp/replace.el b/lisp/replace.el
index 9d1b7bf747..50c74be8f6 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2316,7 +2316,11 @@ replace-highlight
            (isearch-forward (not backward))
            (isearch-other-end match-beg)
            (isearch-error nil))
-       (isearch-lazy-highlight-new-loop range-beg range-end))))
+       (save-match-data
+         ;; Preserve match-data for perform-replace since
+         ;; isearch-lazy-highlight-new-loop calls `sit-for' that
+         ;; does redisplay that might clobber match data (bug#36328).
+         (isearch-lazy-highlight-new-loop range-beg range-end)))))
 
 (defun replace-dehighlight ()
   (when replace-overlay
diff --git a/lisp/term/tty-colors.el b/lisp/term/tty-colors.el
index 307586f221..5af8170203 100644
--- a/lisp/term/tty-colors.el
+++ b/lisp/term/tty-colors.el
@@ -820,7 +820,7 @@ tty-color-canonicalize
   "Return COLOR in canonical form.
 A canonicalized color name is all-lower case, with any blanks removed."
   (let ((case-fold-search nil))
-    (if (string-match "[A-Z ]" color)
+    (if (string-match-p "[A-Z ]" color)
        (replace-regexp-in-string " +" "" (downcase color))
       color)))
 

reply via email to

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