3

Is there a way to check the implementation of a builtin function (e.g. load-file) without cloning the Emacs repository?

2
  • 1
    Some built-in functions are written in C in which case you do need a copy of that source code in order for Emacs to be able to show you the definition. You don't need to clone a repository, though -- a tarball of the sources is absolutely fine for this purpose. For elisp functions, unless you've installed Emacs without the .el (or .el.gz) sources, Emacs will take you to the definitions by default when you ask for help about a function (or variable) and follow the link provided.
    – phils
    Oct 9, 2019 at 19:37
  • n.b. if you installed Emacs via your OS package manager, then you should review all other related packages (which may not be installed), as there may be things that you are missing. (e.g. Debian's basic package includes neither the elisp sources nor the manuals, which makes for an extremely incomplete install).
    – phils
    Oct 9, 2019 at 21:17

3 Answers 3

4

For load-file C-h f load-filethen follow the link from the first line, in this case:

load-file is an interactive compiled Lisp function in ‘files.el’.

will open the elisp function definition, C source code, AFAIK, will require the repo.

2

On debian, and I guess on Ubuntu as well, the elisp sources (.el files as opposed to byte compiled .elc files) are available in the emacs-el package.

The elisp sources are not provided in the basic emacs package since they're not necessary to run emacs, only usefull if, like you do, you want to look at the source.

So absolutely don't need to clone the emacs repo, you just need to install that emacs-el package, eg

sudo apt-get install emacs-el
1

If you are interested in looking at a file from a computer that Emacs isn't even installed on, you can take the filename it's found in from help (C-h f load-file RET), then browse the source at Emacs's GNU Savannah repository, or the Github mirror.

This code will be later than the version of Emacs you're using, and it may be different in important ways.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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