Lisp has a more complex convention for comments than most languages, and automatic formatting respects this convention. It is documented in appendix D.7 Tips on Writing Comments of the Elisp manual (which is also available inside of Emacs itself, use C-h i
to open the Info viewer).
In a nutshell, comments that start with just a ;
are formatted like marginal notes in a book; they go at the ends of the lines where the right–hand margin would be. Use ;;
for comments that are meant to be indented in a way similar to code; this puts the comments at the left–hand margin when they’re not inside a function or other type of top–level item. You can use ;;;
and ;;;;
for headings to divide your documentation or code up into sections and chapters.