14

In clojure-mode emacs is indenting my semi colon comments with 5 tabs. Even if it is the first line in an empty file this occurs.

Eg just open up a clojure file, enter ; at the first character and press tab.

I'm using version 1.7.1

justinhj
  • 11,147
  • 11
  • 58
  • 104

1 Answers1

29

That's normal behavior. In your case you want two semicolons (;;).


From Tutorial on Good Lisp Programming Style by Peter Norvig (pdf) -- page 41:

Obey comment conventions:

  • ; for inline comment
  • ;; for in-function comment
  • ;;; for between-function comment
  • ;;;; for section header (for outline mode)

These comment tips are written for emacs lisp, but they are the same for all lisps: http://www.gnu.org/s/emacs/manual/html_node/elisp/Comment-Tips.html

(setq base-version-list                           ; there was a base
                (assoc (substring fn 0 start-vn)  ; version to which
                       file-version-assoc-list))  ; this looks like
                                                  ; a subversion
                                                  ;
                                                  ;
                                                  ;
                                                  ;    again, 
                                                  ;    this is inline comment


;; two semicolon comment
;; aligned to the same level of indentation as the code
koddo
  • 3,328
  • 2
  • 26
  • 25
  • 4
    Oh! That's fair enough. My Common Lisp mode never enforced this but I guess I should get into better habits. +1 for the link to that book – justinhj Dec 25 '10 at 23:33
  • 1
    Those column aligned comments would make programming in a variable width font really awkward. Are there any more modern competing styles? – pauldoo Feb 22 '11 at 22:02
  • 3
    @pauldoo You code in a variable width font? That must be terrible. – Didier A. Oct 20 '15 at 23:45