代码之家  ›  专栏  ›  技术社区  ›  David Nehme

Emacs模式多行注释

  •  9
  • David Nehme  · 技术社区  · 16 年前

    在emacs模式下定义多行注释的正确方法是什么 (像C的/**/)?我看到的elisp示例用于以单个分隔符开头并在行尾结束的注释(如C++的//或perl的#)。

    3 回复  |  直到 16 年前
        1
  •  16
  •   Tom Dunham    16 年前

    是这样的:

    (define-derived-mode my-mode
        awk-mode "my"
        "My mode"
      (setq comment-multi-line nil) ; maybe
      (setq comment-start "/* ")
      (setq comment-end "*/"))
    

    但也有微妙之处;也许你想要

    /*  line one   */
    /*  line two   */
    /*  line three */
    

    或者你想

    /*  
        line one
        line two
        line three
    */
    

    comment-style ,您可以自定义( M-x customize-variable comment-style ).对于第一个示例,请选择 indent ,第二个例子, extra-line

    这都是在 newcomment.el ,如果您愿意,您可以阅读 M-x describe-variable comment-start .

        2
  •  3
  •   jrockway    16 年前

    汤姆的回答包括创造评论;如果你想让你的模式知道注释,你需要修改语法表。

    http://www.gnu.org/software/emacs/elisp/html_node/Syntax-Tables.html#Syntax-Tables

        3
  •  3
  •   josefwells    13 年前

    这是向emacs模式添加注释goo的极好指南。 http://xahlee.org/emacs/elisp_comment_handling.html