diff options
| author | Tom Tromey <tom@tromey.com> | 2017-06-06 05:57:42 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-06 05:57:42 -0600 |
| commit | ac6a45e6091c0d542b696b6e13551be7e333264a (patch) | |
| tree | 8bc2d51bb68714aab565c1606553ca42c9be119f | |
| parent | 77248135153a6c15cfc35ff9d5db550a5b1a8197 (diff) | |
| parent | d71fe94d51840a3a43b51b983d903fc1a14d7193 (diff) | |
| download | rust-mode-ac6a45e6091c0d542b696b6e13551be7e333264a.tar.gz | |
Merge pull request #213 from KeenS/restore-points
restore points even when an error occurs
| -rw-r--r-- | rust-mode.el | 27 |
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.")) |
