Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emacs: Remove temp files in the event of an error #2003

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#### Bug fixes

+ emacs: Remove temp files in the event of an error (#2003, @gpetiot)

#### Changes

+ Qtest comments are not re-formatted (#2034, @gpetiot)
Expand Down
23 changes: 12 additions & 11 deletions emacs/ocamlformat.el
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ is nil."
(erase-buffer))
(ocamlformat--process-errors
(buffer-file-name) bufferfile errorfile errbuf)))
(message "Could not apply ocamlformat on %s" buffer-file-name))))
(delete-file errorfile)
(delete-file bufferfile)
(delete-file outputfile)))
(message "Could not apply ocamlformat on %s" buffer-file-name)))
(delete-file errorfile)
(delete-file bufferfile)
(delete-file outputfile))))

(defun ocamlformat-args (name start-line end-line)
(let*
Expand Down Expand Up @@ -356,13 +356,14 @@ is nil."
(buffer-file-name) bufferfile errorfile errbuf)))
(message "Could not apply ocamlformat")))))
(indents (mapcar 'string-to-number (split-string indents-str))))
(save-excursion
(goto-char start)
(mapcar
#'(lambda (indent) (indent-line-to indent) (forward-line))
indents))
(delete-file errorfile)
(delete-file bufferfile)))
(unwind-protect
(save-excursion
(goto-char start)
(mapcar
#'(lambda (indent) (indent-line-to indent) (forward-line))
indents))
(delete-file errorfile)
(delete-file bufferfile))))

(defun ocamlformat-line ()
(interactive nil)
Expand Down