3

Emacs-lisp-mode distinguishes multiple kinds of comments.

  • ; is an "end of line" comment when following code, or a "right-margin" comment obeying comment-column when indented with indent-for-tab-command. This style is partcilularly useful for commenting on a code detail, since the indentation and alignment deemphasizes the comment.
  • ;; will be aligned with the indentation of surrounding code and is especially useful as a header of code sections or for longer comment text, where necessary.

I haven't seen this distinction in other modes; indent-for-comment (M-;) will happily indent to comment-column for end-of-line comments, but comments on their own line seem to be indented like ;;, not like ;.

Is there some way to make emacs allow ; style indentation also for other modes, such as shell-script-mode?

if [ $THIS_IS = $A_CODE_LINE ]; then
                           # I want to be able to comment
                           # on the right-side margin
    ## and inline with
    the code
fi
1
  • clojure-mode uses this feature, I think it is unique to linting in lisps. Commented Sep 24, 2019 at 14:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.