-
-
Notifications
You must be signed in to change notification settings - Fork 247
Recognize defn- in clojure-find-def
for declarations
#683
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
Conversation
test/clojure-mode-util-test.el
Outdated
@@ -374,7 +374,25 @@ | |||
"(deftest ^{:a 1} simple-metadata) | |||
(deftest ^{:a {}} complex-metadata) | |||
(deftest |no-metadata)" | |||
(expect (clojure-find-def) :to-equal '("deftest" "no-metadata"))))) | |||
(expect (clojure-find-def) :to-equal '("deftest" "no-metadata")))) | |||
(it "should recognize defn-" |
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.
Probably you should also add a couple of tests showing that anything like defxyz-
will be accepted, so it's clearer that the -
will work for every definition form.
"(defn- |^{:doc \"A function\"} foo [] 1) | ||
(defn- ^:private bar 2)" | ||
(expect (clojure-find-def) :to-equal '("defn-" "foo"))) | ||
(with-clojure-buffer-point |
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 this test should be under a different it
group.
Thanks for the detailed description of the problem and the proposed solution! Outside of my small remark about adding some extra tests - your proposed changes look good to me. Also - please mention your fix in the changelog. P.S. It's always nice to see a first-time contributor to the project! |
My pleasure! It's my first-ever open source contribution, so thank you for the feedback and for the helpful contribution guide! Please let this newbie know if there's anything else I can improve 😊 |
Everything looks great now! Just rebase your branch on top of
Hopefully the first of many! 🚀 |
c0adec2
to
93170ef
Compare
Glad to hear it! ❤ Thanks to you and to @frwdrik! |
This PR expands on the work of #682.
The problem is that when running
cider-find-def
with point inside the following function,it would not recognize
defn-
as the first symbol. Instead it would output("defn" "-")
. I would expect it to output("defn-" "foo")
.This stems from the regex for declarations in
clojure-def-type-and-name-regex
:clojure-mode/clojure-mode.el
Line 2269 in 63356ee
It recognizes
def
followed by an entry from the word classw
or from the symbol class_
, but it also states that the end must be from the "comment end" class>
. The hyphen is not included in this class and therefore can't be the final character in the recognized expression.My suggested fix is to recognize an optional hyphen at the end.
It still recognizes
def-n
and now alsodef-n-
I added a few test cases to the ones added by @frwdrik.
Emacs version:
GNU Emacs 30.0.92 (build 2, aarch64-apple-darwin24.1.0, NS appkit-2575.20 Version 15.1 (Build 24B83)) of 2024-11-01
clojure-mode
version:clojure-mode (version 5.20.0-snapshot)
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!