ModeWhen files - an introduction

When a file is loaded into StrongED, its internal database is searched for instructions as to what mode to open the file. That internal database is compiled from the ModeWhen files in the Modes. Most Mode definitions contain such a ModeWhen file.

At start up (or when modes are rescanned) StrongED searches all Modes (in alphabetical order of modename) for ModeWhen files which it collates in memory. When a new file is opened this internal list is consulted and the appropriate mode selected.

Each ModeWhen file is in four parts - but each part is optional. The first two parts are matched against the file name and file type before the file is loaded. The third part is a list of Named Match expressions used in the first two parts.

Rules Exclude
The full path name of a file is first matched against the Exclude rules. If this produces a match then this mode is abandoned. StrongED will move on to the next ModeWhen file,

This is so that any unwanted matches in the Include section can be avoided. An example of this is the News ModeFile where StrongED's NewsMode file itself would be matched by one of the Include rules. So the Exclude section of the News mode reads:

Rules Exclude
  fff,**.!StrongED.Defaults.Modes.**
  fff,**.!StrED_cfg.UserPrefs.Modes.**
End
Rules Include
If the file to be loaded is not matched by the Exclude rules, then it will be matched against the Include rules. If the file to be loaded matches any rule in this list, then this mode will be pre-selected before the file is loaded. Any subsequent Include rules will not be tested.
Match
Match is optional. It is a lit of Named Match expressions used in Rules Exclude and Rules Include, There is a page detaining the Syntax of ModeWhen Rules section which can include matches in the loaded text.

After the file is loaded, the first 1Kb of it is searched for anything that matches the Match text. If a match is found, then that mode is used. If no Match is found, then the pre-selected mode (if any) will be used. If no mode has been pre-selected, then BaseMode is used.

Display
Determines what display type to use. This section is only used by Dump at the moment (4.79 and earlier).
From the above, it should be evident that, if a Mode contains no ModeWhen file, then that mode will never be used when loading an existing file.

You can place comment lines throughout the file, including inside the sections, by starting lines with "#".

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/modewhen.html
Page first published Thursday the 7th of June, 2018
Last modified:Sat, 08 Sep 2018 16:34:17 BST
© 2018 - 2018 Richard Torrens.