Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #451] respect project root dir suggested by custom function #452

Merged
merged 6 commits into from
Oct 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down