-
-
Notifications
You must be signed in to change notification settings - Fork 53
Filter special form symbols from eldoc args list #166
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
Filter special form symbols from eldoc args list #166
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.
Thanks much for the accurate reports and initial PR!
I updated the PR to take the approach that you described. I've added an option for EDIT: The code to actually invoke |
I'm a bit puzzled about the need to make this deduping conditional. Are there cases when we'd actually want this? P.S. I'm also puzzled that for 10 years nobody reported this when in hindsight the problem is obvious. :D |
I've also been thinking that if want to adjust this only for Eldoc we can just as easily do it on the Elisp side. The current approach will not solve the problem for someone running CIDER without cider-nrepl as nREPL's info op is different (simpler). |
If a user wrote a function whose first parameter was the same name as the function itself, i.e: (defn foo [foo bar baz]
(println foo bar baz)) we probably would not want to filter out the first argument because it's the same name as the function itself. I initially tried to do this in the elisp code, but the obstacle I ran into was the fact that |
Actually, now that I take another look at it, I see that So instead of filtering here, what I could do is update Then, on the elisp side, it seems like it would be more straightforward to implement the filtering logic. |
I'd be fine with this, although this still leave the problem with nREPL without cider-nrepl (and orchard). This information will be missing there. Give how few the special forms are and they've never changed I guess we can just hardcode them in the Elisp code as a quick solution. |
I've written up the change on the CIDER side, in PR #3233. |
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!
Happy to see a simplified version - the less code the better!
Instead of treating special-forms and macros as functions, we should send them as special-forms and macros, respectively, so that CIDER (and other clients) can properly handle the arglists.
@quanticle Don't forget to add a changelog entry for this. |
@quanticle Ping :-) |
This fix is the CIDER companion to [this PR](clojure-emacs/orchard#166) in orchard, which lets us know if the symbol we're querying eldocs for is a special form or an ordinary function. This changes uses that information to deduplicate the arglists for the special form. In the process, the change adds a `cider-eldoc-format-special-form` function, which serves as a home for special form formatting. This change also adds a unit test for cider-eldoc to ensure that it calls the appropriate formatting methods.
This fix is the CIDER companion to [this PR](clojure-emacs/orchard#166) in orchard, which lets us know if the symbol we're querying eldocs for is a special form or an ordinary function. This changes uses that information to deduplicate the arglists for the special form. In the process, the change adds a `cider-eldoc-format-special-form` function, which serves as a home for special form formatting. This change also adds a unit test for cider-eldoc to ensure that it calls the appropriate formatting methods.
Orchard changed how arglists-str are formatted for special forms in this PR: clojure-emacs/orchard#166 It looks like this broke the info tests in cider-nrepl. Assuming the new behaviour is the correct one, I fixed the tests accordingly.
Fixes #165.
Currently, the eldoc args list for special forms includes the special form itself, which throws off the highlighting in Emacs' CIDER. This patch removes the special forms themselves from the args list. It specifically omits the Java interop special forms, because these, for some reason, do not include themselves in the :forms vector.