20.1.3 Info Files in Other Directories

If an Info file is not in the info directory, there are three ways to specify its location:

  1. Write the file name in the dir file as the second part of the menu.
  2. Specify the Info directory name in the INFOPATH environment variable in your .profile or .cshrc initialization file. (Only you and others who set this environment variable will be able to find Info files whose location is specified this way.)
  3. If you are using Emacs, list the name of the file in a second dir file, in its directory; and then add the name of that directory to the Info-directory-list variable in your personal or site initialization file.

    This variable tells Emacs where to look for dir files (the files must be named dir). Emacs merges the files named dir from each of the listed directories. (In Emacs version 18, you can set the Info-directory variable to the name of only one directory.)

For example, to reach a test file in the /home/bob/info directory, you could add an entry like this to the menu in the standard dir file:

* Test: (/home/bob/info/info-test).  Bob's own test file.

In this case, the absolute file name of the info-test file is written as the second part of the menu entry.

If you don’t want to edit the system dir file, you can tell Info where to look by setting the INFOPATH environment variable in your shell startup file. This works with both the Emacs and standalone Info readers.

Emacs uses the INFOPATH environment variable to initialize the value of Emacs’s own Info-directory-list variable. The standalone Info reader merges any files named dir in any directory listed in the INFOPATH variable into a single menu presented to you in the node called ‘(dir)Top’.

However you set INFOPATH, if its last character is a colon (on MS-DOS/MS-Windows systems, use a semicolon instead), this is replaced by the default (compiled-in) path. This gives you a way to augment the default path with new directories without having to list all the standard places. For example (using sh syntax):

INFOPATH=/home/bob/info:
export INFOPATH

will search /home/bob/info first, then the standard directories. Leading or doubled colons are not treated specially.

When you create your own dir file for use with Info-directory-list or INFOPATH, it’s easiest to start by copying an existing dir file and replace all the text after the ‘* Menu:’ with your desired entries. That way, the punctuation and special CTRL-_ characters that Info needs will be present.

As one final alternative, which works only with Emacs Info, you can change the Info-directory-list variable. For example:

(add-hook 'Info-mode-hook '(lambda ()
	     (add-to-list 'Info-directory-list
			  (expand-file-name "~/info"))))