Skip to content

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

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

Merged
merged 6 commits into from
Oct 8, 2017
Merged
Changes from 2 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
13 changes: 11 additions & 2 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ Out-of-the box `clojure-mode' understands lein, boot and gradle."
(and (listp value)
(cl-every 'stringp value))))

(defcustom clojure-project-root-locating-function nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd name this just clojure-project-root-function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defcustom should also have a :package-version property pointing this was added in version 5.7.0.

"Alternative function to locate clojure project root directory, eg. projectile-project-root"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why alternative - let's just set it by default to the currently existing function.

:type 'symbol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a type: 'function

:safe 'symbolp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is funcalled, so no value is safe for it. In fact, we should probably mark it as risky.


(defcustom clojure-refactor-map-prefix (kbd "C-c C-r")
"Clojure refactor keymap prefix."
:type 'string
Expand Down Expand Up @@ -1607,8 +1612,12 @@ Return nil if not inside a project."
(mapcar (lambda (fname)
(locate-dominating-file dir-name fname))
clojure-build-tool-files))))
(when (> (length choices) 0)
(car (sort choices #'file-in-directory-p)))))
(or (and (fboundp clojure-project-root-locating-function)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd simply remove those check here - if the user set something explicitly we can assume they know what they are doing. Fallbacks are pointless and confusing here.

(condition-case err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just ignore-errors

(funcall clojure-project-root-locating-function)
(error nil)))
(when (> (length choices) 0)
(car (sort choices #'file-in-directory-p))))))

(defun clojure-project-relative-path (path)
"Denormalize PATH by making it relative to the project root."
Expand Down