File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1456,6 +1456,27 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
1456
1456
(forward-char columns)))
1457
1457
(min (point ) max-pos)))))
1458
1458
1459
+ (defun rust-format-diff-buffer ()
1460
+ " Show diff to current buffer from rustfmt."
1461
+ (interactive )
1462
+ (unless (executable-find rust-rustfmt-bin)
1463
+ (error " Could not locate executable \% s\" " rust-rustfmt-bin))
1464
+ (make-process
1465
+ :name " rustfmt-diff"
1466
+ :command (list rust-rustfmt-bin " --check" (buffer-file-name ))
1467
+ :buffer
1468
+ (with-current-buffer
1469
+ (get-buffer-create " *rustfmt-diff*" )
1470
+ (erase-buffer )
1471
+ (current-buffer ))
1472
+ :sentinel 'rust-format-diff-buffer-sentinel ))
1473
+
1474
+ (defun rust-format-diff-buffer-sentinel (process e )
1475
+ (when (eq 'exit (process-status process))
1476
+ (if (> (process-exit-status process) 0 )
1477
+ (display-buffer " *rustfmt-diff*" )
1478
+ (message " rustfmt check passed. " ))))
1479
+
1459
1480
(defun rust-format-buffer ()
1460
1481
" Format the current buffer using rustfmt."
1461
1482
(interactive )
You can’t perform that action at this time.
0 commit comments