How can you make an emacs macro wait for cscope query results?
- by Sudhanshu
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.
This is the sequence of keystrokes:
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 only then continue further. 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 (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".