summaryrefslogtreecommitdiff
path: root/rust-mode.el
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2016-08-02 22:29:40 -0400
committerWilfred Hughes <me@wilfred.me.uk>2016-08-02 22:29:40 -0400
commite452995b8ccd388f4be13a11443cffe3cdcd0619 (patch)
tree0ce35c985d9fcd6b64d9271e76b893a1fe55f934 /rust-mode.el
parentba5ff9058546df593ff7d8737fb52b5e92ad1913 (diff)
downloadrust-mode-e452995b8ccd388f4be13a11443cffe3cdcd0619.tar.gz
rust--after-revert-hook should preserve point position.
Otherwise, rust-format-buffer always moves point to the end of the buffer.
Diffstat (limited to 'rust-mode.el')
-rw-r--r--rust-mode.el7
1 files changed, 4 insertions, 3 deletions
diff --git a/rust-mode.el b/rust-mode.el
index 6259b48..1fbc3e8 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1365,9 +1365,10 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
;; to use `font-lock-ensure', which doesn't exist in Emacs 24 and earlier.
;; If it's not available, fall back to calling `font-lock-fontify-region'
;; on the whole buffer.
- (if (fboundp 'font-lock-ensure)
- (font-lock-ensure)
- (font-lock-fontify-region (point-min) (point-max))))
+ (save-excursion
+ (if (fboundp 'font-lock-ensure)
+ (font-lock-ensure)
+ (font-lock-fontify-region (point-min) (point-max)))))
(defun rust--before-save-hook ()
(when rust-format-on-save (rust-format-buffer)))