diff options
| author | Yutian Li <hotpxless@gmail.com> | 2016-07-16 01:53:01 +0800 |
|---|---|---|
| committer | Yutian Li <hotpxless@gmail.com> | 2016-07-16 01:53:01 +0800 |
| commit | 68863001d75f103f6ffb5d0cc834ed63b7380c6d (patch) | |
| tree | 6b0c834b822634818859bb901639e6e73d45de4a | |
| parent | 0cf2bc30ec29ad215242b617748c9fa1aa91c407 (diff) | |
| download | rust-mode-68863001d75f103f6ffb5d0cc834ed63b7380c6d.tar.gz | |
[master] Copy buffer only when format changes.
| -rw-r--r-- | rust-mode.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/rust-mode.el b/rust-mode.el index 16aaa6d..26cce7e 100644 --- a/rust-mode.el +++ b/rust-mode.el @@ -1258,8 +1258,10 @@ This is written mainly to be used as `end-of-defun-function' for Rust." (erase-buffer) (insert-buffer-substring buf) (if (zerop (call-process-region (point-min) (point-max) rust-rustfmt-bin t t nil)) - (progn (copy-to-buffer buf (point-min) (point-max)) - (kill-buffer)) + (progn + (if (not (string= (buffer-string) (with-current-buffer buf (buffer-string)))) + (progn (copy-to-buffer buf (point-min) (point-max)))) + (kill-buffer)) (error "Rustfmt failed, see *rustfmt* buffer for details")))) (defun rust-format-buffer () |
