"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SAVE THE CURRENT STATE OF THE "saveregexp" OPTION
local nosaveregexp
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TAKE A GUESS AT THE BUFFER'S PREFERRED DISPLAY MODE
if knownsyntax(filename)
then set! bufdisplay=syntax
if os=="unix" && buflines >= 1
then {
 1s/^#! *[^ ]*\/\([^ ]\+\).*/set! bufdisplay="syntax \1"/x
 if bufdisplay<<11=="syntax perl"
 then set! bufdisplay="syntax perl"
 if bufdisplay<<12=="syntax tclsh"
 then set! bufdisplay="syntax tcl"
}
if !newfile
then {
 if readeol=="binary" && bufdisplay=="normal"
 then set! bufdisplay=hex
 switch tolower(dirext(filename))
 case .man set! bufdisplay=man
 case .tex set! bufdisplay=tex
 case .htm
 case .html
 case .shtml
 case .dhtml set! bufdisplay=html
 if buflines >= 1 && bufdisplay=="hex"
 then 1s/^<[HIThit!]/set! bufdisplay=html/x
 if (filename<<5=="http:" || filename<<4=="ftp:") && strlen(dirext(filename))<4 && bd=="hex"
 then set! bufdisplay=normal
 if bufdisplay=="normal" && buflines >= 1
 then 1s/^From .*/set! bufdisplay="syntax email"/x
 if dirdir(filename)=="/tmp" || dirdir(filename)=="/var/tmp"
 then set! bufdisplay="syntax email"
 if strlen(dirext(filename))==2 && isnumber(filename>>1) && buflines>=1
 then 1s/^\./set! bufdisplay=man/x
}
if bufdisplay=="html" && readonly
then set locked
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Some messages
if tolower(basename(program))!="elvis" && !ro && (bd=="html" || bd=="man" || bd="tex")
then message To see the source, hit ^Wd
if partiallastline && readeol!="binary"
then warning Partial last line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" EXECUTE MODELINES, IF "modeline" OPTION IS SET
if modeline && buflines >= 1 && buflines <= modelines * 2
then %s/ex:\(.*\):/\1/x
if modeline && buflines > modelines * 2
then {
 eval 1,(modelines)s/[ev][xi]:\\\(.*\\\):/\1/x
 eval (buflines - modelines + 1),(buflines)s/[ev][xi]:\\\(.*\\\):/\1/x
}
