GNU emacs equivalent of func-menu

2019-04-26 15:44发布

问题:

Is there and equivalent of func-menu for GNU emacs? I used func-menu when I had access to xemacs and I prefer its behaviour to that of the speedbar or sr-speedbar. Specifically:

  • I like that only the functions for the current file are displayed.

  • The function list can be popped up from the current frame and isn't a separate window which I may have covered up.

  • The current function name shows up in mode line.

Is there a package for GNU emacs which is a closer approximation to func-menu?

回答1:

imenu would be the analogous feature in GNU Emacs.

See C-hf imenu-add-menubar-index RET.
You can call that in your mode hooks for modes with imenu support.

Naturally elisp is supported, so for a quick demo:

  • M-x find-library RET imenu RET
  • M-x imenu-add-menubar-index RET

and then see the new "Index" item in the menu bar, and also on C-<mouse3>

Of course there's also a keyboard interface, simply by calling M-x imenu RET (with TAB completion), but I would highly recommend adding the ido integration which can be found at the EmacsWiki* -- I find that to be a generally faster interface than using the mouse.

For more details, see C-hig (elisp) Imenu RET

For configuration, see M-x customize-group RET imenu RET

(*) Along with numerous other ways of enhancing the feature, so even if you don't want to use ido, you should definitely have a read through that Wiki page after you've seen the basic version in action.



回答2:

Is this the XEmacs func-menu mode you're talking about? It gives you a list of functions in the current file.

If so, then you can mostly replicate the functionality in GNU Emacs with the Collection of Emacs Development Tools, CEDET (specifically the Semantic code parser), and the Emacs Code Browser, ECB.

  • The ECB Methods window shows you all the symbols in the selected source code buffer. It is a separate window in the Emacs sense - that is, a editing area showing a single buffer, several of which can be within a single window-manager window. It is not a Emacs frame so it won't be covered up.
  • Semantic's stickyfunc-mode can show the current function in a line at the top of your source code buffer. It uses the GNU Emacs-specific header line feature. This is not quite the same as showing the function name in the mode line, but close enough.

Note that ECB requires CEDET and both tend to be tricky to install without XEmacs's package manager.



回答3:

I'm not sure, but I thought the "jump to a function within a buffer" was called fume-mode. If so, searching for an analog for fume-mode might help you zero in on what you are looking for.

Here is an excerpt from the XEmacs manual that mentions fume-mode:

"41. Jump to a Function Within a Buffer.

Suppose you have a file with a lot of functions in it. Well, this package makes it easy to jump to any of those functions. The names of the functions in the current buffer are automatically put into a menubar menu, you select one of the function-names and the point is moved to that very function. The mark is pushed on the mark-ring, so you can easily go back to where you were. Alternatively, you can use enter the name of the desired function via the minibuffer which offers completing read input. In addition, the name of the function before point is optionally displayed in the modeline.

The following modes are supported:

Ada, Assembly, BibTex, C++, C, Dired, Ehdm, ELisp, FORTRAN, Ksh, Latex, Lelisp, Makefile, Maple, Modula2, Modula3, Outline, Objective-C, Pascal, Perl, Postscript, Prolog, PVS, Python, SGML, Scheme, Tcl, Verilog, Manual, Ruby, JavaScript

To install this package, add the following to your initialization file:

(add-hook 'find-file-hooks 'fume-setup-buffer)

(add-hook 'Manual-mode-hook 'turn-on-fume-mode)"


标签: emacs gnu xemacs