Repository navigation
Commit d864d6f
committed
Add a command that removes unused destructured keys
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.1 parent 370c7ff commit d864d6f
4 files changed
Lines changed: 871 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| 492 | + | |
492 | 493 | | |
493 | 494 | | |
494 | 495 | | |
| |||
645 | 646 | | |
646 | 647 | | |
647 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
648 | 673 | | |
649 | 674 | | |
650 | 675 | | |
| |||
0 commit comments