-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
79b93ee
to
40bdb39
Compare
(defun clojure-ts-add-arity () | ||
"Add an arity to a function." | ||
(interactive) | ||
(if-let* ((sym-regex (rx bol |
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'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.
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'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.
40bdb39
to
afe6f9d
Compare
afe6f9d
to
49c2c1e
Compare
Thanks for quick review! |
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!