]> git.eshelyaron.com Git - sweep.git/commitdiff
Avoid using 'string-replace' for Emacs 27 compatibility
authorEshel Yaron <me@eshelyaron.com>
Thu, 1 Jun 2023 15:46:23 +0000 (18:46 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 1 Jun 2023 15:46:23 +0000 (18:46 +0300)
* sweeprolog.el (sweeprolog-top-level-example-done): Refactor and use
'replace-regexp-in-string' instead of 'string-replace'.

sweeprolog.el

index 8b57c8bde15fd87032806723f78dd54e53bc5588..95110517665f58c22f6641651546f1a349d1279c 100644 (file)
@@ -6502,12 +6502,11 @@ as a comment in the source location where you invoked
     (unless (buffer-live-p source-buffer)
       (user-error "Source buffer for this example session no longer alive"))
     (let ((top-level-buffer (current-buffer))
-          (example (replace-regexp-in-string
-                    (rx "?- " eos) ""
-                    (string-replace
-                     "\n\n" "\n"
-                     (buffer-substring-no-properties (point-min)
-                                                     (point-max)))))
+          (example
+           (thread-last (buffer-string)
+                        (substring-no-properties)
+                        (replace-regexp-in-string "\n\n" "\n")
+                        (replace-regexp-in-string (rx "\n?- " eos) "")))
           (marker sweeprolog-top-level-example-marker))
       (pop-to-buffer source-buffer)
       (unless (string-empty-p example)