如何禁用 Emacs 自动向右移动命令?

How to disable Emacs auto moving command to right?

我在 Windows 7 上使用最新版本的 Emacs。假设我在 .emacs 中键入以下代码:

;test|

|表示光标位置。现在,如果我按 Enter,文本将向右移动,看起来像:

                                                      ;test

如何禁用此功能?

这是按照Emacs Lisp style guide:

Comments that start with a single semicolon, ';', should all be aligned to the same column on the right of the source code. Such comments usually explain how the code on that line does its job. For example:

(setq base-version-list                 ; There was a base
      (assoc (substring fn 0 start-vn)  ; version to which
             file-version-assoc-list))  ; this looks like
                                        ; a subversion.

如果您使用两个或更多分号,您将看到其他行为:

Comments that start with two semicolons, ';;', should be aligned to the same level of indentation as the code. Such comments usually describe the purpose of the following lines or the state of the program at that point.

...

Comments that start with three semicolons, ';;;', should start at the left margin. We use them for comments which should be considered a “heading” by Outline minor mode.

...

Comments that start with four semicolons, ';;;;', should be aligned to the left margin and are used for headings of major sections of a program.

自动缩进由electric-indent-mode完成。如果您希望完全禁用它,请输入

(electric-indent-mode -1)

在你的初始文件中。您也可以使用

之类的东西在特定模式下禁用它
(electric-indent-local-mode -1)

在适当的初始化挂钩中。

按照风格指南的建议简单地使用两个分号也应该可以防止这种行为,这将使您受益于 electric-indent-mode 其他代码。