Fork me on GitHub
#emacs
<
2021-03-21
>
agilecreativity20:03:28

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 ;

vemv01:03:48

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.

dotemacs09:03:05

There was this discussion about this a while back: https://github.com/clojure-emacs/clojure-mode/issues/516

practicalli-john09:03:07

;; 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
grazfather14:03:43

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

cgore15:03:05

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

👍 3
cgore15:03:11

So people comment correctly.

practicalli-john18:03:27

Cursive can be configured to use ;; for comments

ag05:03:52

> 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: https://stackoverflow.com/a/8825101/116395

cgore13:03:29

Also:

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

ag14:03:47

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

👍 3
cgore16:03:23

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

practicalli-john17:03:13

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

agilecreativity22:03:35

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.

cgore00:03:08

I view it as a teaching moment troll

cgore00:03:37

(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?

vemv17:04:59

Aside from https://github.com/bbatsov/clojure-style-guide/tree/d096eaadf63a7899cda1e5051597a99f1d51b10f#comments 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: https://www.gnu.org/software/emacs/manual/html_node/elisp/Comment-Tips.html

👍 6
cgore18:04:18

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

👍 3
cgore18:04:08

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