                  outputfile)
                (ocamlformat--apply-rcs-patch patchbuf)
                (message "Applied ocamlformat"))
-             (message "Could not apply ocamlformat")
              (if errbuf
                (progn
                  (with-current-buffer errbuf
                    (setq buffer-read-only nil)
                    (erase-buffer))
                  (ocamlformat--process-errors
-                   (buffer-file-name) bufferfile errorfile errbuf))))))
+                   (buffer-file-name) bufferfile errorfile errbuf)))
+             (message "Could not apply ocamlformat"))))
      (kill-buffer patchbuf)
      (delete-file errorfile)
      (delete-file bufferfile)

files and will overwrite ocamlformat's echo output if used from inside
a `before-save-hook'."
    :type '(choice
            (const :tag "Own buffer" buffer)
            (const :tag "Echo area" echo)
            (const :tag "None" nil))
      :group 'ocamlformat)

(defun ocamlformat--process-errors (filename tmpfile errorfile errbuf)
  (with-current-buffer errbuf
    (if (eq ocamlformat-show-errors 'echo)
      (message "%s" (buffer-string))
      (insert-file-contents errorfile nil nil nil)
      ;; Convert the ocamlformat stderr to something understood by the compilation mode.
      (goto-char (point-min))
