Function: dune-root
dune-root is a natively compiled function defined in dune.el.
Signature
(dune-root &optional DIRECTORY)
Documentation
Return the root directory of the dune project of DIRECTORY.
DIRECTORY defaults to default-directory if not provided.
Source Code
;; Defined in /nix/store/ai4i12v8z13z6l9irpjcha90driqcxbb-emacs-packages-deps/share/emacs/site-lisp/elpa/dune-20260803.1048/dune.el
(defun dune-root (&optional directory)
"Return the root directory of the dune project of DIRECTORY.
DIRECTORY defaults to `default-directory' if not provided."
(let*
(root
workspace
(dir (or directory default-directory))
(project-p (lambda (dir)
(cond
((dune-workspace-p dir)
(setq workspace t)
t)
((and
(not workspace)
(dune-project-p dir))
t)))))
(while dir
(setq dir (locate-dominating-file dir project-p))
(when dir
(setq root dir
dir (file-name-parent-directory dir))))
root))