1

这个问题类似于Getting Emacs fill-paragraph to play nice with javadoc-like comments,但适用于 C#。

我有这样的评论:

/// <summary>
/// Of these Colonies, and ought to fall themselves by sending a 
/// constant state of THE unanimous 
/// Declaration OF Nature and donations are legally 1.E.1.
/// </summary>
///
/// <remarks>
/// <para>
/// If you received written explanation to the phrase "Project Gutenberg" associated 
/// with which you are redistributing 
/// Project GUTENBERG you receive specific permission.
/// </para>
/// </remarks>

我希望 fill-paragraph仅填充 text,并将标记元素保留在它们自己的单独行上,例如,

/// <summary>
/// Of these Colonies, and ought to fall themselves by 
/// sending a constant state of THE unanimous Declaration 
/// OF Nature and donations are legally 1.E.1.
/// </summary>
///
/// <remarks>
/// <para>
/// If you received written explanation to the phrase 
/// "Project Gutenberg" associated with which you are 
/// redistributing Project GUTENBERG you receive specific 
/// permission.
/// </para>
/// </remarks>

我认为我需要设置段落开始变量。Ch v 告诉我它的当前值是:

"[  ]*\\(//+\\|\\**\\)[     ]*\\(@[a-zA-Z]+\\>\\|$\\)\\|^\f"

...这已经看起来很毛茸茸了。(我讨厌 emacs 正则表达式的所有转义 reqd。)我想我需要回顾一下XML doc 元素(如 <remarks>)之后的第一行开始一个段落。

我现在要搞砸了,但是有没有人设置它来做内联代码文档?


编辑:哎呀!Emacs 正则表达式不会向后看!好的,还有其他建议吗?如何将段落的开头设置为 <summary> 或 <para> 之后的行?

ps:我上面示例中的假代码文档来自对美国独立宣言的古腾堡副本的马尔可夫链操作;感谢这个问题的技术。

4

1 回答 1

2

试试这个设置:

(setq paragraph-separate "[     ]*\\(//+\\|\\**\\)\\([  ]*\\| <.*>\\)$\\|^\f")

这告诉 fill-paragraph 是什么分隔了段落,我对其进行了自定义以包含一个空格和一对匹配的尖括号。这可能会让你得到你想要的。它适用于您提供的示例。

当然,您必须在其中一个 c 模式挂钩中设置该变量,例如:

(add-hook 'c-mode-common-hook '(lambda () (setq paragraph-separate "...")))
于 2009-06-25T04:02:26.643 回答