Skip to content

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

Closed
@expez

Description

@expez

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions