2

New Emacs user here. Hitting enter after a semicolon commented line in any file type (.el and .lisp at the very least) indents the comment in a very unhelpful way that I have to assume is not intended behavior. This problem does not occur if I move away from that comment line in any way besides hitting return (triggering auto-indent presumably).

For example, If I type the following

; this is a comment

Then hit return, I get the following (32 spaces indentation)

                                ; this is a comment

What is causing this behavior, and how can I prevent it?

I am running Emacs 26.3.0.20191219 installed through Chocolatey on Windows 10

  • 1
    Use two semicolons. – NickD Jul 22 at 19:24
4

Unable to post this as a comment, but the indentation is likely part of one of the active modes (probably lisp-mode based on your description). You can do M+x describe-modes to see which modes are active.

This answer provides some background on the history of the common lisp commenting style https://stackoverflow.com/a/6365579

This question and answers describe why the single ; indents differently than multiple consecutive ; characters: https://stackoverflow.com/questions/14190488/set-comments-at-the-same-indentation-level-as-all-forms, namely that lisp-indent-line hardcodes it with the following comment

          ;; Single-semicolon comment lines should be indented
          ;; as comment lines, not as code.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.