emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/anzu 8930374775 176/288: Fix case if s-expression cannot b


From: ELPA Syncer
Subject: [nongnu] elpa/anzu 8930374775 176/288: Fix case if s-expression cannot be compiled.
Date: Thu, 6 Jan 2022 03:58:50 -0500 (EST)

branch: elpa/anzu
commit 8930374775f27dc5ff500a429cca10b0eba37400
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>

    Fix case if s-expression cannot be compiled.
---
 anzu.el | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/anzu.el b/anzu.el
index 08d6e0801b..ef061a71bb 100644
--- a/anzu.el
+++ b/anzu.el
@@ -438,7 +438,8 @@
       from)))
 
 (defun anzu--compile-replace-text (str)
-  (let ((compiled (query-replace-compile-replacement str t)))
+  (let ((compiled (ignore-errors
+                    (query-replace-compile-replacement str t))))
     (cond ((stringp compiled) compiled)
           ((and (consp compiled) (functionp (car compiled)))
            compiled)
@@ -448,17 +449,19 @@
 (defun anzu--evaluate-occurrence (ov to-regexp replacements fixed-case 
from-regexp)
   (let ((from-string (overlay-get ov 'from-string))
         (compiled (anzu--compile-replace-text to-regexp)))
-    (with-temp-buffer
-      (insert from-string)
-      (goto-char (point-min))
-      (when (re-search-forward from-regexp nil t)
-        (or (ignore-errors
-              (if (consp compiled)
-                  (replace-match (funcall (car compiled) (cdr compiled)
-                                          replacements) fixed-case)
-                (replace-match compiled fixed-case))
-              (buffer-substring (point-min) (point-max)))
-            "")))))
+    (if (not compiled)
+        ""
+      (with-temp-buffer
+        (insert from-string)
+        (goto-char (point-min))
+        (when (re-search-forward from-regexp nil t)
+          (or (ignore-errors
+                (if (consp compiled)
+                    (replace-match (funcall (car compiled) (cdr compiled)
+                                            replacements) fixed-case)
+                  (replace-match compiled fixed-case))
+                (buffer-substring (point-min) (point-max)))
+              ""))))))
 
 (defun anzu--overlay-sort (a b)
   (< (overlay-start a) (overlay-start b)))



reply via email to

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