]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't access overriding-text-conversion-style when unbound
authorPo Lu <luangruo@yahoo.com>
Tue, 18 Feb 2025 12:58:32 +0000 (20:58 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 21:33:01 +0000 (22:33 +0100)
* lisp/replace.el (perform-replace): Don't access
overriding-text-conversion-style when unbound, and also avoid
needlessly polluting this symbol with a binding.  (bug#76371)

(cherry picked from commit 0cf3823463e9a52a6fbdc5e02555381cd6e0f5b5)

lisp/replace.el

index 1ae1881ce988512fe2daca69c74ae5f2819dc0cc..9b24ea432d4488648bf86b8e5258c4dbf28bea96 100644 (file)
@@ -2877,7 +2877,8 @@ characters."
          (region-filter nil)
 
          ;; Disable text conversion during the replacement operation.
-         (old-text-conversion-style overriding-text-conversion-style)
+         (old-text-conversion-style (and (boundp 'overriding-text-conversion-style)
+                                         overriding-text-conversion-style))
          overriding-text-conversion-style
 
          ;; Data for the next match.  If a cons, it has the same format as
@@ -2937,10 +2938,9 @@ characters."
 
     (push-mark)
     (undo-boundary)
-    (when query-flag
+    (when (and query-flag (fboundp 'set-text-conversion-style))
       (setq overriding-text-conversion-style nil)
-      (when (fboundp 'set-text-conversion-style)
-        (set-text-conversion-style text-conversion-style)))
+      (set-text-conversion-style text-conversion-style))
     (unwind-protect
        ;; Loop finding occurrences that perhaps should be replaced.
        (while (and keep-going
@@ -3358,12 +3358,11 @@ characters."
       (replace-dehighlight)
       (when region-filter
         (remove-function isearch-filter-predicate region-filter))
-      (when query-flag
+      (when (and query-flag (fboundp 'set-text-conversion-style))
         ;; Resume text conversion.
         (setq overriding-text-conversion-style
               old-text-conversion-style)
-        (when (fboundp 'set-text-conversion-style)
-          (set-text-conversion-style text-conversion-style))))
+        (set-text-conversion-style text-conversion-style)))
     (or unread-command-events
        (message (ngettext "Replaced %d occurrence%s"
                           "Replaced %d occurrences%s"