21
votes

I'd like to quickly move point to a function in my Emacs buffer. I'd like to run some function and get a prompt asking me for the function name, with completion provided for every function defined in the current buffer.

I generally use etags to navigate around, but sometimes I'm looking for a framework method that's been overridden in several files. In these cases, I can find the file I need but then I'd like to quickly jump to the function there. There is a similar feature in TextMate where you can select a definition from a list in the bottom right of the editor.

8

8 Answers

36
votes

Just to jump around functions in the current file? Use imenu. It's the simplest and lightest of all the alternatives listed so far and might be enough for what you want. It's also built into Emacs and has minimum setup hassle. It features graphical and textual interfaces. Anything extra and you'll be better off using one of the other excellent suggestions made here.

2
votes

speedbar comes standard, and gives you a collapsible menu for each file in the current directory, by default middle clicking on an entry for a function definition jumps to that def. With emacs23 this was changed to the more normal leftclick.

2
votes

You can use etags-select to select from multiple matching tags. But the answer to what you asked is imenu.

0
votes

Icicles is probably closer to what you are looking for:

http://www.emacswiki.org/emacs/Icicles_-_Tags_Enhancements

It's an enhancement to etags and includes (among other things) the file name with the tag so you can tell if it's the one you are looking for.

0
votes

try CEDET. It is a bit difficult to set up the first, but here is an excellent tutorial: by Alex ott

And when he gets installed, you can use semantic-complete-jump. pressed tab couple times, and it is also brings up symbol definitions.

0
votes

If M-. brings up the wrong method, you can type C-u M-. to find the next one with the same name.

0
votes

global gtags is very good

0
votes

To navigate within the current file or a set of files that you select, you do not need a TAGS file. You can use Imenu. But it is better to use Icicles imenu commands.

Why? Because they let you use completion. Substring, regexp, prefix, or fuzzy completion. Combine simple patterns to match, or subtract them.

Command icicle-imenu is bound in Icicle mode to C-c =. Butyou can also look up just a command or just a non-command function (non-interactive), using command icicle-imenu-command or icicle-imenu-non-interactive-function.

These commands are multi-commands, meaning that they are actually browsers: you can trip among function definitions using keys C-RET or C-mouse-2 (direct jumps) and C-down (cycle). Hit RET or click mouse-2 to settle down at a final destination.