【问题标题】:How to get Emacs fill-paragraph to work on inline XML code doc in my C# modules?如何让 Emacs 填充段落在我的 C# 模块中处理内联 XML 代码文档?
【发布时间】:2009-06-25 12:02:26
【问题描述】:

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

我有这样的cmets:

/// <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>

我希望填充段落只填充文本,并将标记元素保留在它们自己的单独行上,例如,

/// <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>

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

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

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

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


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

之后的行?

ps:我上面示例中的虚假代码文档来自Gutenberg copy of the US Declaration of Independence 上的马尔可夫链操作;感谢this question 提供的技术。

【问题讨论】:

    标签: c# .net emacs xml-documentation


    【解决方案1】:

    试试这个设置:

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

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

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

    (add-hook 'c-mode-common-hook '(lambda () (setq paragraph-separate "...")))
    

    【讨论】:

      猜你喜欢
      • 2010-10-07
      • 1970-01-01
      • 1970-01-01
      • 2014-11-13
      • 1970-01-01
      • 2018-05-27
      • 1970-01-01
      • 1970-01-01
      • 2011-04-10
      相关资源
      最近更新 更多