Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [#171](https://github.com/clojure-emacs/clojure-ts-mode/pull/171): Highlight Markdown in the docstrings of the forms in `clojure-ts-extra-def-forms`.
- [#172](https://github.com/clojure-emacs/clojure-ts-mode/pull/172): Fix `clojure-ts-outline-variant` and `clojure-ts-completion-enabled` being ignored in `.dir-locals.el`.
- [#172](https://github.com/clojure-emacs/clojure-ts-mode/pull/172): Stop marking `clojure-ts-ensure-grammars`, `clojure-ts-auto-remap` and the options that turn the embedded parsers on and off as safe in `.dir-locals.el`, where they have no effect.
- [#169](https://github.com/clojure-emacs/clojure-ts-mode/pull/169): Add `clojure-ts-remove-unused-keys` (`C-c C-r k`), which removes the names the top-level form at point destructures from maps but never uses, along with their `:or` defaults.

## 0.6.0 (2025-12-02)

Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,30 @@ multi-arity function or macro. Function can be defined using `defn`, `fn` or
`defmethod` form. This command also supports functions defined inside forms like
`letfn`, `defprotocol`, `reify`, `extend-protocol` or `proxy`.

### Remove unused destructured keys

`clojure-ts-remove-unused-keys`: Remove what the top-level form at point
destructures from maps but doesn't use: names in `:keys`, `:strs` and `:syms`,
`:as` names and names bound to keys, along with their `:or` defaults. That
covers arglists (`defn`, `fn`, `defmethod`, `letfn`, `reify` and the like) and
the bindings of `let`, `loop`, `for`, `doseq` and the like. A map with nothing
left becomes `_`.

```clojure
(defn handle [{:keys [id user] :or {user "anon"} :as req}]
(process id))

;; becomes

(defn handle [{:keys [id]}]
(process id))
```

A name stays when a symbol with that name appears anywhere in its scope, even
if it's a local that shadows it, and so does one starting with `_`, which marks
it unused on purpose. Positional args and vector destructuring are left alone,
as removing one would change what the others bind.

### Default keybindings

| Keybinding | Command |
Expand All @@ -648,6 +672,7 @@ multi-arity function or macro. Function can be defined using `defn`, `fn` or
| `C-c C-r c` / `C-c C-r C-c` | `clojure-ts-cycle-conditional` |
| `C-c C-r o` / `C-c C-r C-o` | `clojure-ts-cycle-not` |
| `C-c C-r a` / `C-c C-r C-a` | `clojure-ts-add-arity` |
| `C-c C-r k` / `C-c C-r C-k` | `clojure-ts-remove-unused-keys` |

### Customize refactoring commands prefix

Expand Down
Loading
Loading