views:

42

answers:

1

I am trying to write a macro which calls cscope-find-functions-calling-this-function on each and every tag in a file displayed in the *Tags List* buffer (created by list-tags command). This should create a buffer which contains list of all functions calling a set of functions defined in a certain file.

I just position the point at the start of the first tag in the Tags List buffer and then run the following keyboard macro to do this. This is the sequence of keystrokes in the keyboard-macro:

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]

Problem: I get no results in the buffer, and I found out that's because Step 3-7 execute even before cscope prints the results of query made on Steps 1-2.

I can insert a pause in the macro by using C-x q, but I'd rather like the macro to wait after Step 2, until cscope has returned with the results and then continue further automatically. I suspect this is not possible through a macro, maybe a LISP function... I'm not a lisp expert myself. Can someone please help? Thanks!


Details:

  • I have Icicles installed so by default I get word at point in current buffer as input in minibuffer.
  • F11 is bound to cscope-find-functions-calling-this-function
  • windmove is installed and C-x <right> (C-x ESC o - as shown below) takes you to the right window.
  • F7 is bound to append-results-to-buffer which is defined as:
(defun append-results-to-buffer ()
  (interactive)
  (append-to-buffer (get-buffer-create "c1") (point) (mark)))

This function just appends the currently marked region to a buffer named "c1".

+1  A: 

The CEDET Suite has cscope support in cedet-cscope.el which calls to cscope synchronously. You can probably borrow something from there to use from your keyboard macro.

Alternately, you could use CEDET's symref tool (semantic-symref-symbol) to do the heavy lifting on top of CScope. It can also use GNU Global, or IDUtils.

Eric
Thanks for the tip Eric! I guess I need to do some digging around. Good thing is I'm loving this whole LISP business.
Sudhanshu