-
-
Notifications
You must be signed in to change notification settings - Fork 645
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 "save before refresh" functionality and use files.el
for path comparisons/operations
#2546
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cichli
commented
Dec 21, 2018
cichli
commented
Dec 21, 2018
Long time, no see! It's good to see you back! :-) |
bbatsov
reviewed
Dec 22, 2018
bbatsov
reviewed
Dec 22, 2018
bbatsov
approved these changes
Dec 22, 2018
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.
Apart from my small remarks the PR looks great to me!
@cichli ping :-) |
cichli
force-pushed
the
fix-save-on-refresh
branch
from
January 21, 2019 19:15
40960e9
to
9dab2a5
Compare
I have added a new defcustom to control for which modes the saving should happen – defaults to |
cichli
force-pushed
the
fix-save-on-refresh
branch
2 times, most recently
from
January 22, 2019 04:02
600d9d2
to
2a8d87a
Compare
bbatsov
reviewed
Jan 22, 2019
Previously this relied on `clojure-project-dir` from clojure-mode, but tools.namespace will refresh any modified files on the entire classpath, so they are worth including too. Additionally, path comparisons are now made using `file-in-directory-p` rather than `string-prefix-p`, obviating any issues around path expansion, symlinks, and platform-specific issues such as case sensitivity.
* Use `file-truename` to relax the need for the given path to be absolute * Only consider actual directories on the classpath * Use `file-in-directory-p` and `file-relative-name` rather than `string-prefix-p` and `substring`
cichli
force-pushed
the
fix-save-on-refresh
branch
from
January 22, 2019 13:42
2a8d87a
to
1896b1b
Compare
Great work! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried setting
cider-ns-save-files-on-refresh
to botht
and'prompt
but found neither had any effect. It turns out thatclojure-project-dir
returns a non-canonical path (e.g.~/clojure/...
), whereas the predicate passed tosave-some-buffers
was using(file-truename default-directory)
which does return canonical paths (e.g./Users/griffithsm/clojure/...
).I then made the further observation that
tools.namespace
actually reloads all modified Clojure files on the entire classpath - not just those inside the current project!To solve this I have modified
cider-ns-refresh--save-project-buffers
to:files.el
rather thanstring-prefix-p
. This means we get rid of the Windows-specific workaround for case-insensitivity there too.Similarly, the use of string comparisons in
cider-expected-ns
meant we had to be sure that its input was a canonical path. Again by using functions fromfiles.el
we can avoid any platform-related headaches or similar.make test
)make lint
) which is based onelisp-lint
and includescheckdoc
, check-declare, packaging metadata, indentation, and trailing whitespace checks.