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

Prevent clean-ns from putting :as and :refer on their own lines #305

Closed
expez opened this issue Jun 27, 2021 · 0 comments
Closed

Prevent clean-ns from putting :as and :refer on their own lines #305

expez opened this issue Jun 27, 2021 · 0 comments
Assignees

Comments

@expez
Copy link
Member

expez commented Jun 27, 2021

This is due the default output from clojure.pprint/pprint when a vector grows long. It will then put each element on their own line. This looks especially stupid with libspec vectors:

[a.pretty.long.ns.gets.its.own.line.like.it.should
 :as 
 but-then-the-alias-comes-way-down-here]

A better formatting would be:

[a.pretty.long.ns.gets.its.own.line.like.it.should
 :as the-alias-comes-on-this-line-instead]

I want to give :refer the same treatment.

[a.pretty.long.ns.gets.its.own.line.like.it.should
 :refer
 [this that]

becomes:

[a.pretty.long.ns.gets.its.own.line.like.it.should
 :refer [this that]

This will, however, cause a bit of a regression if you have a ton of referred symbols:

(require
 '[a.pretty.long.ns.gets.its.own.line.like.it.should
   :refer
   [this
    that
    the
    other
    more
    moar
    and
    finally
    the
    problem
    on
    comes
    on
    line-wrap]])

becomes:

(require '[a.pretty.long.ns.gets.its.own.line.like.it.should
           :refer [this
                   that
                   the
                   other
                   more
                   moar
                   and
                   finally
                   the
                   problem
                   on
                   comes
                   on
                   line-wrap]])

I think these both look super bad. This behavior will privilege short :refer clauses, but I think that's fine. Having tons of referred symbols is an anti-pattern anyway, so we should nudge people toward not doing that.

If someone does this consistently we can always take another PR improving this edge-case further.

@expez expez self-assigned this Jun 27, 2021
expez added a commit that referenced this issue Jun 27, 2021
This makes the ns form take up less vertical space and makes it easier
on the eyes.

This was never done intentionally but a side-effect of simply delegating
the printing of regular libspecs to `clojure.core.pprint` which puts
each element of a vector on its own line when the line gets long enough.
expez added a commit that referenced this issue Jun 27, 2021
This makes the ns form take up less vertical space and makes it easier
on the eyes.

This was never done intentionally but a side-effect of simply delegating
the printing of regular libspecs to `clojure.core.pprint` which puts
each element of a vector on its own line when the line gets long enough.
expez added a commit that referenced this issue Jun 27, 2021
This makes the ns form take up less vertical space and makes it easier
on the eyes.

This was never done intentionally but a side-effect of simply delegating
the printing of regular libspecs to `clojure.core.pprint` which puts
each element of a vector on its own line when the line gets long enough.
expez added a commit that referenced this issue Jun 27, 2021
This makes the ns form take up less vertical space and makes it easier
on the eyes.

This was never done intentionally but a side-effect of simply delegating
the printing of regular libspecs to `clojure.core.pprint` which puts
each element of a vector on its own line when the line gets long enough.
expez added a commit that referenced this issue Jun 27, 2021
This makes the ns form take up less vertical space and makes it easier
on the eyes.

This was never done intentionally but a side-effect of simply delegating
the printing of regular libspecs to `clojure.core.pprint` which puts
each element of a vector on its own line when the line gets long enough.
expez added a commit that referenced this issue Jun 27, 2021
This makes the ns form take up less vertical space and makes it easier
on the eyes.

This was never done intentionally but a side-effect of simply delegating
the printing of regular libspecs to `clojure.core.pprint` which puts
each element of a vector on its own line when the line gets long enough.
@expez expez closed this as completed in 5d4ff16 Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant