           (bufferfile (make-temp-file "ocamlformat" nil ext))
           (outputfile (make-temp-file "ocamlformat" nil ext))
           (errorfile (make-temp-file "ocamlformat" nil ext))
-          (errbuf (if ocamlformat-show-errors (get-buffer-create "*compilation*")))
+          (errbuf
+            (cond
+              ((eq ocamlformat-show-errors 'buffer)
+                (get-buffer-create "*compilation*"))
+              ((eq ocamlformat-show-errors 'echo)
+                (get-buffer-create "*OCamlFormat stderr*"))))
           (patchbuf (get-buffer-create "*OCamlFormat patch*"))
           (coding-system-for-read 'utf-8)
           (coding-system-for-write 'utf-8)

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)

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