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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- [#116](https://github.com/clojure-emacs/clojure-ts-mode/pull/116): Extend built-in completion to complete all imported symbols from an `ns`
form.
- Add documentation and bug reporting commands from `clojure-mode`.
- Add some ns manipulation functions from `clojure-mode`.
- [#118](https://github.com/clojure-emacs/clojure-ts-mode/pull/118): Add some ns manipulation functions from `clojure-mode`.
- Fix a bug in `clojure-ts-add-arity` when body has more than one expression.

## 0.5.1 (2025-06-17)

Expand Down
7 changes: 6 additions & 1 deletion clojure-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,12 @@ type, etc. See `treesit-thing-settings' for more details."
(when same-line-p
(newline-and-indent))
(when single-arity-p
(insert-pair 2 ?\( ?\))
(save-excursion
(backward-up-list)
(forward-list)
(down-list -1)
(insert ")"))
(insert "(")
(backward-up-list))
(insert "([])\n")
;; Put the point between square brackets.
Expand Down
16 changes: 16 additions & 0 deletions test/clojure-ts-mode-refactor-add-arity-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@

(clojure-ts-add-arity))

(when-refactoring-with-point-it "should handle a single-arity defn with multiple body expressions"
"(defn fo|o
^{:bla \"meta\"}
[arg]
body
second-expr)"

"(defn foo
^{:bla \"meta\"}
([|])
([arg]
body
second-expr))"

(clojure-ts-add-arity))

(when-refactoring-with-point-it "should add an arity to a multi-arity defn"
"(defn foo
([arg1])
Expand Down
3 changes: 2 additions & 1 deletion test/samples/refactoring.clj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
(defn foo
^{:bla "meta"}
[arg]
body)
body
second-expr)

(if ^boolean (= 2 2)
true
Expand Down