home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / elvis22g.zip / lib / elvis.arf < prev    next >
Text File  |  2002-04-10  |  3KB  |  80 lines

  1. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  2. " SAVE THE CURRENT STATE OF THE "saveregexp" OPTION
  3. local nosaveregexp
  4. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  5. " TAKE A GUESS AT THE BUFFER'S PREFERRED DISPLAY MODE
  6. if knownsyntax(filename)
  7. then set! bufdisplay=syntax
  8. if os=="unix" && buflines >= 1
  9. then {
  10.  try 1s/\V^#! *[^ ]*\/\([^ ]\+\).*/set! bufdisplay="syntax \1"/x
  11.  if bufdisplay<<11=="syntax perl"
  12.  then set! bufdisplay="syntax perl"
  13.  if bufdisplay<<12=="syntax tclsh"
  14.  then set! bufdisplay="syntax tcl"
  15. }
  16. if !newfile
  17. then {
  18.  if readeol=="binary" && bufdisplay=="normal" && (partiallastline || !binary)
  19.  then set! bufdisplay=hex
  20.  switch tolower(dirext(filename))
  21.  case .man set! bufdisplay=man
  22.  case .tex set! bufdisplay=tex
  23.  case .htm
  24.  case .html
  25.  case .shtml
  26.  case .dhtml set! bufdisplay=html
  27.  if buflines >= 1 && bufdisplay=="hex"
  28.  then try 1s/\V^<[HIThit!]/set! bufdisplay=html/x
  29.  if (filename<<5=="http:" || filename<<4=="ftp:") && strlen(dirext(filename))<4 && bd=="hex"
  30.  then set! bufdisplay=normal
  31.  if bufdisplay=="normal" && buflines >= 1
  32.  then try 1s/\V^From .*/set! bufdisplay="syntax email"/x
  33.  if dirdir(filename)=="/tmp" || dirdir(filename)=="/var/tmp"
  34.  then set! bufdisplay="syntax email"
  35.  if strlen(dirext(filename))==2 && isnumber(filename>>1) && buflines>=1
  36.  then try 1s/\V^\./set! bufdisplay=man/x
  37. }
  38. if bufdisplay=="html" && readonly
  39. then set locked
  40. if bufdisplay=="html"
  41. then set nosmartargs
  42. if readonly && (bufdisplay=="html" || bufdisplay=="man")
  43. then try set nohlspell
  44. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  45. " Store the file's timestamp
  46. let timestamp = time(filename)
  47. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  48. " Set the buffer's "initialsyntax" option, based on "prefersyntax"
  49. if bufdisplay=="html" || bufdisplay=="man" || bufdisplay=="tex"
  50. then {
  51.  try {
  52.   switch prefersyntax
  53.   case always    set isyn
  54.   case local    let isyn = !readonly || dirdir(filename) == "."
  55.   case writable    let isyn = !readonly
  56.   case never    set noisyn
  57.  }
  58. }
  59. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  60. " Set mapmode to the bufdisplay, if appropriate
  61. switch bufdisplay
  62. case html
  63. case man
  64. case tex let! mapmode=bufdisplay
  65. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  66. " Some messages
  67. if tolower(basename(program))!="elvis" && !ro && (bd=="html" || bd=="man" || bd="tex")
  68. then message To see the source, hit ^Wd
  69. if partiallastline && readeol!="binary"
  70. then warning Partial last line
  71. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  72. " EXECUTE MODELINES, IF "modeline" OPTION IS SET
  73. if modeline && buflines >= 1 && buflines <= modelines * 2
  74. then try %s/\V[ev][xi]:\(.*\):/\1/x
  75. if modeline && buflines > modelines * 2
  76. then {
  77.  eval try 1,(modelines)s/\V[ev][xi]:\\\(.*\\\):/\1/x
  78.  eval try (buflines - modelines + 1),(buflines)s/\\V[ev][xi]:\\\(.*\\\):/\1/x
  79. }
  80.