【问题标题】:Comment indenting seems messed up in clojure-modeclojure-mode 中的注释缩进似乎搞砸了
【发布时间】:2011-05-30 17:26:29
【问题描述】:

在 clojure-mode 中,emacs 将我的半冒号 cmets 缩进 5 个制表符。即使它是空文件中的第一行,也会发生这种情况。

例如,打开一个 clojure 文件,输入 ;在第一个字符处,然后按 Tab。

我使用的是 1.7.1 版

【问题讨论】:

    标签: emacs clojure tabs


    【解决方案1】:

    这是正常行为。在您的情况下,您需要两个分号 (;;)。


    来自Good Lisp Programming Style by Peter Norvig (pdf) 上的教程——第 41 页:

    遵守评论约定:

    • ;用于内联评论
    • ;;功能内评论
    • ;;;函数间注释
    • ;;;;用于节标题(用于大纲模式)

    这些注释提示是为 emacs lisp 编写的,但它们对所有 lisp 都是一样的:http://www.gnu.org/s/emacs/manual/html_node/elisp/Comment-Tips.html

    (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
                                                      ;
                                                      ;
                                                      ;
                                                      ;    again, 
                                                      ;    this is inline comment
    
    
    ;; two semicolon comment
    ;; aligned to the same level of indentation as the code
    

    【讨论】:

    • 哦!这很公平。我的 Common Lisp 模式从未强制执行此操作,但我想我应该养成更好的习惯。为该书的链接 +1
    • 那些列对齐的 cmets 会使可变宽度字体的编程变得非常尴尬。还有更现代的竞争风格吗?
    • @pauldoo 你用可变宽度字体编码?那一定很糟糕。
    猜你喜欢
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    相关资源
    最近更新 更多