Mode file example

The News mode is a good example of a ModeFile but is it also a good example of a text-match. Originally this was as below.

Rules Exclude
  fff,**.!StrongED.Defaults.Modes.**
  fff,**.!StrED_cfg.UserPrefs.Modes.**
End

Rules Include
! b86,**
  fff,**.News.**
  fff,**.MBox
  fff,**.Mail*
  fff,**.OLEfiles.mar*
  fff,**.OLEfiles.TM*
  fff,**.TTFN_*
- fff,**.TTFN_*
  fff,(Pluto)**
> fff, ** ; _Newstest
End

# Use newsmode if there is a line starting with "From:"

Match
_newstest** ( < "From:")
End

The (Pluto) bit is there because when any file is received via OLE, StrongED prepends the name of the client in parentheses. It then inspects the file path to ascertain the mode. This line ensures that any text file from Pluto opens in NewsMode

This original ModeWhen file works fine for News, but it does not work for all emails as many emails have lots of headers before the From: line, so this From: does not occur in the first 1Kb (which is the amount searched by latest versions of StrongED - previous versions searched the entire file which caused significant delays in loading large files). The first suggestion was:

Match
_newstest** ( < "From:" | "Path:" | "Return-Path:")

End

However the above is case sensitive (the default condition) so does not work with a mail system that uses Return-path. So other alternatives are:

Make it completely case insensitive:

_newstest** ( < \- "From:" | "Path:" | "Return-Path:")
Allow both lower and upper case 'p':
_newstest** ( < "From:" | "Path:" | "Return-Path:" | "Return-path:")

_newstest** ( < "From:" | "Path:" | ("Return-" 'Pp' "ath:"))

_newstest** ( < "From:" | (["Return-"] ("Path:" | "path:")))

_newstest** ( < "From:" | (["Return-"] 'Pp' "ath:"))

Finally it was pointed out that email headers are case insensitive, so "From:", "Path:" and "Return-Path:" may all be upper, lower or mixed. The case insensitive option is then best.

Other relevant pages

Top of page


Page Information

http://css.torrens.org/valid-html401-bluehttp://css.torrens.org/valid-css Document URI: http://stronged.torrens.org/man/modes/examples/modewhen.html
Page first published Wednesday the 13th of December, 2017
Last modified:Thu, 05 Jul 2018 14:11:24 BST
© 2017 - 2018 Richard Torrens.