emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rust-mode ad674a1d43: save excursion when formatting


From: ELPA Syncer
Subject: [nongnu] elpa/rust-mode ad674a1d43: save excursion when formatting
Date: Fri, 7 Jan 2022 05:58:49 -0500 (EST)

branch: elpa/rust-mode
commit ad674a1d43a7ffefd3dba33599c6aa5f49d70e43
Author: brotzeit <brotzeitmacher@gmail.com>
Commit: brotzeit <brotzeitmacher@gmail.com>

    save excursion when formatting
    
    close #392
---
 rust-rustfmt.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/rust-rustfmt.el b/rust-rustfmt.el
index 0690b84bc5..530abaa165 100644
--- a/rust-rustfmt.el
+++ b/rust-rustfmt.el
@@ -331,9 +331,11 @@ Return the created process."
   ;; If emacs version >= 26.2, we can use replace-buffer-contents to
   ;; preserve location and markers in buffer, otherwise we can try to
   ;; save locations as best we can, though we still lose markers.
-  (if (version<= "26.2" emacs-version)
-      (rust--format-buffer-using-replace-buffer-contents)
-    (rust--format-buffer-saving-position-manually)))
+  (save-excursion
+    (save-window-excursion
+      (if (version<= "26.2" emacs-version)
+          (rust--format-buffer-using-replace-buffer-contents)
+        (rust--format-buffer-saving-position-manually)))))
 
 (defun rust-enable-format-on-save ()
   "Enable formatting using rustfmt when saving buffer."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]