-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Improvements for REPL output pre-processing and locref navigation #2083
Conversation
daa6f65
to
498e90c
Compare
cider-repl.el
Outdated
(or (cider-sync-request:ns-path var) | ||
(nrepl-dict-get (cider-sync-request:info var) "file")) | ||
(plist-get loc :file)))) | ||
(file (or (when var |
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.
Who does this improve the code? Seems exactly the same to me.
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 difference is that now :file
metadata is picked up when first two resolutions fail (those within or). This happens when a var is a protocol method. This was also the original intention btw.
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.
Ah, I see your point now - var
might be present, but its branch might return nil
. Add some comments as it's somewhat hard to follow the what the assumptions here otherwise.
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.
Yes, I used "var" loosely to refer to the variable at point, which need not correspond to clojure's var. Will add a couple of notes.
cider-repl.el
Outdated
@@ -561,7 +561,7 @@ When there is a possible unfinished ansi control sequence, | |||
(buffer-local-value 'cider-repl--ns-forms-plist connection) | |||
ns))))) | |||
|
|||
(defvar cider-repl--root-ns-highlight-template "\\<\\(%s\\)[^$/: \t\n]+" | |||
(defvar cider-repl--root-ns-highlight-template "\\<\\(%s\\)[^$/: \t\n()]+" |
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.
What's the purpose of this change?
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.
Improve original regexp. Currently things like ns1.foo.bar(file.clj:123) are highlighted all the way to 123. This change stops them at (.
Originally I thought all those reference have $ in their name, but that's not always the case.
cider-repl.el
Outdated
@@ -1051,7 +1051,7 @@ regexes from `cider-locref-regexp-alist' to infer locations at point." | |||
(nrepl-dict-get (cider-sync-request:info var) "file"))) | |||
(plist-get loc :file)))) | |||
(if file | |||
(cider--jump-to-loc-from-info (nrepl-dict "file" file "line" line)) | |||
(cider--jump-to-loc-from-info (nrepl-dict "file" file "line" line) t) |
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 it's subjective whether this is better or worse - in such cases I always add a defcustom.
P.S. Mind the commit message style. 😃
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.
It's not subjective. These pseudo links now behave like links in cider stacktrace buffer. Also like links in every other buffer which has a bunch of links in it (occur, grep, compilation etc) behave like that. It's common to click on multiple error references till you get what you want.
Mind the commit message style. 😃
What do you mean more concretely?
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.
What do you mean more concretely?
Follow this guide.
When clicked on locref in REPL, jump to other window.
doesn't adhere to #4
or #5
.
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.
Ohh, dot at the end of the message. Fixing that :) The subject line is already in imperative mood.
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 subject line is already in imperative mood.
I'm not a stickler for this stuff, but no, it's not.
Jump to other window when clicking on locref in REPL
would be.
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.
Indeed. The commit messages should ideally always start with a verb.
498e90c
to
b5fb91d
Compare
CHANGELOG.md
Outdated
@@ -8,6 +8,7 @@ | |||
|
|||
### Bugs Fixed | |||
|
|||
* Improve file retrieval when jumping to REPLs location references and Clojure vars cannot be resolved. |
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.
How come you can just to something that's not resolved? I guess you made some mistake in the description here. Or this just for the scope of the REPL defs. Frankly I don't remember much this code and I don't have time to dive into it, but I still have to understand what exactly is this supposed to fix.
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.
That code is recent. I added it in #2043 and now I am just improving on it.
I just said what I did there - when locrefs cannot be referenced from variables at point, use file metadata from the locrefs themselves. I can state it more generically "Improve locations lookup by using file metadata when available". Not accurate but conveys the improvement.
AFAIC, this need not be documented at all as being a small and technical fix on a recent change, but knowing how zealous you are on change-logs I added it.
d7ab529
to
052d90b
Compare
fc22b8d
to
74fee61
Compare
I am piling a bunch of related changes and improvements here. With a bit more doc this time, so should be self explanatory. Also fixing failing tests to account for recent buttercup changes. Two notable new features:
instead of |
It'd be better to open more PRs. A bunch of unrelated changes in a single PR is hard to review. |
- Disallow highlight spilling over () as in ns.foo.bar(file.clj:123)). - Start matching at the beginning of the symbol, not word. Particularly inhibit matching of namespaced keywords (which could be many).
6437a59
to
8d59067
Compare
This allows for customization of the modification of the REPL output before it is inserted into the buffer. New functions to be used as part of this hook: - cider-repl-add-locref-help-echo - cider-repl-highlight-current-project
8d59067
to
f93a5fe
Compare
Improving on #2043 a bit for navigation. Pass through file metatdata when available from location references and no info from var names could be retrieved.
cider-find-file
does a good job in those cases.