summaryrefslogtreecommitdiff
path: root/rust-mode.el
diff options
context:
space:
mode:
authorSunrin SHIMURA (keen) <3han5chou7@gmail.com>2017-06-06 17:35:30 +0900
committerSunrin SHIMURA (keen) <3han5chou7@gmail.com>2017-06-06 17:35:30 +0900
commitd71fe94d51840a3a43b51b983d903fc1a14d7193 (patch)
tree8bc2d51bb68714aab565c1606553ca42c9be119f /rust-mode.el
parent77248135153a6c15cfc35ff9d5db550a5b1a8197 (diff)
downloadrust-mode-d71fe94d51840a3a43b51b983d903fc1a14d7193.tar.gz
restore points when an error occurs too
Diffstat (limited to 'rust-mode.el')
-rw-r--r--rust-mode.el27
1 files changed, 14 insertions, 13 deletions
diff --git a/rust-mode.el b/rust-mode.el
index 1a9d77d..cdf4edb 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1326,19 +1326,20 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
(rust--format-get-loc buffer start)
(rust--format-get-loc buffer point))
window-loc)))))
- (rust--format-call (current-buffer))
- (dolist (loc buffer-loc)
- (let* ((buffer (pop loc))
- (pos (rust--format-get-pos buffer (pop loc))))
- (with-current-buffer buffer
- (goto-char pos))))
- (dolist (loc window-loc)
- (let* ((window (pop loc))
- (buffer (window-buffer window))
- (start (rust--format-get-pos buffer (pop loc)))
- (pos (rust--format-get-pos buffer (pop loc))))
- (set-window-start window start)
- (set-window-point window pos))))
+ (unwind-protect
+ (rust--format-call (current-buffer))
+ (dolist (loc buffer-loc)
+ (let* ((buffer (pop loc))
+ (pos (rust--format-get-pos buffer (pop loc))))
+ (with-current-buffer buffer
+ (goto-char pos))))
+ (dolist (loc window-loc)
+ (let* ((window (pop loc))
+ (buffer (window-buffer window))
+ (start (rust--format-get-pos buffer (pop loc)))
+ (pos (rust--format-get-pos buffer (pop loc))))
+ (set-window-start window start)
+ (set-window-point window pos)))))
(message "Formatted buffer with rustfmt."))