Rename ns aliases in selected region #590
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When copying code from other sources, the conventions for aliasing namespaces may be different (eg.
str
vsstring
for clojure.string) and one has to manually search and replace these aliases.Since there was already a
clojure-rename-ns-alias
command with most of the relevant logic, I extended it to be able to rename aliases in a selected region. In that case, it will not touch the ns form at all and only pick up aliases from the region.I also cleaned up the code a bit from my previous PR here, moving the ns-alias related functions together and renaming
clojure-collect-ns-aliases
with double dashes (there was really no reason for it to be public in the first place).The API could be changed to introduce another command instead of doing region-active DWIM on
clojure-rename-ns-alias
. But in practice I find that such renaming usually involves multiple (selected) forms, so a command that works on top-level forms probably isn't that useful.Will update the changelog and readme after details are confirmed :)
Thanks!
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!