Repository navigation
Align threading macro args with the first arg - #153
Merged
bbatsov merged 1 commit intoOct 29, 2026
Merged
Conversation
This was referenced Oct 25, 2026
The threading macro rule anchored each argument on its previous sibling. That only works when every line holds exactly one form: after a line like `(first) (last) :interceptors` or a trailing comment, the next argument lined up with that last form or the comment instead. The function call rule already aligns arguments with the first one, and it gives the same result for the cases the threading rule was written for, so the threading rule is removed. This matches cljfmt and clojure-mode.
bbatsov
force-pushed
the
fix-threading-macro-arg-indentation
branch
from
October 29, 2026 06:02
8453c30 to
04336e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In semantic indentation, the arguments of
->,->>,some->and the other threading macros are lined up with the previous argument instead of the first one. That works only when every line holds exactly one form. After a line with several forms, a trailing comment, or a comment after the first argument, every following line jumps to the right.This PR removes the special threading-macro rule. The ordinary function-call rule already aligns each argument with the first one, which gives the same result in the cases the threading rule was written for, and the right result in the cases above. The output now matches clojure-mode and cljfmt.
Examples
Each example shows the result of
indent-regionwith default settings and alignment turned on (clojure-ts-align-forms-automatically/clojure-align-forms-automatically). Identical outputs are grouped under one heading.A line with several threaded forms
clojure-mode, cljfmt 0.13.1, clojure-ts-mode with this PR:
clojure-ts-mode
main:A trailing comment
clojure-mode, cljfmt 0.13.1, clojure-ts-mode with this PR:
clojure-ts-mode
main:A comment after the first argument
clojure-mode, cljfmt 0.13.1, clojure-ts-mode with this PR:
clojure-ts-mode
main:Any symbol ending in -> or ->> (here some->)
clojure-mode, cljfmt 0.13.1, clojure-ts-mode with this PR:
clojure-ts-mode
main:Tests
This PR adds a new spec,
should align threading macro args with the first arg, covering several forms on one line, a trailing comment,some->, a multi-line argument, and->>with its first argument on the next line. It fails onmainand passes with this PR.How it was checked locally:
make all(Eldev: compile with warnings as errors, lint, indent check, tests) passes on Emacs 30.1 (the nix-emacs-ci build CI uses) and on 31.1.50, the closest local build to CI's snapshot.Notes
clojure-ts--threading-macrois kept, because other code still uses it.Part of a series
This is one of 7 small, independent PRs, each fixing one problem found while making clojure-ts-mode format like clojure-mode. Each one is based on
mainand none depends on another. Some touch neighbouring lines inCHANGELOG.mdand the indentation tests, so once one is merged the others may need a quick rebase, which we're happy to do::blockformsclojure.test/arealignmentindent-regionleaving the last forms unalignedAbout this PR
The code, tests and this description were generated by an AI (Claude, by Anthropic), at @jasonjckn's request. Sorry for the PR spam: the fixes are split up so that each one can be accepted or rejected on its own instead of in one big change. If AI-generated contributions are a problem for this project, please feel free to close these PRs right away.
M-x checkdocand fixed any warnings in the code you've written.