如何让emacs宏等待cscope查询结果?

时间:2010-05-31 21:28:07

标签: emacs macros elisp ctags cscope

我正在尝试编写一个宏,在cscope-find-functions-calling-this-function缓冲区(由*Tags List*命令创建)中显示的文件中的每个标记上调用list-tags这应创建一个缓冲区,其中包含调用某个文件中定义的一组函数的所有函数的列表。

我只是将该点放在 Tags List 缓冲区中第一个标记的开头,然后运行以下键盘宏来执行此操作。这是键盘宏中的击键序列:

1.  <f11>              ;; cscope-find-functions-calling-this-function                                                                                                           
2.  RET                ;; newline      [shows results of cscope in a split window]
3.  C-x C-p            ;; mark-page
4.  C-x C-x            ;; icicle-exchange-point-and-mark
5.  <up>               ;; previous-line
6.  <end>              ;; end-of-line             [region to copy has been marked]
7.  <f7>               ;; append-results-to-buffer
8.  C-x ESC O          ;;                 [move back to split window on the right]
9.  C-x b              ;; icicle-buffer        [Switch back to *Tags List* buffer]
10. *Tags              ;; self-insert-command * 5
11. SPC                ;; self-insert-command
12. List*              ;; self-insert-command * 5
13. RET                ;; newline
14 . <down>            ;; next-line       [Position point on next tag in the list]

问题: 我在缓冲区中没有得到任何结果,我发现这是因为步骤3-7甚至在之前执行 cscope打印在步骤1-2中进行的查询结果。

我可以使用C-x q在宏中插入一个暂停,但我更喜欢宏在步骤2之后等待,直到cscope返回结果然后自动继续。我怀疑这是不可能通过宏,也许是LISP功能......我自己不是一个lisp专家。有人可以帮忙吗?谢谢!


详细说明:

  • 我安装了Icicles 默认情况下,我在当前缓冲区中获取单词作为迷你缓冲区中的输入。
  • F11必然会 cscope-find-functions-calling-this-function
  • windmove已安装且C-x&lt; right&gt; (C-x ESC o - 如下图所示)带你去 右窗。
  • F7必然会 这是append-results-to-buffer 定义为:
(defun append-results-to-buffer ()
  (interactive)
  (append-to-buffer (get-buffer-create "c1") (point) (mark)))

此函数只是将当前标记的区域附加到名为“c1”的缓冲区。

1 个答案:

答案 0 :(得分:2)

CEDET套件在cedet-cscope.el中具有cscope支持,可同步调用cscope。您可以借用键盘宏从那里借一些东西。

或者,您可以使用CEDET的symref工具(semantic-symref-symbol)在CScope上进行繁重的工作。它也可以使用GNU Global或IDUtils。