How SXEmacs finds Directories and Files
=======================================

SXEmacs deals with a multitude of files during operation.  These files are spread over many directories, and SXEmacs determines the location of most of these directories at startup and organizes them into various paths.  (A path, for the purposes of this section, is simply a list of directories which SXEmacs searches successively in order to locate a file.)

SXEmacs Directory Hierarchies
-----------------------------

Many of the files SXEmacs looks for are located within the SXEmacs installation itself.  However, there are several views of what actually constitutes the "SXEmacs installation": SXEmacs may be run from the compilation directory, it may be installed into arbitrary directories, spread over several directories unrelated to each other.  Moreover, it may subsequently be moved to a different place.  (This last case is not as uncommon as it sounds.  Binary kits work this way.)  Consequently, SXEmacs has quite complex procedures in place to find directories, no matter where they may be hidden.

SXEmacs will always respect directory options passed to configure. However, if it cannot locate a directory at the configured place, it will initiate a search for the directory in any of a number of hierarchies rooted under a directory which SXEmacs assumes contain parts of the SXEmacs installation; it may locate several such hierarchies and search across them.  (Typically, there are just one or two hierarchies: the hierarchy where SXEmacs was or will be installed, and the one where it is being built.)  Such a directory containing a hierarchy is called a root. Whenever this section refers to a directory using the shorthand <root>, it means that SXEmacs searches for it under all hierarchies SXEmacs was able to scrounge up.  In a running SXEmacs, the hierarchy roots are stored in the variable emacs-roots.

Package Hierarchies
-------------------

Many relevant directories and files SXEmacs uses are actually not part of the core installation.  They are part of any of the many packages usually installed on top of an SXEmacs installation.  (see Packages.) Hence, they play a prominent role in the various paths SXEmacs sets up.

SXEmacs locates packages in any of a number of package hierarchies. Package hierarchies fall into three groups: early, late, and last, according to the relative location at which they show up in the various SXEmacs paths.  Early package hierarchies are at the very front, late ones somewhere in the middle, and last hierarchies are (you guessed it) last.

By default, SXEmacs looks for early package hierarchies in $XDG_DATA_HOME/sxemacs, and late package hierarchies in $PREFIX/share/sxemacs.

Under the early and late hierarchies are the subdirectories: site-packages, sxemacs-packages, mule-packages, and xemacs-packages, which are searched in that order.  (If you run in-place, these are direct subdirectories of the build directory.)

By default, SXEmacs does not have a pre-configured last package hierarchy.  Last hierarchies are primarily for using package hierarchies of outdated versions of XEmacs as a fallback option.  For example, it is possible to run SXEmacs with the XEmacs 20.4 package hierarchy as a last hierarchy.

It is possible to specify at configure-time the location of the various package hierarchies with the --with-package-path option to configure. The early, late, and last components of the package path are separated by double colons instead of single colons.  If all three components are present, they locate the early, late, and last package hierarchies respectively.  If two components are present, they locate the early and late hierarchies.  If only one component is present, it locates the late hierarchy.  At run time, the package path may also be specified via the EMACSPACKAGEPATH environment variable.  Or, alternatively, the early hierarchy can be set via the -user-pkgs-directory command line argument (see Command Switches).

An SXEmacs package is laid out just like a normal installed SXEmacs lisp directory.  It may have lisp, etc, info, and lib-src subdirectories.  SXEmacs adds these at appropriate places within the various system-wide paths.

There may be any number of package hierarchy directories.

Directories and Paths
---------------------

Here is a list of the various directories and paths SXEmacs tries to locate during startup.  SXEmacs distinguishes between directories and paths specific to version, site, and architecture when looking for them.

version-specific
     directories are specific to the version of SXEmacs they belong to and typically reside under <root>/share/sxemacs-<VERSION>.  This is where you'll find the lisp that is shipped with SXEmacs, we call it the core lisp.

site-specific
     directories are independent of the version of SXEmacs they belong to and typically reside under <root>/share/sxemacs.  Where you'll find the site's package lisp (late-packages).

architecture-specific
     directories are specific both to the version of SXEmacs and the architecture it runs on and typically reside under <root>/lib/sxemacs-<VERSION>/<ARCHITECTURE>.  This is where you'll find the emodules, and other miscellaneous things such as gnuserv, and yow.

If SXEmacs runs with the -debug-paths option (see Command Switches), it will print the values of these variables, hopefully aiding in debugging any problems which come up.

lisp-directory
     Contains the version-specific location of the Lisp files that come with the core distribution of SXEmacs.  SXEmacs will search it recursively to a depth of 1 when setting up load-path.

load-path
     Is where SXEmacs searches for SXEmacs Lisp files with commands like load-library. It contains the package lisp directories (see further down) and the version-specific core Lisp directories.  If the environment variable EMACSLOADPATH is set at startup, its directories are prepended to load-path.

Info-directory-list
     Contains the location of info files.  (See (info).)  It contains the package info directories and the version-specific core documentation.  Moreover, SXEmacs will add /usr/info, /usr/local/info as well as the directories of the environment variable INFOPATH to Info-directory-list.

exec-directory
     Is the directory of architecture-dependent files that come with SXEmacs, especially executable programs intended for SXEmacs to invoke.

exec-path
     Is the path for executables which SXEmacs may want to start.  It contains the package executable paths as well as exec-directory, and the directories of the environment variables PATH and EMACSPATH.

doc-directory
     Is the directory containing the architecture-specific DOC file that contains documentation for SXEmacs' commands.

data-directory
     Is the version-specific directory that contains core data files SXEmacs uses. It may be initialized from the EMACSDATA environment variable.

data-directory-list
     Is the path where SXEmacs looks for data files.  It contains package data directories as well as data-directory.