Rename ns alias improvements - #556
Conversation
9edea85 to
4f9548a
Compare
| (insert sexp) | ||
| (clojure--replace-sexps-with-bindings-and-indent))) | ||
|
|
||
| (defun clojure--collect-ns-aliases () |
There was a problem hiding this comment.
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.
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.
Pure function taking a ns form as param.
| (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.
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.
Hmm, I wrote this a few months ago and can't remember why I had that in the first place, will simplify
|
|
||
| ### 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.
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 checkdocand fixed any warnings in the code you've written.