This section describes elvis's session files and itemizes the steps it takes during initialization.
elvis is intended to eventually meet COSE (Common Open System Environment) standards. These require that programs be able to save their state and return to that saved state at a later time.
To be able to do this, elvis maintains all its state in a session file. Normally elvis creates the session file when it starts, and removes it when it exits, but if elvis crashes, a left-over session file can be used to implement recovery of the edited files.
elvis performs the following initialization steps. Interestingly, much of the customization for elvis is moved out of editor options and into initialization files.
Initialize all hardcoded options.
Select an interface from those compiled into elvis. elvis will choose the "best" of the ones that are compiled in and that can work. For example, the X11 interface is considered to be better than the termcap interface, but it may not be usable if X Windows is not currently running.
The selected interface can process the command line for initialization options that are specific to it.
Create the session file if it doesn't exist; otherwise, read it (in preparation for recovery).
Initialize the elvispath
option from the
ELVISPATH
environment variable. Otherwise, give
it a default value.
"~/.elvislib:/usr/local/lib/ elvis"
is a typical value, but the actual value
will depend upon how elvis was
configured and built.
Search elvispath
for an ex script named
elvis.ini and run it. The default
elvis.ini file performs the
following actions:
Chooses a digraph table based on the current operating system. (Digraphs are a way to define the system's extended ASCII character set and how characters from the extended set should be entered.)
Sets options based on the program's name (for example, ex vs. vi mode).
Handles system-dependent tweaks, such as setting the colors for X11 and adding menus to the interface.
Picks an initialization filename, either .exrc for UNIX, or elvis.rc for non-UNIX systems. Call this file f.
If the EXINIT
environment variable
exists, executes its value. Otherwise,
:source
~/f,
where f is the filename chosen previously.
If the exrc
option has been set, then
runs the :safer
command on f in the current directory.
For X11, sets the normal, bold, and italic fonts, if they have not been set already.
Load the pre- and post-read and pre- and post-write command files, if they exist. Also load the elvis.msg file. All of these files are described later in this chapter.
Load and display the first file named on the command line.
If the -a
option was given, load and display
the rest of the files, each in its own window.