tags:

views:

106

answers:

3

Hello,

GNU Emacs 23.1.1

I am just wondering is there any feature in emacs where I can find out what functions call a specific function.

In my code, I normally have to do a search on the function name to see what functions calls it.

It would be nice if I could display all the names of the functions where this specific function is being called from.

many thanks for any suggestions,

A: 

I use xcscope for this. It's a library that makes Emacs interact with the external cscope tool.

After setup, you can use cscope-find-functions-calling-this-function to get a list of source code destinations that call a certain function.

http://www-inst.eecs.berkeley.edu/~cs186/fa05/debugging/xcscope.el http://www.emacswiki.org/emacs/CScopeAndEmacs

mmmasterluke
+3  A: 

You can use semantic-symref function from CEDET package. It can use GNU Global or CTags databases (if they exists) to find callers, or could parse sources to find occuriences

Alex Ott
+1  A: 

here is a snippet from my old .emacs file

it does: ask for thing to find from etags-tagfile (find-tag-tag) grep for it according to mode

(defun find-caller (tagname)
  "Find occurences of tagname in files in the current directory
matching extension of current file."
  (interactive (list (find-tag-tag "Find caller: ")))
  (let ((cmd "grep -n "))
    (cond
     ((member major-mode '(lisp-mode cmulisp-mode))
      (grep (concat cmd "-i '" tagname "' *.lisp")))
     ((eq major-mode 'c-mode)
      (grep (concat cmd "'" tagname "' *.[ch]")))
     ((member major-mode '(latex-mode tex-mode))
      (grep (concat cmd "-i '" tagname "' *.tex")))
     ((eq major-mode 'emacs-lisp-mode)
      (grep (concat cmd "'" tagname "' *.el")))
     (t (grep (concat cmd "'" tagname "' *"))))))
Peter Miehle
just FYI: CEDET can use grep to find callers
Alex Ott