 
 ;;; Code:
 
+(require 'seq)
+(require 'subr-x)
+
 (defun coqdev-default-directory ()
   "Return the Coq repository containing `default-directory'."
-  (let ((dir (locate-dominating-file default-directory "coq-core.opam")))
+  (let ((dir (seq-some
+              (lambda (f) (locate-dominating-file default-directory f))
+              '("META.coq" "META.coq.in" "META.coq-core.in" "coqpp"))))
     (when dir (expand-file-name dir))))
 
 (defun coqdev-setup-compile-command ()
   "Setup `compile-command' for Coq development."
   (let ((dir (coqdev-default-directory)))
-    ;; we add a space at the end to make it easy to add arguments (eg -j or target)
-    (when dir (setq-local compile-command (concat "make -C " (shell-quote-argument dir) " ")))))
+    (when dir (setq-local compile-command (concat "cd " (shell-quote-argument dir) "
+dune build @check # coq-core.install dev/shim/coqtop-prelude")))))
 (add-hook 'hack-local-variables-hook #'coqdev-setup-compile-command)
 
 (defvar camldebug-command-name) ; from camldebug.el (caml package)

  (let ((dir (coqdev-default-directory)))
    (when dir
      (setq-local bug-reference-bug-regexp "#\\(?2:[0-9]+\\)")
      (setq-local bug-reference-url-format "https://github.com/coq/coq/issues/%s"))))
(add-hook 'hack-local-variables-hook #'coqdev-setup-bug-reference-mode)

(defun coqdev-sphinx-quote-coq-refman-region (left right &optional offset beg end)

      (setq-local coq-prog-name (concat dir "_build/default/dev/shim/coqtop-prelude")))))
(add-hook 'hack-local-variables-hook #'coqdev-setup-proofgeneral)

(defvar coqdev-ocamldebug-command "dune exec -- dev/dune-dbg coqc /tmp/foo.v"
  "Command run by `coqdev-ocamldebug'")

(declare-function comint-check-proc "comint")
(declare-function tuareg--split-args "tuareg")
(declare-function ocamldebug-filter "ocamldebug")
(declare-function ocamldebug-sentinel "ocamldebug")
(declare-function ocamldebug-mode "ocamldebug")
(declare-function ocamldebug-set-buffer "ocamldebug")
(defun coqdev-ocamldebug ()
  "Runs a command in an ocamldebug buffer."
  (interactive)
  (require 'ocamldebug)
  (let* ((dir (read-directory-name "Run from directory: "
                                   (coqdev-default-directory)))
         (name "ocamldebug-coq")
