ele*_*kil 3 emacs elisp cc-mode
我使用由一个安装一个C++程序员cc-mode和CEDET,当然还有我们敬爱的emacs(v24.2).
我缺少的一个功能是一个通过参数列表快速移动点的函数.考虑这个例子:
void takesManyArgs( int a1, int a2, int a3, std::pair<int,int> a4, int a5 ){
// does something nifty!
}
// [...]
takesManyArgs( b1, b2, b3, make_pair( b4, b5 ), b6 );
Run Code Online (Sandbox Code Playgroud)
点在第一个之前int.现在我想以一种简单的方法快速浏览参数列表,即在第一个非空格字符超过逗号(参数分隔符)之前移动的forward-argument(和backward-argumentaswell)函数.
我已经编写了一个小功能,但它不是我喜欢它的工作方式:
(defun arg-forward ()
"Move point forward in the file until we hit an argument separator, i.e. comma, colon or semicolon."
(interactive)
(progn
(re-search-forward "[,]")))
Run Code Online (Sandbox Code Playgroud)
原则上这个函数只是跳转到下一个逗号.那不是我想要的行为.
我想要一个功能:
,| int它看起来像, |int这里|的标记点) |int b3到|make_pair( int b4, int b5 )到|int a6地方|的标记点 任何帮助你elisp"黑客"表示赞赏!
编辑:添加了一些说明.
Edit2:修复了示例"代码"
此功能似乎按您的要求执行:
(defun arg-forward ()
"Move point forward until we hit an argument separator, the comma, colon, semicolon"
(interactive)
(condition-case nil
(let ((separator-regexp "[,:;]"))
(forward-sexp)
(while (not (or (looking-at (format "[ \t]*%s" separator-regexp))
(save-excursion (forward-char -1)
(looking-at (format "[]\"')}]*[ \t]*%s " separator-regexp)))))
(forward-sexp))
(if (looking-at separator-regexp)
(forward-char 1))
;; going forward one sexp and back puts point at front of sexp
;; essentially skipping the whitespace, but also ensuring we don't
;; jump out of a larger closing set of parentheses
(forward-sexp)
(forward-sexp -1))
(error
(beep)
(message "At end of argument list"))))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
98 次 |
| 最近记录: |