I'd like to browse source code in emacs by searching for 'word' or 'tag' hits in a way somewhat similar to etags but:
- clicking on words to search for matches across a code base (say a directory or project)
- each click leads to a search hits listing view that itself has words that can be clicked to search again
To be more specific: Here's a program that works similarly to what I would like to use in emacs -- it's a small web application in Python:
https://github.com/mseaborn/sbrowse
There are basically two views, which might perhaps map onto emacs something like this:
web view -> emacs 'view'
------------------------
source code -> a regular editing buffer with appropriate mode (say python-mode)
hits listing -> something like compilation-mode
In the source code view, one can click on a 'word' to jump to the hits listing.
The hits listing looks like the inline block below (here I've shown what you'd see on searching for 'spam'
path/to/file.py:
104: ham = spam()
123: # Some more spam
path/to/other/file.py
98: ham *= spam ** 2
From here one might:
- Click on 'ham' or 'Some' and get a similar listing for that word
- Click on a line number ('98:') to jump to a source code view that shows the hit in context
- Click on a file path is a link to jump to the top of the corresponding source code view
Usually the search is done by simple grepping for words based on regexp word boundaries or similar. One other feature of sbrowse that is nice, though, is that it has pluggable search implementations. For example, I would like to be able to implement an elisp function or unix command to search using https://github.com/google/codesearch, so that clicks in both views perform the search using that program.
Is there anything available like this in the emacs universe?
M-x xref-find-references
.