Skip to content

Threading macro alignment of first argument on it's own line #254

Open
@dannyfreeman

Description

@dannyfreeman

Sometimes I find myself with a threading macro where I don't want the first argument to be on the same line as the threading symbols.

For example

(->>
 x
 foo
 bar

This guide does not recommend the number of spaces to indent the arguments with in this situation.
Clojure-mode default in Emacs indents 1 space from the opening (. cljfmt does the same.

I observe most people keeping the first argument on the same line as the threading macro symbol, and think it is the ideal way to align. However, sometimes lines get long and people drop the first argument down to. I'd like to add something like that into the guide for those situations.

Maybe change the threading macros alignment section could have a "not as good" part for this situation.

;; good
(->> (range)
     (filter even?)
     (take 5))

;; not as good
(->> 
 (range)
 (filter even?)
 (take 5))

;; bad
(->> (range)
  (filter even?)
  (take 5))

As for the alignment/offset to recommend, I don't have a preference. Since cljfmt uses 1 I'd recommend sticking with that since people use that tool for linting in CI/CD pipelines.

Happy to make the PR myself as well, but wanted to open an issue before doing that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions