【问题标题】:Emacs mode multiline commentsEmacs 模式多行注释
【发布时间】:2011-06-29 03:49:16
【问题描述】:

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

【问题讨论】:

    标签: emacs elisp


    【解决方案1】:

    是这样的:

    (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】:

      Tom 的回答包括创建 cmets;如果你想让你的模式知道 cmets,你需要修复语法表。

      相关阅读:

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

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 2012-08-11
          • 2011-06-22
          • 1970-01-01
          • 2017-04-28
          • 2014-05-24
          • 2011-09-30
          • 1970-01-01
          • 1970-01-01
          • 2013-12-01
          相关资源
          最近更新 更多