10

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

4

3 回答 3

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.

于 2009-01-31T17:42:01.670 回答
3

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

相关阅读:

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

于 2009-02-01T01:01:22.360 回答
3

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

于 2011-06-28T19:49:16.523 回答