-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
[Fix #451] respect project root dir suggested by custom function #452
Conversation
clojure-mode.el
Outdated
(when (> (length choices) 0) | ||
(car (sort choices #'file-in-directory-p))))) | ||
(or (and (fboundp clojure-project-root-locating-function) | ||
(condition-case err |
There was a problem hiding this comment.
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
clojure-mode.el
Outdated
@@ -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 | |||
"Alternative function to locate clojure project root directory, eg. projectile-project-root" | |||
:type 'symbol |
There was a problem hiding this comment.
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
clojure-mode.el
Outdated
(defcustom clojure-project-root-locating-function nil | ||
"Alternative function to locate clojure project root directory, eg. projectile-project-root" | ||
:type 'symbol | ||
:safe 'symbolp) |
There was a problem hiding this comment.
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.
clojure-mode.el
Outdated
@@ -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 |
There was a problem hiding this comment.
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
.
clojure-mode.el
Outdated
@@ -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 | |||
"Alternative function to locate clojure project root directory, eg. projectile-project-root" |
There was a problem hiding this comment.
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.
clojure-mode.el
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
clojure-mode.el
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
Shouldn't this be using |
In theory - yes. In practice this is more or less a prototype that wasn't really polished. I was actually discussing this with its author just a couple of days ago. He wanted us to collaborate on providing more extension points for Projectile, but frankly I don't really see much point in working towards this universal API given the fact I'm not really interested in using it and apart from a few generic functions each project management library has way too many specifics to it. On the other side - this could allow a lot of modes to drop at least the product root detection code they cart along. |
Type changed to function and marked as risky.
@bbatsov I applied your suggestions but to get rid of unnecessary fallbacks and set |
Why did you split it in two? I don't see any reason to do, even after taking a look at the code. |
This was to set |
Ah, yeah - the name you have to the old function confused me a bit. This looks ok overall. |
clojure-mode.el
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the ' to a #'
Besides that last comment, it looks good to me. |
It still needs a changelog entry. |
clojure-project-root-function defaults to #'clojure-project-root-path now.
Changelog updated. |
…ectory customizable (clojure-emacs#452)
It would allow e.g. |
This is a humble attempt to get clojure-mode respecting project root directory suggested by a custom function (like projectile-project-root), as described in #451