Skip to content
Open
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 @@ -18,6 +18,7 @@

* [#709](https://github.com/clojure-emacs/clojure-mode/pull/709): Fix `clojure-get-indent-spec` and `put-clojure-indent` converting legacy indent specs, like those of `letfn`, `reify` or `extend-protocol`, to the wrong modern rules.
* [#709](https://github.com/clojure-emacs/clojure-mode/pull/709): Fix indenting with a modern indent spec that has an `:inner` rule with a position but no `:block` rule, like `((:inner 1 0))`, which signaled an error.
* [#711](https://github.com/clojure-emacs/clojure-mode/pull/711): Fix the indentation of `letfn` functions, and of other forms an `:inner` rule with an index applies to, when a `#_` form comes before them, as the discarded form and its `#_` counted as two arguments.

## 5.23.0 (2026-03-25)

Expand Down
6 changes: 5 additions & 1 deletion clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,11 @@ holds a list of forms, each indented with :defn style\"."
(while (ignore-errors (clojure-backward-logical-sexp 1)
(not (or (bobp)
(eq (char-before) ?\n))))
(cl-incf pos))
;; #_ discards the form after it, which was counted already,
;; unless that's the form we started from.
(if (looking-at-p "#_")
(setq pos (max 0 (1- pos)))
(cl-incf pos)))
(let* ((function (thing-at-point 'symbol))
(method (or (when function ;; Is there a spec here?
(clojure--get-indent-method function))
Expand Down
11 changes: 11 additions & 0 deletions test/clojure-mode-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,17 @@ DESCRIPTION is a string with the description of the spec."
(baz 1)))]
(foo (bar 10)))")

(when-indenting-it "should not count discarded forms for the position of an inner rule"
"
(letfn #_[(f [] 1)] [(g []
2)]
(g))"

"
(letfn #_ #_ [(f [] 1)] [(g [] 2)] [(h []
3)]
(h))")

(when-indenting-it "should handle try/catch/finally"
"
(try
Expand Down
Loading