emacs - 将注释设置为与所有表单相同的缩进级别

标签 emacs elisp indentation

默认情况下,注释的缩进级别对我来说似乎很陌生。

(defun example ()
  just
  some
                ; a comment
  words)

如何调整它使第一个分号与常规 Lisp 形式垂直对齐?
(defun example ()
  just
  some
  ; a comment
  words)

我能发现的是,默认机制的工作原理是将注释与固定列对齐(可通过 M-x comment-set-column 查询),并且可以修改 comment-indent-function变量(将其设置为 nil 部分解决了我的问题)。

最佳答案

Emacs 根据使用的分号数量对 elisp 中的注释进行不同的缩进。如果你使用两个,你应该得到你想要的缩进:

(defun test-single ()
                                        ; A single semicolon
  nil)

(defun test-double ()
  ;; Do two semicolons make a colon ;)
  nil)

另外,三个分号;;;根本没有重新缩进。通常,它们用于标记源文件中的新主要部分。

关于emacs - 将注释设置为与所有表单相同的缩进级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14190488/

相关文章:

在 Haskell 的 Parsec 中解析基于缩进的语法

python - 使用 JSON 模块进行 pretty-print 时如何实现自定义缩进?

Emacs、GDB 和多个 X 窗口

emacs - 使用 emacs 为文本着色显示

ruby - Tab 键在 Emacs ruby​​ 模式下不起作用

emacs - 优化 key-chord.el 触发

emacs - 分析 Emacs Lisp 行为不当的技巧?

python - Python中的条件语句

emacs - 组织模式 : describe a chess position and automatically generate image of chessboard

Emacs - 如何将kill更改为删除?