branch: elpa/rust-mode
commit 80cdc5417c3f6a6faf85f0d78c6d606c9aa39cb0
Author: Sergey Vinokurov <serg....@gmail.com>
Commit: brotzeit <brotzeitmac...@gmail.com>

    Improve rust--format-fix-rustfmt-buffer
---
 rust-rustfmt.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/rust-rustfmt.el b/rust-rustfmt.el
index d3b7509..33f916d 100644
--- a/rust-rustfmt.el
+++ b/rust-rustfmt.el
@@ -86,13 +86,13 @@
 ;; Since we run rustfmt through stdin we get <stdin> markers in the
 ;; output. This replaces them with the buffer name instead.
 (defun rust--format-fix-rustfmt-buffer (buffer-name)
-  (with-current-buffer (get-buffer rust-rustfmt-buffername)
-    (let ((inhibit-read-only t))
-      (goto-char (point-min))
-      (while (re-search-forward "--> <stdin>:" nil t)
-        (replace-match (format "--> %s:" buffer-name)))
-      (while (re-search-forward "--> stdin:" nil t)
-        (replace-match (format "--> %s:" buffer-name))))))
+  (save-match-data
+    (with-current-buffer (get-buffer rust-rustfmt-buffername)
+      (let ((inhibit-read-only t)
+            (fixed (format "--> %s:" buffer-name)))
+          (goto-char (point-min))
+          (while (re-search-forward "--> \\(?:<stdin>\\|stdin\\):" nil t)
+            (replace-match fixed))))))
 
 ;; If rust-mode has been configured to navigate to source of the error
 ;; or display it, do so -- and return true. Otherwise return nil to

Reply via email to