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

Emacs Asked on November 30, 2021

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.


Answered by einfeyn496 on November 30, 2021

## 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

### How to programmatically surround a string with escaped double-quote

1  Asked on September 2, 2021 by lawlist

### Tramp session fails to recover from inactivity

2  Asked on September 2, 2021 by bignose

### Make pdf-tools remember the page I was on

1  Asked on September 2, 2021

### Switch from Dired to Wdired rename file and directory errors when using “-F” or “–classify” ls switch regex help

1  Asked on September 2, 2021 by j-spen

### 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

### Emacs keybindings / invocation for Apple iMac keyboard, similar to LMI or Knight?

1  Asked on September 2, 2021

### How to Redefine Meta Key to Use Esc Key Only and Allow Using Alt Key for Another Purpose

2  Asked on September 2, 2021 by vikram

### 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

### Can magit stage a hunk / selected lines in ‘diff-mode’?

1  Asked on September 2, 2021

### Properly exporting latex to HTML from org-mode using dvisvgm / dvipng

1  Asked on September 2, 2021 by nilaksh-singh

### How do I make emacs indent relative to the beginning of the previous line?

1  Asked on September 2, 2021 by x-yuri

### gnus: fetch mails over IMAP from Outlook mail server

1  Asked on September 2, 2021

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

0  Asked on September 2, 2021 by brian-postow

### How to display list of previous copies/kills (M-w or C-w)?

3  Asked on September 2, 2021 by erwann

### Fixed length buffer for shell

1  Asked on September 2, 2021

### How to overwrite by pasting a string without selecting a region?

1  Asked on September 2, 2021 by starquake