我正在为工作中使用的APL方言编写Emacs主模式。 我已经
基本字体锁定可以正常工作,并且在设置注释开始和
注释-开始-跳过,注释/取消注释区域并填充段落
工作。
但是,注释块通常包含javadoc样式的注释,而我
想要填充段落以避免将线条开始粘在一起
用这样的命令。
如果我有这个(\而不是javadoc @):
1 2 3 4
| # This is a comment that is long and should be wrapped.
# \\arg Description of argument
# \
et Description of return value |
M-q给我:
1 2 3 4 5
| # This is a comment that is long and
# should be wrapped. \\arg Description
# of argument \
et Description of
# return value |
但是我想要:
1 2 3 4 5
| # This is a comment that is long and
# should be wrapped.
# \\arg Description of argument
# \
et Description of return value |
我尝试将段落开始和段落分隔设置为
适当的值,但填充段落仍无法在
评论块。 如果删除注释标记,则M-q可以根据需要工作
,因此我用于段落开头的regexp似乎有效。
我是否需要为我的专业写一个自定义的填充段落
模式? cc-mode可以处理这种情况,但实际上
复杂,如果可能,我想避免这种情况。
问题在于,段落开头的regexp必须匹配包括实际注释字符在内的整行才能工作。 以下elisp适用于我给出的示例:
1
| (setq paragraph-start"^\\\\s-*\\\\#\\\\s-*\\\\\\\\\\\\(arg\\\\|ret\\\\).*$") |
这是一个具有用于php-mode的正则表达式示例的页面,该页面可以执行以下操作:
http://barelyenough.org/blog/2006/10/nicer-phpdoc-comments/
在这些情况下,我要做的是在段落行和参数行之间打开空白行,然后使用M-q包裹段落行,然后杀死它们之间的空白行。 这不是理想的方法,但是它可以正常工作,并且如果需要重复,很容易在宏中进行记录。
还有其他模式的fill-paragraph-function使用的功能不太复杂。 浏览我的安装,看起来像是ada-mode和make-mode的例子。