@@ -1440,9 +1440,11 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
1440
1440
(point )))
1441
1441
1442
1442
; ; Formatting using rustfmt
1443
+ (defconst rust-rustfmt-buffername " *rustfmt*" )
1444
+
1443
1445
(defun rust--format-call (buf )
1444
1446
" Format BUF using rustfmt."
1445
- (with-current-buffer (get-buffer-create " * rustfmt* " )
1447
+ (with-current-buffer (get-buffer-create rust- rustfmt-buffername )
1446
1448
(erase-buffer )
1447
1449
(insert-buffer-substring buf)
1448
1450
(let* ((tmpf (make-temp-file " rustfmt" ))
@@ -1479,7 +1481,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
1479
1481
; ; Since we run rustfmt through stdin we get <stdin> markers in the
1480
1482
; ; output. This replaces them with the buffer name instead.
1481
1483
(defun rust--format-fix-rustfmt-buffer (buffer-name )
1482
- (with-current-buffer (get-buffer " * rustfmt* " )
1484
+ (with-current-buffer (get-buffer rust- rustfmt-buffername )
1483
1485
(goto-char (point-min ))
1484
1486
(while (re-search-forward " --> <stdin>:" )
1485
1487
(replace-match (format " --> %s : " buffer-name)))))
@@ -1490,7 +1492,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
1490
1492
(defun rust--format-error-handler ()
1491
1493
(let ((ok nil ))
1492
1494
(when rust-format-show-buffer
1493
- (display-buffer (get-buffer " * rustfmt* " ))
1495
+ (display-buffer (get-buffer rust- rustfmt-buffername ))
1494
1496
(setq ok t ))
1495
1497
(when rust-format-goto-problem
1496
1498
(rust-goto-format-problem)
@@ -1506,7 +1508,7 @@ rustfmt complain in the echo area."
1506
1508
; ; This uses position in *rustfmt* buffer to know which is the next
1507
1509
; ; error to jump to, and source: line in the buffer to figure which
1508
1510
; ; buffer it is from.
1509
- (let ((rustfmt (get-buffer " * rustfmt* " )))
1511
+ (let ((rustfmt (get-buffer rust- rustfmt-buffername )))
1510
1512
(if (not rustfmt)
1511
1513
(message " No *rustfmt*, no problems. " )
1512
1514
(let ((target-buffer (with-current-buffer rustfmt
@@ -1817,7 +1819,7 @@ Return the created process."
1817
1819
(when rust-format-on-save
1818
1820
(if (not (executable-find rust-rustfmt-bin))
1819
1821
(error " Could not locate executable \" %s \" " rust-rustfmt-bin)
1820
- (when (get-buffer " * rustfmt* " )
1822
+ (when (get-buffer rust- rustfmt-buffername )
1821
1823
; ; KLDUGE: re-run the error handlers -- otherwise message area
1822
1824
; ; would show "Wrote ..." instead of the error description.
1823
1825
(or (rust--format-error-handler)
0 commit comments