55

I tried to edit my init file. Is there any possible way to quickly jump into function definition of other .el file that has already loaded/required ?

I remember doing this once, but don't remember how...

4 Answers 4

64

M-x find-function RET (function name) RET

I find that C-h C-f makes a good keybinding for find-function (given that C-h f is bound by default to describe-function)

(global-set-key (kbd "C-h C-f") 'find-function)

Sign up to request clarification or add additional context in comments.

5 Comments

This only works for functions that have been loaded, or one that is set up for auto loading.
Indeed, but it seemed like the best answer given that the question was specifically about loaded elisp functions, and it doesn't require the extra step of generating a TAGS file.
I just had this exact question, thanks much. I also discovered that there's also find-function-at-point (in emacs 23, at least). I bound this to C-h C-f and it works great!
Some similarly useful functions are: find-function-on-key, find-variable, and find-library.
If you don't want to have this as a global hotkey, but in emacs-lisp major modes only: (add-hook 'emacs-lisp-mode-hook (lambda () (local-set-key (kbd "M-.") 'find-function-at-point)))
10

As of emacs-25.1, there's a new generic function xref-find-definitions. The xref built-in package provides a generic framework for navigating definitions in code. Probably, it'd take some time for every mode to adjust custom functions for this framework, but, at the very least, emacs-lisp-mode already ported.

3 Comments

Awesome! There was no inverse of find-function-at-point AFAIK which really annoyed me. Now it works the way I want! (The inverse of xref-find-definitions is xref-pop-marker-stack)
unfortunately it wont work with tags files generated from .el.gz files.
@RichieHH are you sure ctags/etags support indexing .el.gz files? Out of curiosity I just made a single derectory with an arbitrary elisp file add-log.el.tar.gz, and when I do ctags -eR . and etags add-log.el.tar.gz, the resulting TAGS file has no definitions.
5

etags [options] file1 file2 ... and then, from inside emacs, do M-. to visit the tag. To go the the next occurrence of the tag, do M-,.

1 Comment

You probably meant M-. there :) Not M-x .
4

find-function is the way to go. An alternative is to use C-h f, then click the file name in buffer *Help*.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.