【发布时间】:2013-02-17 20:50:00
【问题描述】:
在 Python 的 PEP 8 样式指南中,建议内联 cmets 由 two spaces 分隔行的其余部分。但是,Emacs 中的默认设置是运行 comment-dwim 或 indent-for-comment 在行尾和注释之间只放置一个空格。有没有办法改变 emacs 中的这种默认行为?
我正在运行 Emacs 23.3.1
【问题讨论】:
标签: python emacs emacs23 dot-emacs
在 Python 的 PEP 8 样式指南中,建议内联 cmets 由 two spaces 分隔行的其余部分。但是,Emacs 中的默认设置是运行 comment-dwim 或 indent-for-comment 在行尾和注释之间只放置一个空格。有没有办法改变 emacs 中的这种默认行为?
我正在运行 Emacs 23.3.1
【问题讨论】:
标签: python emacs emacs23 dot-emacs
这应该做你想做的:
(add-hook 'python-mode-hook
(lambda () (set (make-local-variable 'comment-inline-offset) 2)))
【讨论】:
您可以通过C-h v RET comment-inline-offset查看emacs的文档,然后您将找到@And所说的答案。
这是一个简化版:
(add-hook 'python-mode-hook
(lambda () (setq-local comment-inline-offset 2)))
【讨论】:
尝试将comment-start 设置为" # "(前一个空格,后一个空格)。
M-x set-variable comment-start " # "
【讨论】:
comment-dwim,它会将内联注释重新对齐,使其只有一个空格。
我认为这可能会满足您的需求:
(defun my-comment-indent ()
(interactive)
(end-of-line)
(let ((comment-column (+ 2 (current-column))))
(comment-indent)))
【讨论】: