Repository navigation
Add a command that removes unused destructured keys - #708
Merged
Merged
Conversation
bbatsov
force-pushed
the
remove-unused-keys
branch
from
November 1, 2026 09:32
485b205 to
108a3e7
Compare
clojure-remove-unused-keys (C-c C-r k) removes what the top-level form at point destructures from maps but never uses: names in :keys, :strs and :syms, :as names and names bound to keys, along with their :or defaults. It covers the arglists of fn, defn, defmethod, letfn and methods, and the bindings of let-like forms. A map with nothing left becomes _. Comments and #_ forms among the names stay, and a map that still has one isn't empty. A name counts as used when any unqualified symbol with that name appears in its scope. That ignores shadowing, so it can only miss a removal. Names starting with _ stay, as do positional args and vector destructuring. A map left with only :as stays a map, as map destructuring turns a seq into a map and the bare name wouldn't. Quoted and syntax-quoted forms are left alone, being data or a macro's template. With no syntax tree to go by, a small reader turns the form into one, which keeps the rest the same as in clojure-ts-mode.
bbatsov
force-pushed
the
remove-unused-keys
branch
from
November 3, 2026 07:28
108a3e7 to
baa7b31
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The same command as clojure-emacs/clojure-ts-mode#169. clojure-mode has no syntax tree, so a small reader builds one for the form at point, and the rest matches the clojure-ts-mode version. Both give the same results over cider-nrepl, orchard and refactor-nrepl.