Skip to content
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

clojure-find-def fails on spurious comments #686

Open
smendezs opened this issue Feb 24, 2025 · 1 comment
Open

clojure-find-def fails on spurious comments #686

smendezs opened this issue Feb 24, 2025 · 1 comment

Comments

@smendezs
Copy link

If I put a comment after a defn like this:

(defn
   ;; comment
   foo [a b]
   (+ a b))

it's still syntactically valid clojure. However, this breaks some clojure-mode functionality.

Expected behavior

(clojure-find-def) with the pointer in that function should return ("defn" "foo").

Actual behavior

It returns nil.

The regexp responsible for this, clojure-def-type-and-name-regex doesn't take into account any comments before the symbol name (foo in this case).

Steps to reproduce the problem

Execute (clojure-find-def) while the pointer is in the above function def.

Environment & Version information

clojure-mode version

clojure-mode (version `20241211)`

Emacs version

29.4

Operating system

Ubuntu 22.04

@smendezs
Copy link
Author

While the case may sound silly, it comes up in our code base in the test files, where some people put testrunner params after the function, for example:

(deftest
^:test-refresh/focus
test-name
(is...))

So if you later comment out the test-refresh/focus, clojure-mode has trouble recognizing the def for that test.

Solution

I can send a patch adding to the regexp mentioned above, but that's ugly. Is there a better solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant