Skip to content

Commit

Permalink
Try unwind-protect
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbarclay committed Apr 20, 2024
1 parent 085148f commit 429ec3d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions parinfer-rust-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,15 @@ parinfer."
;; buffer we get stuck in a loop of trying to undo things and parinfer redoing them
(defun parinfer-rust--track-undo (orig-func &rest args)
"Wraps ORIG-FUNC and ARGS in some state tracking for `parinfer-rust-mode'."
(condition-case-unless-debug err
(apply orig-func args)
(unwind-protect
(apply orig-func args)
;; We want to "Ignore" errors here otherwise the function exits
;; and causes the following commands, where we set flags, to be
;; ignored
;; FIXME: IIUC maybe you simply want to use `unwind-protect' instead.
(error
(message "%s" (cadr err))
nil))
;; Always ignore the first post-command-hook run of parinfer after an undo
(setq-local parinfer-rust--ignore-post-command-hook t)
(parinfer-rust--set-default-state))
(progn
;; Always ignore the first post-command-hook run of parinfer after an undo
(setq-local parinfer-rust--ignore-post-command-hook t)
(parinfer-rust--set-default-state))))

(defun parinfer-rust--execute-change-buffer-p (mode)
"Return non-nil if running `parinfer-rust--execute' with MODE would change the current buffer."
Expand Down

0 comments on commit 429ec3d

Please sign in to comment.