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

Comment formatting #30

Closed
greglook opened this issue Jan 24, 2020 · 1 comment
Closed

Comment formatting #30

greglook opened this issue Jan 24, 2020 · 1 comment

Comments

@greglook
Copy link
Owner

So far cljstyle mostly avoids moving comments around or otherwise formatting them, but there are a few rules that come to mind as useful additions:

  • Enforce that stand-alone comments start with two semicolons (;;) - this matches convention and keeps Emacs from pushing the comment far to the right as it does with single-semicolon comments.
  • Apply indentation rules to comments. Right now a reindented form leaves comments at their original indent, requiring manual fixup later.
  • Wrap long comments at a certain column.
@sogaiu
Copy link

sogaiu commented Jul 26, 2020

I don't know if this counts as comment formatting, but I end up with things that look like this:

(clojure.test/deftest test-at-line-425
  (clojure.test/is (= true (discard-with-form?
                             '(:discard
                                (:whitespace " ")
                                (:map
                                  (:keyword ":a") (:whitespace " ")
                                  (:number "1")))))))
;; XXX: iiuc, discard forms in parcera can have up to 2
;;      elements in them.  if there are two elements,
;;      the first is whitespace.
;;
;;      if the understanding above is false, the following
;;      code should be modified.
(defn undiscard
  [ast]
  (when (discard-with-form? ast)
    (->> (rest ast)
         (drop-while whitespace?)
         first)))

I'd like for there to be a line between the last line of the first deftest form and the first line of the comment. I tried a variety of configuration settings without much success.

FWIW, the following is what I had in .cljstyle to produce the output above:

{:indentation? true
 :insert-missing-whitespace? true
 :insert-padding-lines? true
 :line-break-functions? true
 :max-consecutive-blank-lines 0
 :padding-lines 1
 :remove-consecutive-blank-lines? true
 :remove-surrounding-whitespace? true
 :remove-trailing-whitespace? true
 :require-eof-newline? true}

The settings above were tuned a bit to try to have a single line between top-level forms -- and that seemed to be working.

Any ideas?

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

2 participants