Emacs auto-indenting comments in an unhelpful manner

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 installed through Chocolatey on Windows 10

Emacs Asked on November 30, 2021

1 Answers

One Answer

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

This question and answers describe why the single ; indents differently than multiple consecutive ; characters:, namely that lisp-indent-line hardcodes it with the following comment

          ;; Single-semicolon comment lines should be indented
          ;; as comment lines, not as code.

Answered by einfeyn496 on November 30, 2021

Add your own answers!

Related Questions

Can I take vector (SVG) screenshots of Emacs?

2  Asked on September 2, 2021 by clment


tramp and sudo: how to edit files under another account

3  Asked on September 2, 2021 by daniel-wu


Tramp session fails to recover from inactivity

2  Asked on September 2, 2021 by bignose


How company-mode suggestions are delivered?

1  Asked on September 2, 2021 by seonghyun-park


How to set utf-8 encoding for *markdown-output* buffer?

1  Asked on September 2, 2021 by volodymyr


Bind keybord shortcuts to a MIDI keyboard?

1  Asked on September 2, 2021 by gabriele-nicolardi


How to wrap lines at window edge

2  Asked on September 2, 2021 by lambda-pumpkin


C-h v gives ” Symbol’s value as variable is void: default

0  Asked on September 2, 2021 by brian-postow


Fixed length buffer for shell

1  Asked on September 2, 2021


Ask a Question

Get help from others!

© 2022 All rights reserved.