Skip to content

Commit 8665005

Browse files
committed
Introduce constant for *rustfmt*.
1 parent a36c96a commit 8665005

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

rust-mode.el

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,9 +1440,11 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
14401440
(point)))
14411441

14421442
;; Formatting using rustfmt
1443+
(defconst rust-rustfmt-buffername "*rustfmt*")
1444+
14431445
(defun rust--format-call (buf)
14441446
"Format BUF using rustfmt."
1445-
(with-current-buffer (get-buffer-create "*rustfmt*")
1447+
(with-current-buffer (get-buffer-create rust-rustfmt-buffername)
14461448
(erase-buffer)
14471449
(insert-buffer-substring buf)
14481450
(let* ((tmpf (make-temp-file "rustfmt"))
@@ -1479,7 +1481,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
14791481
;; Since we run rustfmt through stdin we get <stdin> markers in the
14801482
;; output. This replaces them with the buffer name instead.
14811483
(defun rust--format-fix-rustfmt-buffer (buffer-name)
1482-
(with-current-buffer (get-buffer "*rustfmt*")
1484+
(with-current-buffer (get-buffer rust-rustfmt-buffername)
14831485
(goto-char (point-min))
14841486
(while (re-search-forward "--> <stdin>:")
14851487
(replace-match (format "--> %s:" buffer-name)))))
@@ -1490,7 +1492,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
14901492
(defun rust--format-error-handler ()
14911493
(let ((ok nil))
14921494
(when rust-format-show-buffer
1493-
(display-buffer (get-buffer "*rustfmt*"))
1495+
(display-buffer (get-buffer rust-rustfmt-buffername))
14941496
(setq ok t))
14951497
(when rust-format-goto-problem
14961498
(rust-goto-format-problem)
@@ -1506,7 +1508,7 @@ rustfmt complain in the echo area."
15061508
;; This uses position in *rustfmt* buffer to know which is the next
15071509
;; error to jump to, and source: line in the buffer to figure which
15081510
;; buffer it is from.
1509-
(let ((rustfmt (get-buffer "*rustfmt*")))
1511+
(let ((rustfmt (get-buffer rust-rustfmt-buffername)))
15101512
(if (not rustfmt)
15111513
(message "No *rustfmt*, no problems.")
15121514
(let ((target-buffer (with-current-buffer rustfmt
@@ -1817,7 +1819,7 @@ Return the created process."
18171819
(when rust-format-on-save
18181820
(if (not (executable-find rust-rustfmt-bin))
18191821
(error "Could not locate executable \"%s\"" rust-rustfmt-bin)
1820-
(when (get-buffer "*rustfmt*")
1822+
(when (get-buffer rust-rustfmt-buffername)
18211823
;; KLDUGE: re-run the error handlers -- otherwise message area
18221824
;; would show "Wrote ..." instead of the error description.
18231825
(or (rust--format-error-handler)

0 commit comments

Comments
 (0)