mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
ocamlforamt hook: buffers without a file name
The behavior before this PR would cause an error if a buffer not backed by a file was opened. This can be trivially reproduced by opening a merge/rebase conflict using ediff inside an .ml file. Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
This commit is contained in:
@ -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))))
|
||||
|
Reference in New Issue
Block a user