4.1 Finding More Information

In this walk-through, I will describe each new function as we come to it, sometimes in detail and sometimes briefly. If you are interested, you can get the full documentation of any Emacs Lisp function at any time by typing C-h f and then the name of the function (and then RET). Similarly, you can get the full documentation for a variable by typing C-h v and then the name of the variable (and then RET).

Also, describe-function will tell you the location of the function definition.

Put point into the name of the file that contains the function and press the RET key. In this case, RET means push-button rather than “return” or “enter”. Emacs will take you directly to the function definition.

More generally, if you want to see a function in its original source file, you can use the xref-find-definitions function to jump to it. xref-find-definitions works with a wide variety of languages, not just Lisp, and C, and it works with non-programming text as well. For example, xref-find-definitions will jump to the various nodes in the Texinfo source file of this document (provided that you’ve run the etags utility to record all the nodes in the manuals that come with Emacs; see Create Tags Table in The GNU Emacs Manual).

To use the xref-find-definitions command, type M-. (i.e., press the period key while holding down the META key, or else type the ESC key and then type the period key), and then, at the prompt, type in the name of the function whose source code you want to see, such as mark-whole-buffer, and then type RET. (If the command doesn’t prompt, invoke it with an argument: C-u M-.; see Different Options for interactive.) Emacs will switch buffers and display the source code for the function on your screen11. To switch back to your current buffer, type M-, or C-x b RET. (On some keyboards, the META key is labeled ALT.)

Incidentally, the files that contain Lisp code are conventionally called libraries. The metaphor is derived from that of a specialized library, such as a law library or an engineering library, rather than a general library. Each library, or file, contains functions that relate to a particular topic or activity, such as abbrev.el for handling abbreviations and other typing shortcuts, and help.el for help. (Sometimes several libraries provide code for a single activity, as the various rmail… files provide code for reading electronic mail.) In The GNU Emacs Manual, you will see sentences such as “The C-h p command lets you search the standard Emacs Lisp libraries by topic keywords.”


Footnotes

(11)

If instead of showing the source code for a Lisp function, Emacs asks you which tags table to visit, invoke M-. from a buffer whose major mode is Emacs Lisp or Lisp Interaction.