Skip to content

Commit

Permalink
emacs: Remove temp files in the event of an error
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetiot committed Mar 2, 2022
1 parent 7022aee commit 61ffb3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
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

#### New features
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

0 comments on commit 61ffb3d

Please sign in to comment.