31.28. Hyperlinking and Navigation Features

Various modes documented elsewhere have hypertext features so that you can follow links, usually by clicking Mouse-2 on the link or typing RET while point is on the link. Info mode, Help mode and the Dired-like modes are examples. The Tags facility links between uses and definitions in source files, see Section 24.16. Imenu provides navigation amongst items indexed in the current buffer, see Section 24.17. Info-lookup provides mode-specific lookup of definitions in Info indexes, see Section 24.13. Speedbar maintains a frame in which links to files, and locations in files are displayed, see Section 19.9.

Other non-mode-specific facilities described in this section enable following links from the current buffer in a context-sensitive fashion.

31.28.1. Following URLs

M-x browse-url RET url ret

Load a URL into a Web browser.

The Browse-URL package provides facilities for following URLs specifying links on the World Wide Web. Usually this works by invoking a web browser, but you can, for instance, arrange to invoke compose-mail from mailto: URLs.

The general way to use this feature is to type M-x browse-url, which displays a specified URL. If point is located near a plausible URL, that URL is used as the default. Other commands are available which you might like to bind to keys, such as browse-url-at-point and browse-url-at-mouse.

You can customize Browse-URL's behaviour via various options in the browse-url Customize group, particularly browse-url-browser-function. You can invoke actions dependent on the type of URL by defining browse-url-browser-function as an association list. The package's commentary available via C-h p provides more information. Packages with facilities for following URLs should always go through Browse-URL, so that the customization options for Browse-URL will affect all browsing in Emacs.

31.28.2. Activating URLs

M-x goto-address

Activate URLs and e-mail addresses in the current buffer.

You can make URLs in the current buffer active with M-x goto-address. This finds all the URLs in the buffer, and establishes bindings for Mouse-2 and C-c RET on them. After activation, if you click on a URL with Mouse-2, or move to a URL and type C-c RET, that will display the web page that the URL specifies. For a mailto URL, it sends mail instead, using your selected mail-composition method (Section 28.6).

It can be useful to add goto-address to mode hooks and the hooks used to display an incoming message. rmail-show-message-hook is the appropriate hook for Rmail, and mh-show-mode-hook for MH-E. This is not needed for Gnus, which has a similar feature of its own.

31.28.3. Finding Files and URLs at Point

FFAP mode replaces certain key bindings for finding files, including C-x C-f, with commands that provide more sensitive defaults. These commands behave like the ordinary ones when given a prefix argument. Otherwise, they get the default file name or URL from the text around point. If what is found in the buffer has the form of a URL rather than a file name, the commands use browse-url to view it.

This feature is useful for following references in mail or news buffers, README files, MANIFEST files, and so on. The ffap package's commentary available via C-h p and the ffap Custom group provide details.

You can turn on FFAP minor mode to make the following key bindings and to install hooks for using ffap in Rmail, Gnus and VM article buffers.

C-x C-f filename RET

Find filename, guessing a default from text around point (find-file-at-point).

C-x 4 f

ffap-other-window, analogous to find-file-other-window.

C-x 5 f

ffap-other-frame, analogous to find-file-other-frame.

M-x ffap-next

Search buffer for next file name or URL, then find that file or URL.

C-x d directory RET

Start Dired on directory, defaulting to the directory name at point (ffap-dired-at-point).


ffap-at-mouse finds the file guessed from text around the position of a mouse click.


Display a menu of files and URLs mentioned in current buffer, then find the one you select (ffap-menu).

31.28.4. Finding Function and Variable Definitions

M-x find-function RET function RET

Find the definition function in its source file.

M-x find-variable RET variable RET

Find the definition of variable in its source file.

M-x find-function-on-key RET key

Find the definition of the function that key invokes.

These commands provide an easy way to find the definitions of Emacs Lisp functions and variables. They are similar in purpose to the Tags facility (Section 24.16), but don't require a tags table; on the other hand, they only works for function and variable definitions that are already loaded in the Emacs session.

To find the definition of a function, use M-x find-function. M-x find-variable finds the definition of a specified variable. M-x find-function-on-key finds the definition of the function bound to a specified key.

To use these commands, you must have the Lisp source (.el) files available along with the compiled (.elc) files, in directories in load-path. You can use compressed source files if you enable Auto Compression mode. These commands only handle definitions written in Lisp, not primitive functions or variables defined in the C code of Emacs.