When a document is loaded or saved under a different name, ne
may
examine the contents of the document to determine whether to ignore the
corresponding file’s actual or missing extension and use instead a virtual
extension. This affects which AutoPrefs and Syntax settings ne
applies to the document.
The document’s contents are matched against the regular expressions (see
see Regular Expressions) you include in your ~/.ne/.extensions
file. (There may also be an extensions file (no leading ‘.’)
in the global directory.) If ne
finds a match it will act as if the
document’s name had the corresponding extension.
Note that by default ne
does not override a file’s
given extension. However, you can specify any number of extensions that
you would like to allow to be overridden by including lines in your
~/.ne/extensions containing only a dot followed by a single extension or
shell “glob pattern”. In particular, “.*
” would
allow overriding all extensions.
Here’s an example ~/.ne/.extensions file:
# The following patterns match some common command interpreters. # They must match on the first line. sh 1 ^#!\s*/.*\b(bash|sh|ksh|zsh)\s* csh 1 ^#!\s*/.*\b(csh|tcsh)\s* pl 1 ^#!\s*/.*\bperl\b py 1 ^#!\s*/.*\bpython[0-9]*\s* rb 1 ^#!\s*/.*\bruby\s* xml 1 ^<\?xml # These must match in the first 30 and 1000 lines, respectively. yaml 30 ^---$ ini 1000i ^\[\s*(\w|[.-])+\s*\]\s*$ # You must list the existing extensions you wish to override, one # per line. Shell glob patterns are allowed. Note that ".*" would # allow overriding any extension. (Think before you do that!) .conf .tx[0-9]
The only lines which matter consist of a space-delimited set of
extension number regular_expression
or a single ‘.’ followed by a glob pattern. Anything else is treated as a comment. The number must be a positive integer indicating the maximum line number of the document in which the corresponding regular expression must match. The exception is zero, which allows a match on any line in the document. (Actually, ne restricts the examined portion of the document to the first 1,000,000 bytes.) If the number has a lower-case ‘i’ suffix (see the ini example above), the corresponding regular expression is not case sensitive. Trailing spaces are not included as part of the regular_expression.
Only the last instance of any extension specification is considered. This allows you to override any specifications from the global extensions file. If you really need two different patterns, join them into one by concatenating them with a ‘|’ like so:
foo 1000i (pattern_A)|(pattern_B)