-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Relax regexp for clojure-find-def to recognize more complex metadata on vars #682
Relax regexp for clojure-find-def to recognize more complex metadata on vars #682
Conversation
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.
LGTM!
Because the addition is a single +
to a regex, there's practically no risk of breaking anything with this.
You might enjoy adding some test cases - since this is a pure function it should easy to add a variety:
- without / with metadata
- def/defn/defwhatever
^:private
That's optional though.
The proposed changes look good to me. Just add a bugfix entry to the changelog and we're good to go. |
Thanks for the quick feedback! I added a few tests based on the issue reported by @mbezjak. While doing so, I came across this failing test case:
In other words, |
Yeah, that's definitely a bug. |
Seems like the issue is that in this part of the
the |
Thanks again for your quick feedback! I'd be happy to make a PR for the |
We're all good here. Thanks!
A separate PR would be great! |
This PR tries to solve an issue that was originally reported on the CIDER project, but was later found to be related to
clojure-mode
: clojure-emacs/cider#3758.In summary, the problem encountered is that running
cider-test-run-test
on a form like thisdoes not correctly recognize this as a test (in fact it doesn't recognize this as a def-form at all). I traced the underlying issue to the regexp
clojure-def-type-and-name-regex
used byclojure-find-def
, which I assume make a best-effort attempt at recognizing metadata on vars, but which is not able to match on the form above since it doesn't match metadata maps with more than one right-brace}
.The approach in this PR is to modify the regexp to allow for more than one right-brace at the end of the metadata, if it is a map. A more robust approach would be to use an actual Clojure parser, but that might be a bit excessive.
I didn't find any tests related to
clojure-find-def
, but please let me know if I should add one.Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):
M-x checkdoc
and fixed any warnings in the code you've written.Thanks!