diff --git a/CHANGELOG.md b/CHANGELOG.md index da1a6d9d..3006d136 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * [#443](https://github.com/clojure-emacs/clojure-mode/issues/443): Fix behavior of `clojure-forward-logical-sexp` and `clojure-backward-logical-sexp` with conditional macros. * [#429](https://github.com/clojure-emacs/clojure-mode/issues/429): Fix a bug causing last occurrence of expression sometimes is not replaced when using `move-to-let`. * [#423](https://github.com/clojure-emacs/clojure-mode/issues/423): Make `clojure-match-next-def` more robust against zero-arity def-like forms. +* [#451](https://github.com/clojure-emacs/clojure-mode/issues/451): Make project root directory calculation customized by `clojure-project-root-function` ### New features diff --git a/clojure-mode.el b/clojure-mode.el index 8ed7f5f9..11a4ab66 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -192,6 +192,12 @@ Out-of-the box `clojure-mode' understands lein, boot and gradle." (and (listp value) (cl-every 'stringp value)))) +(defcustom clojure-project-root-function #'clojure-project-root-path + "Function to locate clojure project root directory." + :type 'function + :risky t + :package-version '(clojure-mode . "5.7.0")) + (defcustom clojure-refactor-map-prefix (kbd "C-c C-r") "Clojure refactor keymap prefix." :type 'string @@ -1600,6 +1606,13 @@ nil." (defun clojure-project-dir (&optional dir-name) "Return the absolute path to the project's root directory. +Call is delegated down to `clojure-project-root-function' with +optional DIR-NAME as argument." + (funcall clojure-project-root-function dir-name)) + +(defun clojure-project-root-path (&optional dir-name) + "Return the absolute path to the project's root directory. + Use `default-directory' if DIR-NAME is nil. Return nil if not inside a project." (let* ((dir-name (or dir-name default-directory))