From 3bf68a6568baa4a930918c308a7888b122ccf294 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Fri, 7 Nov 2025 10:58:29 +0100 Subject: [PATCH] [emacs] add [dune-find-dominating] command Signed-off-by: Arvid Jakobsson --- doc/changes/added/12696.md | 2 ++ editor-integration/emacs/dune.el | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 doc/changes/added/12696.md 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)))