Skip to content

Add :indent-rich-comments? option#387

Open
jramosg wants to merge 1 commit into
weavejester:masterfrom
jramosg:feature/indent-rich-comments
Open

Add :indent-rich-comments? option#387
jramosg wants to merge 1 commit into
weavejester:masterfrom
jramosg:feature/indent-rich-comments

Conversation

@jramosg

@jramosg jramosg commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Rich comments are often used as a scratchpad where forms are added and removed frequently. Allowing the closing parenthesis to be placed on a new line, aligned with the indentation of the block, makes these edits cleaner and keeps the diffs focused on the actual code changes.

This commit adds the :indent-rich-comments? option, which:

  • Ensures a trailing newline exists in rich comments when enabled.
  • Prevents the removal of this newline during whitespace cleanup.
  • Aligns the closing parenthesis with the block's indentation.

Fixes #365.

Rich comments are often used as a scratchpad where forms are added and
removed frequently. Allowing the closing parenthesis to be placed on a
new line, aligned with the indentation of the block, makes these
edits cleaner and keeps the diffs focused on the actual code changes.

This commit adds the :indent-rich-comments? option, which:
- Ensures a trailing newline exists in rich comments when enabled.
- Prevents the removal of this newline during whitespace cleanup.
- Aligns the closing parenthesis with the block's indentation.

Fixes weavejester#365.
@jramosg
jramosg force-pushed the feature/indent-rich-comments branch from e1a9437 to 1cab794 Compare January 15, 2026 18:07
@weavejester

Copy link
Copy Markdown
Owner

This option should default to false, as we don't want it to reformat existing code.

I'm also unsure if this is the right way to go about this feature. Let me give it some thought, but my initial idea is it might be worth having a list of forms that ignore certain rules.

@jramosg

jramosg commented Jan 29, 2026

Copy link
Copy Markdown
Contributor Author

we could have something like:

{:rule-exceptions {comment #{:gather-trailing-parens}}}

what do you think?

@marksto

marksto commented Mar 25, 2026

Copy link
Copy Markdown

Over the years I personally got used to this syntax:

(comment
  ,,,
  :end/comment)

It's just an extra globally interned keyword (if you are inaccurate to eval it), otherwise a no-op that achieves the same goal for rich-comment blocks, plays nicely with tooling (both linters and formatters) and has a low potential to piss off one's colleagues.

I saw people doing different other similar things, e.g.:

(comment
  ,,,
  .)

(comment
  ,,,
  #_x)

but I found that either lacking clear, obvious semantics and/or not being able to play nicely with this or that tooling.

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

Successfully merging this pull request may close these issues.

Put rich comment's closing parenthesis on a new line

3 participants