-
-
Notifications
You must be signed in to change notification settings - Fork 247
Rename ns alias improvements #556
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
Rename ns alias improvements #556
Conversation
9edea85
to
4f9548a
Compare
clojure-mode.el
Outdated
@@ -2684,6 +2684,19 @@ lists up." | |||
(insert sexp) | |||
(clojure--replace-sexps-with-bindings-and-indent))) | |||
|
|||
(defun clojure--collect-ns-aliases () |
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 guess this one can even be public API and optionally take a ns
form as a param.
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.
Do you mean having it as a string->list pure function? Or taking a point
param marking the location of the start of the ns form?
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.
Pure function taking a ns form as param.
clojure-mode.el
Outdated
(while (re-search-forward rgx end 'noerror) | ||
(message (match-string 1)) | ||
(push (cons (point) (match-string-no-properties 1)) res)) | ||
res))) |
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 not sure I understand the value of returning cons cells here if the first item in the cons cell is not the name the alias is referring to.
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.
Hmm, I wrote this a few months ago and can't remember why I had that in the first place, will simplify
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.
👍
@@ -2,8 +2,12 @@ | |||
|
|||
## master (unreleased) | |||
|
|||
### Bugs fixed | |||
### New features | |||
* [#556](https://github.com/clojure-emacs/clojure-mode/issues/556): `clojure-rename-ns-alias` picks up existing aliases for minibuffer completion. |
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.
Please, add a blank line after each heading.
This allows for renaming ns aliases with special regex chars like . and *, without having to quote them
badf458
to
2ff902b
Compare
I discovered and fixed another bug when aliases have common prefixes, eg. [clojure.string :as string]
[clojure.spec.alpha :as s] renaming s -> x would produce Refactored I can squash related commits together if needed, thanks |
2ff902b
to
327f2f4
Compare
Looks fine to me. Add a couple of unit tests for it and we're in business.
Great!
That'd be ideal! Thanks! |
327f2f4
to
2b962d8
Compare
Okay, squashed the commits and included one test for the collect-aliases function. |
Thanks! |
Some minor improvements to the command
clojure-rename-ns-alias
, offering minibuffer completion of existing aliases and using regexp-quote, so that namespaces containing characters like*
or+
can be renamed correctly without need for manual escaping.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.