Skip to content

Introduce clojure-ts-add-arity refactoring command #93

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

Merged
merged 1 commit into from
May 11, 2025

Conversation

rrudakov
Copy link
Contributor

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):

  • The commits are consistent with our contribution guidelines.
  • You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
  • You've run M-x checkdoc and fixed any warnings in the code you've written.
  • You've updated the changelog (if adding/changing user-visible functionality).
  • You've updated the readme (if adding/changing user-visible functionality).

Thanks!

@rrudakov rrudakov force-pushed the feature/add-arity branch from 79b93ee to 40bdb39 Compare May 10, 2025 16:28
(defun clojure-ts-add-arity ()
"Add an arity to a function."
(interactive)
(if-let* ((sym-regex (rx bol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing you can extract some private function checking whether the form at point is function-like. I assume that would be useful for other things down the road.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done a small refactoring in this PR and extracted some helper functions, such as clojure-ts--search-list-form-at-point or clojure-ts--list-node-sym-text or clojure-ts--parent-until (which I wish was part of treesit.el). This particular regexp and the following query is very unlikely going to be used anywhere else, it's too specific. If I extracted it to a function I would have to give it a name that indicates that it returns a node that represents a construct to which an arity could be added. We can always extract it if we need it in other place.

@rrudakov rrudakov force-pushed the feature/add-arity branch from 40bdb39 to afe6f9d Compare May 11, 2025 06:22
@rrudakov rrudakov force-pushed the feature/add-arity branch from afe6f9d to 49c2c1e Compare May 11, 2025 06:28
@rrudakov rrudakov requested a review from bbatsov May 11, 2025 06:29
@bbatsov bbatsov merged commit a1fdc69 into clojure-emacs:main May 11, 2025
3 checks passed
@rrudakov rrudakov deleted the feature/add-arity branch May 11, 2025 07:16
@rrudakov
Copy link
Contributor Author

Thanks for quick review!

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

Successfully merging this pull request may close these issues.

2 participants