开发者

In Emacs, how can I jump between functions in the current file?

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 Text开发者_开发技巧Mate where you can select a definition from a list in the bottom right of the editor.


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.


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.


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


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.


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.


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


global gtags is very good


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.


I use C-M-a and C-M-e to jump between the beginning and end of functions.

Otherwise, open up Speedbar and click the + icon next to a file name to view a list of functions contained in the file. Then click on the function names to jump to them directly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜