For elvis, this means that edit sessions should be restartable. It is possible to begin an edit session with one elvis process, exit that process, and then later start a new elvis process which resumes the previous edit session.
To accomplish this, elvis stores its state in a file, called the session file. For all practical purposes, the session file is the session.
The name of the session file is stored in the session option. By default, this will be a file in your home directory, named "elvis*.ses", where "*" represents a number chosen at run-time to make the file name unique. You can specify some other name for the session file via the -ssession command-line flag.
If the session file doesn't already exist when elvis starts running, then elvis will create it.
When elvis exits, it will normally delete the session file if this is the elvis process that created it. If the session file was left over from some other elvis process, then elvis will not delete it upon exiting. This is controlled by the tempsession option; if you don't like elvis' default behavior then you can change it.
Elvis then chooses which user interface it should use. Elvis does this by scanning the command line arguments for a -ggui flag; if there is no such flag, then elvis tests each user interface and uses the best one that is expected to work. (For example, the "x11" interface is expected to work if there is a DISPLAY environment variable and the X server is accessible. If not, then the "x11" interface is rejected and some other interface is used.)
The session file is then opened or created. For preexisting session files, elvis scans the session file for any buffers in it, and adds them to its internal list. Elvis can even reload the "undo" versions of some buffers.
Elvis searches through the directories named in the elvispath option for a file named "elvis.ini". If it finds that file, then it loads it into a buffer named "Elvis initialization" and executes its contents as a series of ex commands. See section 10.2.1 for description of the default contents of this file.
After that, it attempts to similarly load some other files, but they aren't executed. Some of them will be executed later. These files are:
.-----------.----------------------.------------------------------. | FILE NAME | BUFFER NAME | PURPOSE | |-----------|----------------------|------------------------------| | elvis.msg | Elvis messages | used to translate messages | | elvis.brf | Elvis before reading | executed before loading file | | elvis.arf | Elvis after reading | executed after loading file | | elvis.bwf | Elvis before writing | executed before saving file | | elvis.awf | Elvis after writing | executed after saving file | ^-----------^----------------------^------------------------------^The "elvis.msg" file is described in section 11: Messages. The other files are described later in this section.
The next step in initialization is to load the first file and display it in a window. To do this, it first creates an empty buffer with the same name as the file. It then executes the "Elvis before reading" buffer (if it exists) on the empty buffer. The file's contents are then read into the buffer. Then the "Elvis after reading" buffer (if it exists) is executed on the new buffer. Finally, elvis creates a new window that shows the new buffer.
If the -a flag was given on the command line, then elvis will repeat the above steps for each file named on the command line. On the other hand, if no filenames were given on the command line then elvis will simply create a single untitled buffer and a window that shows it.
" SET SOME LOCAL DEFAULTS set lptype=ps2 lplines=60 lpcolumns=80 lpwrapThis line initializes the printer options to values that are appropriate for my system. You'll probably need to change them for your system.
" DEFINE SOME LATIN-1 DIGRAPHS source! (elvispath("elvis.lat"))This attempts to locate the "elvis.lat" file and execute it. The "elvis.lat" file is an ex script which contains a bunch of :digraph commands that set up the digraph table appropriately for the Latin-1 symbol set. The "!" at the end of the :source command name causes :source to silently ignore errors.
let p=tolower(basename(program)) if p == "ex" || p == "edit" then set initialstate=ex if p == "view" then set defaultreadonly if p == "edit" || p == "vedit" then set novice if home == "" then let home=dirdir(program)These lines initialize certain options according to the name by which elvis was invoked. Traditionally, invoking vi by the name "ex" causes it to start up in ex mode instead of vi mode, and "view" causes the files to be treated as readonly.
" X11 INTERFACE DEFAULTS GO HERE if gui == "x11" then color i saddlebrown|color u navyblue then if normalfont == "" then set normalfont="*-courier-medium-r-*-18-*" then set boldfont="*-courier-bold-r-*-18-*" then set italicfont="*-courier-medium-o-*-18-*"These lines set the defaults for the "x11" user interface. You should set the defaults here, and not in an app-defaults file. If you aren't using the "x11" user interface, then these lines have no effect.
" EXECUTE THE STANDARD CUSTOMIZATION SCRIPTS let f=(os=="unix" ? ".exrc" : "elvis.rc") if $EXINIT then eval $EXINIT else source! ~$1(f) if exrc then safer! (f)These lines set the f option to either ".exrc" or "elvis.rc", whichever is appropriate for your operating system. They then check whether an environment variable named "EXINIT" is set to a non-empty value. If so, then the value of EXINIT is executed as an ex command line; otherwise the ".exrc" or "elvis.rc" file in your home directory is executed, if it exists. (The $1 is replaced by a forward or backward slash, depending on your operating system.) If EXINIT or .exrc/elvis.rc (whichever was executed) has set the exrc option then elvis will execute ".exrc" or "elvis.rc" in the current directory, if it exists. Elvis uses :safer instead of :source to execute the file for security reasons.
" TAKE A GUESS AT THE BUFFER'S TYPE let e=tolower(dirext(filename)) if e==".bin" || e==".dat" || (os=="msdos" || os=="win32") && (e=".exe" || e=".com") then set binaryThese lines try to guess whether the file is binary or not. This must be done before the file is loaded because for non-binary files elvis converts newlines to linefeeds as it reads the file.
Note: The "if" line is split above merely as a typographical convenience. In the real "elvis.brf" file, the "if" line and "&&" line are actually a single line.
" TAKE A GUESS AT THE BUFFER'S PREFERRED DISPLAY MODE let e=tolower(dirext(filename)) if e==".c" || e==".h" || e==".cpp" then set bufdisplay=c if e<<4==".htm" then set bufdisplay=html if e==".man" || e==".1" then set bufdisplay=man if binary then set bufdisplay=hexThese lines try to guess the preferred display mode for the file, mostly by examining the filename's extension.
" EXECUTE MODELINES, IF "modelines" OPTION IS SET if modelines && buflines >= 1 && buflines <= 10 then %s/ex:\(.*\):/\1/x if modelines && buflines > 10 then 1,5s/ex:\(.*\):/\1/x then $-4,$s/ex:\(.*\):/\1/xThese commands search for modelines in the newly loaded file, if the modelines option is set. The modelines are executed via the new "x" option to the :s command.
if backup && !newfile && os=="unix" then eval ! cp -f (filename) (basename(filename)).bak if backup && !newfile && os!="unix" then eval ! copy (filename) (basename(filename)).bakThese lines copy the original version of the file to a "*.bak" file. Note that we implement separate Unix and non-Unix versions of the copy command here.
There is no default "elvis.awf" file, because I haven't found any need for one yet.
Only one elvis process at a time is allowed to use a given session file. To enforce this, when elvis starts up it sets an "in use" flag in the session file's header. Any later elvis process will test that flag, and refuse to use a session file which is already in use.
When elvis crashes, it leaves the "in use" flag set, even though the process that was using it has died. You must restart your edit session via "elvis -r". The -r flag tells elvis to ignore the "in use" flag.
When this new elvis process starts up, it will be displaying a new, empty buffer. Don't panic! Your edit buffers are still intact; they just don't happen to be displayed in the initial window.
After a crash, the session file might not be entirely self-consistent. Because of this, it is dangerous to edit the file using this session file. You should save your old buffer to a file immediately, and then exit elvis. To save your old buffer give elvis the command ":(buffer)w filename" where buffer is the name of your buffer (usually the same as the original file name) and filename is the name of a new file where you wish to store the text. For safety's sake, you should not write the salvaged buffer out over the top of the original text file.
After exiting, you should give the shell command "rm core ~/elvis*.ses" to delete the core file and the damaged session file. (For DOS/Windows users, the command is "DEL ELVIS*.SES".)
If you can figure out how to reproduce the problem, please let me know! My email address is
kirkenda@cs.pdx.edu/ElvisN /Courier findfont 12 scalefont def /ElvisB /Courier-Bold findfont 12 scalefont def /ElvisI /Courier-Oblique findfont 12 scalefont def /ElvisPage { 12 36 translate } def /ElvisLeftPage { 12 750 translate -90 rotate 0.58 0.75 scale } def /ElvisRightPage { newpath 12 394 moveto 576 0 rlineto stroke 12 366 translate -90 rotate 0.58 0.75 scale } def