Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread macro is not honored #248

Closed
introom opened this issue Mar 8, 2022 · 8 comments
Closed

Thread macro is not honored #248

introom opened this issue Mar 8, 2022 · 8 comments

Comments

@introom
Copy link

introom commented Mar 8, 2022

Give the following code:

(-> zz
    (as-> x
          foo))

It should be formatted as:

(-> zz
    (as-> x
        foo))

Which also happens to be what emacs clojure mode does.

However, cljfmt thinks the code is already formatted.

Steps to reproduce:
clojure -Sdeps '{:deps {cljfmt {:mvn/version "0.8.0"}}}' -m cljfmt.main check example.clj

@weavejester
Copy link
Owner

Why should it be formatted that way? Can you give some justification?

@introom
Copy link
Author

introom commented Mar 8, 2022

It's like macro body forms two spaces indented.

foo here belongs to the body part.

https://github.com/bbatsov/clojure-style-guide#body-indentation

@introom
Copy link
Author

introom commented Mar 8, 2022

Similar to the fashion foo is indented here:

(as-> y x
  foo)

@weavejester
Copy link
Owner

The section of the Clojure style guide you link to recommends that forms shouldn't be indented 4 spaces, but in your original post you have indented 4 spaces. Was that a typo?

@introom
Copy link
Author

introom commented Mar 8, 2022

The issue is not about the format of -> but rather the inconsistency on how cljfmt handles as->.

Cljfmt requires that the body form to be two space indents, for example,

;; cljfmt thinks foo is correctly indented (1)
(as-> y
      x
  foo)

;; cljfmt thinks foo is not correctly indented (2)
(as-> y
      x
      foo)

The problem is, when the as-> is inside thread->, an implicit argument is placed; however, cljfmt seems to ignore it and formats it similar to the above case (2).

(-> y
    (as-> x
          foo))

@weavejester
Copy link
Owner

Ah, yes, that's a known missing feature. Currently cljfmt is not aware of the threading macros when handling block indentation.

@or
Copy link
Contributor

or commented May 10, 2022

Duplicate of #223.

@weavejester
Copy link
Owner

Closed due to duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants