Emacs隐藏/显示支持C ++三斜线Doxygen标记? [英] Emacs hide/show support for C++ triple-slash Doxygen markup?

查看:146
本文介绍了Emacs隐藏/显示支持C ++三斜线Doxygen标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Doxygen的三斜杠语法来标记我的C ++代码。有
两个重要的情况出现:

I use Doxygen's triple-slash syntax to markup my C++ code. There are two important cases which arise:

1)块标记注释是行上唯一的元素,可能
或可能不开始冲洗左;例如

1) block markup comments which are the sole element on the line and may or may not begin flush left; e.g.

class foo
/// A one sentence brief description of foo.  The elaboration can
/// continue on for many lines.
{
    ...
};

void foo::bar
    /// A one sentence brief description of bar.  The elaboration can
    /// continue on for many lines.
    () const
{
    ...
}

2)尾随标记注释总是跟在第一行前面的一些数量的C ++
令牌,但仍然可以溢出到
后续行;例如

2) trailing markup comments which always follow some number of C++ tokens earlier on the first line but may still spill over onto subsequent lines; e.g.

class foo
{
    int  _var1;                 ///< A brief description of _var1.
    int  _var2;                 ///< A brief description of _var2
                                ///< requiring additional lines.
}

void foo::bar
    ( int arg1                  ///< A brief description of arg1.
    , int arg2                  ///< A brief description of arg2
                                ///< requiring additional lines.
    ) const
{
    ...
}

我不知道存在什么隐藏/显示支持来处理这些约定。
最重要的例子是块标记注释。理想情况下,我会
喜欢能够消除这些完全,意味着我会
不喜欢浪费一行简单地表示存在折叠的
块标记注释,喜欢边缘标记, a la hideshowvis.el

I wonder what hide/show support exists to deal with these conventions. The most important cases are the block markup comments. Ideally I would like to be able to eliminate these altogether, meaning that I would prefer not to waste a line simply to indicate presence of a folded block markup comment, preferring a fringe marker, a la hideshowvis.el.

推荐答案

也许,作为部分答案下面的代码片段会做的伎俩。
在C ++模式中按M-s M-s,它隐藏所有类型的注释。再次按M-s M-s再次显示注释。我知道短代码有它的局限性:

Maybe, as a partial answer the following snippet of code would do the trick. Press M-s M-s in C++-mode and it hides all comments of the kind you described. Again pressing M-s M-s reveals the comments again. I know that the short code has its limitations:


  1. 如果可以单独隐藏/显示每个特殊注释,这将是很好的。

  1. It would be nice if one could hide/show each special comment separately.

由于所有特别评论都被隐藏,因此您经常需要Ms女士。因此, hs1-mode 应该对大型C ++文件更有效(也许,应该通过 jit-font-lock )。

Since all special comments are hidden you would need M-s M-s quite often. Therefore, hs1-mode should be more effective on large C++-files (maybe, it should be implmented via jit-font-lock).

特殊注释的连续行应连接到一个隐藏块。

Consecutive lines of special comments should be joined to one hidden block.







(defvar hs1-regexp
  "\\(\n[[:blank:]]*///\\|///<\\).*$"
  "List of regular expressions of blocks to be hidden.")

(define-minor-mode hs1-mode
  "Hide/show predefined blocks."
  :lighter " hs1"
  (if hs1-mode
      (let (ol)
    (save-excursion
      (goto-char (point-min))
      (while (search-forward-regexp hs1-regexp nil 'noErr)
        (when (eq (syntax-ppss-context (syntax-ppss (match-end 1))) 'comment)
          (setq ol (make-overlay (match-beginning 0) (match-end 0)))
          (overlay-put ol 'hs1 t)
          (overlay-put ol 'invisible t)
          ))))
    (remove-overlays (point-min) (point-max) 'hs1 t)
    ))

(add-hook 'c++-mode-hook '(lambda () (local-set-key (kbd "M-s M-s") 'hs1-mode)))

这篇关于Emacs隐藏/显示支持C ++三斜线Doxygen标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆