diff --git a/modules/lang/ocaml/config.el b/modules/lang/ocaml/config.el index 60c19ade3..696aa9822 100644 --- a/modules/lang/ocaml/config.el +++ b/modules/lang/ocaml/config.el @@ -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))))