Merge pull request #4842 from rgrinberg/fix-ocamlformat

ocamlforamt hook: buffers without a file name
This commit is contained in:
Henrik Lissner 2021-04-13 19:15:59 -04:00 committed by GitHub
commit 876bdb523c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,9 +111,10 @@
(setq +format-with 'ocp-indent)
(when (and (executable-find "ocamlformat")
(locate-dominating-file default-directory ".ocamlformat"))
(let ((ext (file-name-extension buffer-file-name t)))
(cond ((equal ext ".eliom")
(setq-local ocamlformat-file-kind 'implementation))
((equal ext ".eliomi")
(setq-local ocamlformat-file-kind 'interface))))
(when buffer-file-name
(let ((ext (file-name-extension buffer-file-name t)))
(cond ((equal ext ".eliom")
(setq-local ocamlformat-file-kind 'implementation))
((equal ext ".eliomi")
(setq-local ocamlformat-file-kind 'interface)))))
(setq +format-with 'ocamlformat))))