Function: neocaml--resolve-build-path
neocaml--resolve-build-path is a natively compiled function defined in
neocaml.el.
Signature
(neocaml--resolve-build-path FILE)
Documentation
Resolve FILE out of a _build directory, if applicable.
For dune-style paths like _build/default/lib/foo.ml, strip
_build/<context>/ and return <project-root>/lib/foo.ml.
For ocamlbuild-style _build/lib/foo.ml, strip _build/ only.
Return nil if FILE is not under _build or the resolved file
does not exist.
Source Code
;; Defined in /nix/store/ahssdx4rwzyxhyhavpn0bkznk13xrggi-emacs-packages-deps/share/emacs/site-lisp/elpa/neocaml-20260907.2015/neocaml.el
;;;; _build directory awareness
(defun neocaml--resolve-build-path (file)
"Resolve FILE out of a `_build' directory, if applicable.
For dune-style paths like `_build/default/lib/foo.ml', strip
`_build/<context>/' and return `<project-root>/lib/foo.ml'.
For ocamlbuild-style `_build/lib/foo.ml', strip `_build/' only.
Return nil if FILE is not under `_build' or the resolved file
does not exist."
(when-let* ((pos (string-search "/_build/" file))
(root (substring file 0 pos))
(rest (substring file (+ pos 8))) ;; skip "/_build/"
(components (split-string rest "/" t)))
(let* (;; Dune: skip first component (context dir like "default")
(dune-path (when (cdr components)
(concat root "/" (string-join (cdr components) "/"))))
;; Ocamlbuild: keep everything after _build/
(ocamlbuild-path (concat root "/" rest)))
(cond
((and dune-path (file-readable-p dune-path)) dune-path)
((file-readable-p ocamlbuild-path) ocamlbuild-path)))))