[英]Emacs mode multiline comments
What's the correct method for defining multi-line comments in an emacs mode (like C's /* */)? 在emacs模式中定义多行注释的正确方法是什么(如C的/ * * /)? The elisp examples I see are for comments that start with a single delimiter and end at the end of the line (like C++'s // or perl's #). 我看到的elisp示例是用于以单个分隔符开头并以行尾结束的注释(如C ++的//或perl的#)。
It's like this: 就像这样:
(define-derived-mode my-mode
awk-mode "my"
"My mode"
(setq comment-multi-line nil) ; maybe
(setq comment-start "/* ")
(setq comment-end "*/"))
But there are subtleties; 但有一些微妙之处; maybe you want 也许你想要
/* line one */
/* line two */
/* line three */
or maybe you want 或许你想要
/*
line one
line two
line three
*/
This is affected by your comment-style
, which you can customize ( Mx customize-variable comment-style
). 这是由您的影响comment-style
,您可以自定义( Mx customize-variable comment-style
)。 For something like the first example choose indent
, for the second example, extra-line
. 对于类似于第一个示例的内容,请选择indent
,对于第二个示例,请选择extra-line
。
It's all defined in newcomment.el
, which you can read about if you Mx describe-variable comment-start
. 它全部在newcomment.el
定义,如果您使用Mx describe-variable comment-start
,您可以阅读它。
Tom's answer covers creating comments; 汤姆的回答包括创建评论; if you want your mode to be aware of comments, you need to fixup the syntax table. 如果您希望模式知道注释,则需要修复语法表。
Relevant reading: 相关阅读:
http://www.gnu.org/software/emacs/elisp/html_node/Syntax-Tables.html#Syntax-Tables http://www.gnu.org/software/emacs/elisp/html_node/Syntax-Tables.html#Syntax-Tables
This is an excellent guide for adding comment goo to an emacs mode. 这是将注释goo添加到emacs模式的绝佳指南。 http://xahlee.org/emacs/elisp_comment_handling.html http://xahlee.org/emacs/elisp_comment_handling.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.