Emacs模式多行注释

标签 emacs elisp

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

最佳答案

就像这样:

(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,则可以阅读。

关于Emacs模式多行注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/499206/

相关文章:

emacs - 我应该为 emacs 使用什么包管理器?

macos - <tab> v. Emacs 中的 TAB

regex - Emacs 在每个单词周围添加引号

emacs - 为什么我以这种方式启动 iswitchb-mode?

emacs - 如何在Dired模式下隐藏一个点(当前目录)

emacs - 广告激活有什么作用?

emacs - (function) 在 Emacs 中有什么用途吗?

emacs - 如何避免意外杀死emacs中的文本?

emacs - 什么是查找 emacs 函数名称和击键的好的 in-emacs 过程

c# - CSharpRepl emacs 集成?