Skip to content

Commit 367a89c

Browse files
author
Christian Howe
committed
Allow formatting with long lines
1 parent dae5af7 commit 367a89c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

rust-mode.el

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,12 +1195,13 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
11951195
(with-current-buffer (get-buffer-create "*rustfmt*")
11961196
(erase-buffer)
11971197
(insert-buffer-substring buf)
1198-
(if (zerop (call-process-region (point-min) (point-max) rust-rustfmt-bin t t nil))
1199-
(progn
1200-
(if (not (string= (buffer-string) (with-current-buffer buf (buffer-string))))
1201-
(copy-to-buffer buf (point-min) (point-max)))
1202-
(kill-buffer))
1203-
(error "Rustfmt failed, see *rustfmt* buffer for details"))))
1198+
(let ((ret (call-process-region (point-min) (point-max) rust-rustfmt-bin t '(t nil) nil)))
1199+
(if (or (zerop ret) (= ret 3))
1200+
(progn
1201+
(if (not (string= (buffer-string) (with-current-buffer buf (buffer-string))))
1202+
(copy-to-buffer buf (point-min) (point-max)))
1203+
(kill-buffer))
1204+
(error "Rustfmt failed, see *rustfmt* buffer for details")))))
12041205

12051206
(defconst rust--format-word "\\b\\(else\\|enum\\|fn\\|for\\|if\\|let\\|loop\\|match\\|struct\\|unsafe\\|while\\)\\b")
12061207
(defconst rust--format-line "\\([\n]\\)")

0 commit comments

Comments
 (0)