|
contents |
what does expander do?
>
Expanding NEdit
Steven Haehn and Joor Loohuis
contents
introduction
Expander is a utility that acts as a filter for text editors, and replaces
specific short character sequences, or abbreviations, with longer ones. The
replacement text may contain newlines, indents, and even the contents of entire
files (templates). It can also contain various control features, and markers
can be used to control cursor placement in NEdit. It provides a simple
mechanism through which rapid prototyping and consistent formatting in NEdit
are easily obtained.
history
Expander has been available for some time from the NEdit site, but it has
undergone quite some changes over the years. Steve explains:
The idea for the expander facility came from my experiences at
Xerox using a programming tool called the Xerox Development Environment (XDE).
Inside XDE was a "Definition" mechanism that allowed user's to define
abbreviations and have them expanded by the stroke of a special key on the
keyboard. It was somewhat primitive in that it's forte was really to take
simple typing abbreviations, such as XDE, and expand it to its stored
definition of "Xerox Development Environment". The Unix 'vi' and 'emacs'
editors also share this similar capability. However, none of these editing
environments satisfied my itch. I wanted more than what they could provide.
Eventually, a colleague introduced me to NEdit, and I was off
learning how this newly discovered editor worked. I had forgotten about the XDE
environment abbreviation expander, until I found the original expander code
created for NEdit by Marc Verdiesen. I saw how it was put together and thought
to myself that with some tweaking (which eventually became almost a complete
rewrite), I could allow individuals to define their own definitions, like the
XDE environment did. I was off and running, ...uh, programming. (Since I am not
a great typist, I go to great lengths to figure out how to be able to generate
good looking, readable code, with minimal effort from my meager typing
skills.)
The original code was locked into the 'C' programming language
and had to be modified to make additions. To get around this I made the program
get all its definitions from data files instead of fixed data in the program.
This allows the user to declare their own definitions without having to modify
the program. It also gives everyone the freedom to specify how they want their
programming constructs to be expanded. For instance, where do the enclosing
braces on a programming statement reside; on the same line as the statement
introductory clause, or on the next line under the clause? The program allows
the user to define these embellishments, not the other way around, with the
program dictating how the statement looks. So that was one goal; to bring data
definitions out of the program into the hands of the user.
Since I program in many languages, a second goal took shape.
This was the goal of language sensitive definitions. I wanted to be able to get
an 'if' statement produced in an individual's programming work without having
to worry about the explicit syntax. So whether one is programming in perl,
Java, 'C', shell scripts, whatever, all that would be needed to do is enter
'if' and expand the definitions according to current language setting. To me,
this frees the programmer from worrying about syntax issues and allows them to
concentrate on the algorithm being developed.
When I was introduced to NEdit, I was working in a group which
had set up some standards on how the code being produced was to look and be
documented. This was leading me down the path of file template expansion, which
became an expander feature. I not only wanted to expand an abbreviation into
the contents of an existing template, I wanted fields in the template to be
dynamically filled in. The goal was to allow generic templates to become
personalized when expanded by an individual. For instance, the name of the
individual applying the expansion and the date the expansion was applied could
be now automatically filled in. This is how the dynamic auto-fill field feature
came into being. It can be thought of as recursive abbreviation expansion. That
is, the expander facility is automatically expanding fields containing
abbreviation for which it already has definitions.
contents |
what does expander do?
>
|