|
<
what does expander do? |
contents |
personalized expansion
>
getting it to work with nedit
Getting started with expander is relatively simple. The instructions
included in the package show how and where to install the files, and set up the
environment. This includes the installation of a set of macros that define the
interface in NEdit for expander. The nature of expander makes it possible to
use the filter_selection() macro subroutine. The
expander macros are basically there to do some housekeeping, like setting
command line options, replacing a selection with the result expander returns,
and configuration control. The intent of the macro interface is that it should
become second nature to type the first one or two letters of an abbreviation,
press the shortcut key for the expansion macro, and continue typing in the
expanded text.
The fact that expander is language sensitive is no coincidence. It is
directly related to the fact that NEdit supports the concept of language for
syntax highlighting. A macro is used that translates NEdit's language names to
the proper name used within expander. The advantage of having language specific
definitions, especially when dealing with computer languages, is that the same
abbreviation can be used in the different dictionaries. Most computer languages
have similar flow control structures, for example an 'if' statement. However,
the syntax of the statement can vary considerably from language to language.
When a programmer tends to work with multiple languages constantly, it gets to
be tedious to have to remember the different flavors of 'if'. With expander,
this problem is solved. Just enter the abbreviation 'if', expand it, and forget
about syntax differences.
Diagram 2. The relationship between the global dictionary
and language specific dictionaries.
Diagram 2. shows the relationship of the global language neutral dictionary
to some language dependent dictionaries and their various flavors of an 'if'
statement. Note that the nesting of dictionaries is not limited to the two
levels shown. Of course, the opposite might also be true, and that is why the
relation between a language mode in NEdit and a mode in expander is indirect.
The service configuration file defines this relation. This makes it possible to
apply the same set of expansion definitions to languages with different
language modes in NEdit, but a similar syntax, for example XML and HTML. Since
NEdit processes and stores this service file at startup, the service file must
be read again after it is changed. A macro is provided in the package to
perform this operation.
As mentioned previously, access to the expander functionality is provided in
the form of a set of macros. Primarily, there are macros that select text, feed
it to expander, and replace the selection with the result of the expansion.
Since expansion strings can contain field markers, macros are also provided to
navigate from marker to marker. These have the effect of removing the field
delimiters, and selecting the content of the marker for quick substitution. It
is also possible to expand an abbreviation and immediately go to the first
field marker. Another form of expansion can be performed using the 'Expand with
selection' macro, which can take the last two words of a selection, expand the
first, and apply the second to autofill fields. Actually, the expander macros
provide even more options, which are accessed through macro call
parameters.
<
what does expander do? |
contents |
personalized expansion
>
|