Hello everyone
https://youtu.be/gIoadGfm5T8?t=953
In this video Sean Corfield describes a tip about comment where you put a trailing comma to avoid structural editing packages from trying to clean this up. Is this still valid? I'm using smartparens in emacs at the moment. The reason I'm asking is because I just started configuring cljfmt and it always joins the paren and removes the comma. I couldn't find a setting to have cljfmt ignore this.
How are other people handling this?
Thank you
Hi!
I've had the same problem. My workaround has been to use a keyword: :rcf, short for "rich comment form". Several Clojure core namespaces have comment forms like this, for example clojure.set.
Currently, my editor does not do this "cleanup", so at the moment, I just leave the whitespace. So this will depend on your teammates and editor setup :)
I use a semicolon in the line before the closing bracket.
Ok, I'll try those options, thank you
It's fun to use :-) as the closing paren. I can't remember where I first saw that.
By the way, cljfmt might consider a patch: https://github.com/weavejester/cljfmt/issues/365
So… what’s the motivation for doing it the Lisp way normally, that is, all ending parens bunched together? Any specific reasons or just “because Lisp, duh”? I’ve never cared much, but for (comments… yeah 🙂
I like and use :eoc (end of comment).
I tend to put *e at the end
I no longer need the comma with VS Code/Calva and I don't use cljfmt directly. I do occasionally see the trailing paren lifted onto the previous line but have not figured out when or why, so maybe that's some cljfmt usage behind the scenes?
@mattias504 to make it easier to evaluate form at cursor by placing your cursor at the end of each line inside the comment so you don't have to worry about that last line and accidentally evaluate the whole comment instead of the last form.
(That's why comments are different to normal lisp forms - but I'm not sure why we lispers bunch the parens up)
I think the chunking up of closing parens relates to our love for brevity. Fewer lines that don't communicate anything.
I've used the following rich comment form style when I wasnt able to get the format tool to behave
(
#_())
I stopped using this rich comment form once I started using parinfer, as I can type directly under the rich comment form and it will move the closing paren accordingly.According to Windows Copilot (ChatGPT 5 now), it's a combination of history (Lisp dates back to when screens were small and horizontal real estate was at a premium), compactness in general (per @teodorlu), editors followed that style (and still do), and a focus on logical structure in code (rather than "lines of code" like other languages). It didn't give me footnotes/links to any authoritative sources this time.
When I first encountered Lisp (early '80s), I remember all the examples I found used this style and I never saw anything to the contrary, so there's an element of "we've always done it this way!" (which I normally hate).
I use #__.
I use nil
I'm surprised cljfmt treats those commas as whitespace to be cleaned up in the first place - seems like an issue worth reporting
there was quite an extensive discussion on this a while back https://github.com/oakmac/standard-clojure-style-js/issues/60
Sometimes I find the useful inside function calls inside comments as well, like:
(call-f "that-takes-a-really-long-arg-like-a-literal-url-for-example-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc-etc"
#__)
In the IDE, it’s not comfortable hunting for the right hand bracket if you want to insert another arg, or things like this.
Same reason I always put parameter vectors on a new line:
;; Parameter vector doesn't dangle at an arbitrary place to the right, depending on function name
(defn very-very-very-very-very-very-very-very-very-descriptive-function-name
[a b])
;; Parameter vector is in the same place, regardless of presence of docstring or not
(defn short-name
[a b])
(defn short-name
"This function has a short name."
[a b])@qythium I posted a comment on that issue -- thanks for the heads up about it since I have not been following the standard-clojure-style-js project -- to note that the Clojure Style Guide got updated to call out comment as a special case where the closing paren should not be gathered.
I just checked and the last time a linter hassled me about this I used :end). But I just saw :-) at work and it's rocketed to the top of my rankings.
Yes, I like the smiley face, gonna go with that. Thanks for the tips everyone
cljfmt keeps it on the same line now