3
,我有以下:折叠在emacs的多线的评论在我的.emacs配置自动
(defun fold-long-comment-lines()
"This functions allows us to fold long comment lines
automatically in programming modes. Quite handy."
(auto-fill-mode 1)
(set (make-local-variable 'fill-no-break-predicate)
(lambda()
(not (eq (get-text-property (point) 'face)
'font-lock-comment-face)))))
上述被调用作为“C-模式共有钩”部分和正确地折叠提供长评论行自动。
然而,上述的东西无差别地工作,无论我是否使用单行注释描述结构字段,或描述一些复杂代码的多行注释。
所以,基本的问题是,如何才能自动折叠长评论行,只有当它是一个多行评论?
感谢 阿努邦
编辑-1:多行注释解释 当我说 “多行注释”,这基本上意味着评论是这样的:
/*
* this following piece of code does something totally funky with client
* state, but it is ok.
*/
code follows
相应,单行注释会是这样的
struct foo {
char buf_state : 3; // client protocol state
char buf_value : 5; // some value
}
上面的elisp代码,尽职尽责地折叠这两个注释行。我只想折叠前者,而不是后者。