Fork me on GitHub

I am trying to prevent the comment in Clojure code that starts with single ; to be align to the right. Is there a way to customize this in Emacs? e.g. I would love to get the same result when commenting the Clojure/Lisp code ;; and ;


there isn't a way (without major hacking) although there's some desire from the clojure-emacs people to implement it As of today, IMO the right approach is to avoid ;. Under Lisp/emacs tradition ; has a very specific meaning, but 99% of Clojure developers don't know about it, or decide to disregard it. So it is counterproductive to use it, given that emacs will apply assumptions that don't match our reality.


There was this discussion about this a while back:


;; is the recommended line comment for Clojure, please consider using this style. Clojure aware editors typically have a key binding that comments using this style (or are easily configured to do so)

➕ 6

I was wondering why my editor kept changing my comments to two ;


As someone who came from Common Lisp, I'd instead rather implement the Emacs behavior in IntelliJ 😄

👍 3

So people comment correctly.


Cursive can be configured to use ;; for comments


> is the recommended line comment for Clojure There are line comments and "end of line comments". They are not the same thing. This SO post illustrates the difference perfectly:



;;; Let's talk about this block of code below ...
And also:
;;;; Big huge section commentary, like a file header or something


For the "Big huge section commentary, like a file header or something", there's M-x comment-box

👍 3

How do you make IntelliJ do that anyway? Asking for a friend who for some reason doesn't use Emacs 🙂


@U06DP0SAV In the IntelliJ settings: Editor-&gt;General-&gt;Smart Keys-&gt;Clojure-&gt;Use ;; for line comments


I always use ;; for my parts, but when I have to contribute to some project and they are using the ; then my Emacs always pushed it to the right and I hate to introduce these changes when possible.


I view it as a teaching moment troll


(Actually sadly no, I just silently tweak the comment blocks in my PR.)

Ben Sless11:04:00

@U45T93RA6 can you shed some light on the special meaning attached to ; ? Is there anything to it besides margin comment?


Aside from I'd add the observation (not hinted in that link?) that margin comments can span multiple lines. I'd say Emacs is optimized for multi-line margin comments, which is why a single-line margin comment can be auto-aligned in an odd-looking position (which in the context of a multi-line comment, would be less odd) Another good read:

👍 6

What that Emacs link says matches my memory from Common Lisp.

👍 3

I think that must have been a convention in Lisp for quite a few decades, no idea how long.