0

Given an elisp function or macro, does Emacs provide any way of finding callers?

Currently I'm just grepping in ~/.emacs.d for examples, but it's crude. Slime has slime-who-references but the excellent elisp-slime-nav doesn't seem to have an equivalent command.

  • Finding callers where? What context do you want to search? The problem is not defined sufficiently. – Drew Aug 3 '16 at 5:02
  • github.com/vapniks/simple-call-tree may be of interest – npostavs Aug 3 '16 at 12:25
  • @Drew ideally callers anywhere in the code loaded in my current Emacs instance. – Wilfred Hughes Aug 3 '16 at 14:09
  • load-history tells you what the explicitly loaded libraries are. You can search (grep or otherwise) those libraries. (But my crystal ball whispers to me that there is a question behind your question as posed. Why do you want to find all callers?) – Drew Aug 3 '16 at 14:47
  • @Drew: When looking at an unfamiliar function/macro, I want to see some examples of it being used. This helps me understand whether I'm using it correctly. – Wilfred Hughes Aug 3 '16 at 15:06
1

I don't believe it's even possible. Elisp has dynamic scope, any symbol can be rebound to anything (and it is being used and abused as you know.) So nothing is known statically.

I do the same, I mean grepping. I use silver-searcher and helm variations a lot around it, including helm-swoop to make the grepping more palatable, and I am always on a lookout for ways to improve it, but I guess at the fundamental level text/regexp search is what we have to deal with.

  • That's right. For example, I have calls to a number of built ins in my init file. How is anything you run on your machine going to know that? – MAP Aug 3 '16 at 5:07
  • Increasing elisp packages are using lexical scope. A simple implementation that called read would be smarter than grepping though, as it wouldn't confuse foo-bar with foo, or strings/comments. – Wilfred Hughes Aug 3 '16 at 14:13
  • 1
0

I've written a package that does this! refs.el, semantic search for elisp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.