https://stackoverflow.com/questions/4222183/emacs-how-to-jump-to-function-definition-in-el-file and talk about navigation to source of functions. They offer two options:

  • M-x find-function
  • C-h f then use link in help buffer.

However, for a compiled function, neither work.

M-x find-function compilation-find-file

throws an error:

Debugger entered--Lisp error: (error "Can’t find library /usr/share/emacs/26.1+gg1+7/lisp/progmodes/compile.el")

If I used the help function path, I see:

compilation-find-file is a compiled Lisp function. 

How can I fix these?

  • This sounds like something specific to your installation/setup; M-x find-function RET compilation-find-file RET works fine for me (so long as compile.el has been loaded beforehand), despite compilation-find-file being a "compiled Lisp function". Does it work if you start with emacs -Q followed by (require 'compile) and then the find-function call? – Basil Aug 5 '18 at 16:02
  • Note that there is also M-. (xref-find-definitions since Emacs 25) for jumping to the definition of the identifier at point, as briefly mentioned in the linked SO post. – Basil Aug 5 '18 at 16:03
  • (require 'compile) does not change the observed behaviour. I am wondering if I need to play with source-directory' and/or load-path'. – Realraptor Aug 5 '18 at 16:12
  • 1
    Why not just take a peak inside the directory where Emacs is looking to see what is there? /usr/share/emacs/26.1+gg1+7/lisp/progmodes and also the parent directory. If there is nothing there, then grep or manually look around for the .el and/or .gz files. There are minimal installations that do not install the Lisp libraries, but that is not very common and is certainly not the default installation method. – lawlist Aug 5 '18 at 16:21
  • 1
    In particular, a Debian/Ubuntu/etc installation may not include everything you want, and you may be missing (and hence need to apt-get install) the emacs-el and emacs25-common-non-dfsg packages (substituting the version number as appropriate in the latter package name). The former provides the elisp source files, and the latter provides the manuals. You don't want to be lacking either of those things. – phils Aug 6 '18 at 0:04

It turns out that adding the -el for the emacs version I am using resolves the problem (as suggested by phils).

  • Note that you can accept your own answer. – Basil Aug 6 '18 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.