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 @@ -3,6 +3,7 @@
## master (unreleased)

- [#386](https://github.com/clojure-emacs/orchard/pull/386): Inspector: rename default view mode for unknown objects to `:object`.
- [#396](https://github.com/clojure-emacs/orchard/pull/396): Indent: don't crash on `(quote (...))`-wrapped `:arglists` (clojure-emacs/cider#3923).
- [#397](https://github.com/clojure-emacs/orchard/pull/397): Inspector: add support for diffing sets.

## 0.41.0 (2026-04-13)
Expand Down
16 changes: 15 additions & 1 deletion src/orchard/indent.clj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@
'fntail
'fn-tail]))))

(defn- normalize-arglists
"Unwrap a `(quote ...)` wrapper around `arglists`, if present.

ClojureScript's analyzer preserves `:arglists` as the raw form when it
comes from a macro-written macro (i.e. a macro whose body emits
`'([x])` for `:arglists` instead of a bare `([x])`). Most consumers
expect the bare seq of arglist vectors, so peel the `quote` off before
processing."
[arglists]
(if (and (seq? arglists)
(= 'quote (first arglists)))
(second arglists)
arglists))

(defn infer-style-indent
"Given a `metadata` map obtained from a Clojure var object,
associates a `:style/indent` value based on inference (rule of thumb) rules:
Expand All @@ -161,6 +175,6 @@

`:style/indent` will be not associated if no rule matched."
[{:keys [name arglists] :as metadata}]
(let [result (compute-style-indent (str name) arglists)]
(let [result (compute-style-indent (str name) (normalize-arglists arglists))]
(cond-> metadata
result (assoc :style/indent result))))
24 changes: 24 additions & 0 deletions test/orchard/indent_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,27 @@
'->> '[[x & forms]] nil
'some-> '[[x & forms]] nil
'some->> '[[x & forms]] nil))

(deftest infer-style-indent-test
(testing "unwraps `(quote ...)`-wrapped arglists"
;; ClojureScript's analyzer preserves `:arglists` as the raw form
;; for macro-written macros, so it shows up as `(quote (...))`
;; rather than `(...)`. See clojure-emacs/cider#3923.
(is+ {:name 'with-ctx
:arglists '(quote ([ctx & body]))
:style/indent 1}
(sut/infer-style-indent
{:name 'with-ctx
:arglists '(quote ([ctx & body]))})))

(testing "passes through bare arglists unchanged (regression test for the common path)"
(is+ {:name 'with-ctx
:arglists '([ctx & body])
:style/indent 1}
(sut/infer-style-indent
{:name 'with-ctx
:arglists '([ctx & body])})))

(testing "doesn't crash on metadata without arglists"
(is+ {:name 'foo}
(sut/infer-style-indent {:name 'foo}))))