diff --git a/doc/changes/added/12696.md b/doc/changes/added/12696.md new file mode 100644 index 00000000000..aa8c3112b7c --- /dev/null +++ b/doc/changes/added/12696.md @@ -0,0 +1,2 @@ +- Add `dune-find-dominating` to `dune.el`, a command to find the + dominating dune file. (#12696, @arvidj) diff --git a/editor-integration/emacs/dune.el b/editor-integration/emacs/dune.el index 56ad762db93..354dceeb4be 100644 --- a/editor-integration/emacs/dune.el +++ b/editor-integration/emacs/dune.el @@ -426,6 +426,17 @@ For customization purposes, use `dune-mode-hook'." (compile (format "%s build @@runtest" dune-command)) (dune-promote)) +;;;###autoload +(defun dune-find-dominating () + "Find dominating dune file." + (interactive) + (if-let* ((dune-file-dir (locate-dominating-file "." "dune")) + (dune-file (concat dune-file-dir "dune"))) + (progn + (xref-push-marker-stack) + (find-file dune-file)) + (error "Found no dune file dominating %s" default-directory))) + (defun dune-project-p (directory) "Return t if DIRECTORY is a dune project." (file-exists-p (expand-file-name "dune-project" directory)))