                        "--name" buffer-file-name
                        "--output" outputfile bufferfile))))
              (progn
-               (call-process-region
-                 (point-min) (point-max) "diff" nil patchbuf nil "-n" "-"
-                 outputfile)
-               (ocamlformat--apply-rcs-patch patchbuf)
+               (if ocamlformat--support-replace-buffer-contents
+		   (replace-buffer-contents (find-file-noselect outputfile))
+		 (ocamlformat--patch-buffer outputfile))
                (message "Applied ocamlformat"))
              (if errbuf
                (progn

        (erase-buffer))
      (kill-buffer errbuf))))

(defun ocamlformat ()
   "Format the current buffer according to the ocamlformat tool."
   (interactive)

         (save-restriction
           (widen)
           (write-region nil nil bufferfile)
           (if (zerop
                 (apply 'call-process
                   ocamlformat-command nil (list :file errorfile) nil
