7

I have been using a little-known editor called "FTE" (or eFTE) for years; it has a nice utility that can display the list of the subroutines/functions/classes (or any such thing--depending on what regexp you define in its configuration file) in a source text file (C, C++, Fortran, ... what have you). This function allows me to jump quickly from one point to another in a source file. Perhaps the original shortcut in FTE is ^I (Control+I). Does emacs have a similar functionality? Emacs is much more advanced than FTE and I would be surprised if no one ever developed such a facility.

Thanks, Wirawan

5 Answers5

12

Try M-x occur RET exp RET - this lists in a new buffer all the occurrences of the exp in the current buffer.

Dror
  • 1,928
9

Most people of course will tell you to just use a modern IDE but they don't understand the power of emacs. Personally, I use ECB which makes my emacs look like this:

enter image description here

The middle window on the left hand side is the list of functions of the current source file. Middle clicking the name moves the cursor to that function's definition.

To install, follow the instructions on the ECB website to install ECB and then add this line to your ~/.emacs (changing the location accordingly):

(add-to-list 'load-path
             "~/.emacs-lisp/ecb/")

Another option is CEDET but I have not used it.

terdon
  • 54,564
7

Use Imenu:

  1. M-X imenu
  2. tab, All.Methods
  3. tab to see all methods
cweiske
  • 2,191
2

You said "display the list of the subroutines/functions/classes (or any such thing--depending on what regexp you define in its configuration file) in a source text file". Ignoring the part in parens for the moment, to which others have responded, it's not clear what you mean by a function etc. being "in" a source file.

If you are asking about seeing a list of the functions etc. that are defined in a given source file, and then navigating among their definitions, then look at Imenu in Emacs. See the Emacs manual, node Imenu. See also this EmacsWiki page about Imenu:

bep
  • 3
Drew
  • 2,144
1

Emacs has a couple of ways to obtain this functionality.

The lighter-weight method is by means of tags, which with suitable customization can serve most purposes. Once you've built a tags file (which is done in a shell, via e.g. cd /path/to/project; ctags -e -R .) and selected it via M-x visit-tags-table RET /path/to/TAGS RET, you can, for example, use M-. on a function call to jump to the function definition, M-x tags-search to grep your way through the files described in the tags table, &c. See the linked page for a fairly thorough description of the tools available.

The heavier-weight method is by means of Semantic, a lexer/parser combination implemented entirely in Emacs Lisp. While I'm not as familiar with Semantic as with tags, the impression I get is that Semantic incurs a heavier initial setup burden, in exchange for a more generally useful result. In addition to the linked manual page, (the Emacs Wiki article)[http://www.emacswiki.org/emacs/SemanticBovinator] may be of additional help here.

Aaron Miller
  • 10,087