diff options
| author | Sergey Vinokurov <serg.foo@gmail.com> | 2021-06-28 19:39:21 +0100 |
|---|---|---|
| committer | brotzeit <brotzeitmacher@gmail.com> | 2021-10-16 20:21:36 +0200 |
| commit | 80cdc5417c3f6a6faf85f0d78c6d606c9aa39cb0 (patch) | |
| tree | e749f504fdf94c90e124561331b3e1ae9fb56a95 /rust-rustfmt.el | |
| parent | d0c1ffa68d0ba0af0b35b761d2d73a2c1b4fc7a3 (diff) | |
| download | rust-mode-80cdc5417c3f6a6faf85f0d78c6d606c9aa39cb0.tar.gz | |
Improve rust--format-fix-rustfmt-buffer
Diffstat (limited to 'rust-rustfmt.el')
| -rw-r--r-- | rust-rustfmt.el | 14 |
1 files 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 |
