It is assumed that the reader has a copy of se installed on his machine and is reasonably familiar with using it. Other useful programs from Software Tools are mentioned, such as the text formatter fmt, the paginator pg and the list files lf program. Also mentioned are other Public Domain programs such as arc. A reasonable familiarity with Unix is also assumed.
Topics covered include: setting up se according to the user's needs; solutions to common problems; using se with other software; and useful se command language idioms.
Se is used to generate files that can be fed into other applications: text formatters, programming language compilers, electronic mail systems and so on. So, how does one connect se into other software? Most programs will have facilities to import or export files. Sometimes a menu of possible file formats is provided, sometimes the file name tells the program how to interpret the data. In either case, the option we want is ASCII text. Avoid options such as WordStar format, Lotus worksheet or dBase data they won't work.
By way of example, here is the command to display a list of the files in the current directory:
!lsThe list of files appears in the usual way, then se displays the message type return to continue:. When you have finished reading the display, press return; se will re-draw the editing screen exactly as it was before.
There are some problems with shell escapes, as these commands are called. The obvious one is that you can forget where you are and log out of the machine while se is still running unseen. This will lose your editing buffer, so it is usually wise to write the buffer into a file before using the shell escape.
In fact, se displays a message No writes since last change on the status line if the buffer hasn't been saved during a shell escape. This is also important if the command that you execute refers to the file that you are editing.
Using fmt one can create documents that can be read either on the screen or printed out. Input to fmt, as created with se, consists of a mixture of formatting commands and text. An fmt command is distinguished from the text around it by the following convention: a command begins in column one with a full-stop.
Clearly, it is easy to get se to spot commands for you. To search for the next fmt command in a file, type:
/^\./Note the use of the caret ^ metacharacter to match start of line. Also, the special meaning of dot has been escaped.
Fmt's inline function syntax uses square brackets [ and @]. To find the next function call in a file, type:
/\[/Note the use of \ to escape the special meaning of [.
In order to get se to recognise fmt comments, use the following commands, either on the command line or in a .RC file:
of/"/'/.#/\n/ ocThe oc option acts as a toggle when used on the command line.
Once the fmt document is ready to test, it is useful to run fmt from within se. The shell escape mechanism allows this and also allows the use of a pipe into pg to see the result of special effects such as underlining or boldfacing. Try the following commands with an fmt document in the buffer:
w !fmt % | pg -mFirst, the file is written to disk to ensure that fmt gets the latest version. Then the percent character % is used to give the current file name in the shell command. The -m option to pg tells it to expect an fmt metafile. Remember that se has one level of shell command history; to repeat the preview command, type:
w !!and se will place the previous shell command back on the command line for editing; pressing return will cause it to be executed. So, with the shell history feature it is possible to spend an entire session in se, while calling up other programs via the shell escape. The pling-pling-return-return sequence soon becomes well-known.
It was for programmers that the Source-Code Mode was incorporated. The following list shows the quote and comment symbols for a number of popular languages, together with the corresponding file suffix.
C .c .h of|"|'|/*|*/|#|\n|
BASIC .bas of|"|"|'|\n|||
BASIC .bas of|"|'|REM|\n|||
Pascal .pas of|"|'|(*|*)|(*$|*)|
Pascal .pas of|"|'|{|}|{$|}|
occam .occ of|"|'|--|\n|||
PostScript .ps of|"|'|%|\n|||
Ratfor .r of|"|'|#|\n|||
fmt .fmt of|"|'|.#|\n|||
TeX .tex of|"|'|%|\n|||
Algol-68 .a68 of|"|'|#|#|||
PL/1 .pl1 of|"|'|/*|*/|||
In each case an environment variable can be set up to indicate the location of the file itself. A sensible default is used if the environment variable has not been set up.
File Default Name Environment Variable message file SE.MSG SE_MSG help file SE.HLP SE_HLP startup file SE.RC SE_RCAs an example, here is the command required to tell se to look in a file called HELP.SE in the directory C:\TOOLS whenever the user asks for help:
C> set se_hlp=C:\tools\help.seSimilar commands are used to set the other files up. Remember to put the set commands in your AUTOEXEC.BAT file so that they are executed each time you reboot.
When se reads a file, either with a e command or from the command line, it looks at the name of the file in order to determine what it contains. In most systems, the suffix of the file name is a good indication of the type. For instance, prog.p is a Pascal program whereas note.text is a file of plain text.
In the startup file se recognises a special construct consisting of a line beginning with a curly bracket {. This is followed by either the keyword LANG or TERM. The LANG keyword is followed by a list of file suffices. If the suffix of the file being read matches any of the suffices following the keyword, all the commands up to the next closing curly bracket } are executed; if not, they are ignored.
The TERM keyword does a similar job with terminal types.
An example of a typical startup file will make this clear. Note the use of a hash # to introduce comments:
# Startup file for 'se'
oa
# Pascal
{ LANG pas p
oia
ol$
}
# Documents
{ LANG txt doc
ol%
}
In this example, oa is obeyed no matter what kind of file
is being edited.
However, if a Pascal program is edited oia and ol$
are obeyed because the file suffices match.
If a text file is edited, ol% is obeyed.
If some other kind of file, with an unrecognised suffix,
is edited, the only effect is to obey the oa.
A slight problem arises with options like oa because they toggle the state of some option. Since the .RC file is read every time a new file is read into se, options like oa would not behave as desired. The problem is solved by a simple rule: before reading the .RC file, se restores all options to their default states. This means that all reserved words are erased, key bindings are put back to the default set, and default screen colours are set up. In addition, of course, toggle-type options such as oa, or, oc and oy are put back to a known state.
Any of se's commands or options may be put in the startup file. It is possible to arrange for different types of file to set up different colours for se's screen (on a colour system). Different prompts can be set; insert mode can be turned on.
The most powerful use of this ability is to put key-binding ob commands in the startup file. In this way, it is possible to customise the whole keyboard according to the work being done. Another example from the world of programming:
oa
{ LANG bas
ob[a-p]"PRINT"
ob[a-r]"RETURN"
ob[a-g]"GOSUB"
}
{ LANG c h
oia
ob[a-b]"break;"
ob[a-r]"return;"
ob[a-p]"printf ("
ob[a-u]"unsigned"
ob[a-i]kill_all "#include <stdio.h>"
}
The last example shows the use of the kill_all function to
ensure that the #include begins in column one.
In fact, an even better version would use the left cursor
function eight times to move the cursor back to the s,
ready for the user to overtype the filename.
In practice, you would put of and oc commands in the language-dependent blocks as well.
The message file contains, as the first line, the version number of se that it works with. This is to avoid the situation where a new version of the editor requires more messages than the previous version, but the old message file is still installed on the system. If you upgrade to a new version of se, and you want to use a specially-modified message file from the old version, make sure that you compare the lengths of the message files. New messages will normally be added to the end of the file and you should ensure that any extra ones from the new version are added to your old file.
We have already seen how environment variables are used to tell se where to find the message file. There is one special point to note about the file itself; it is possible to make a message ring the terminal's bell or bleeper. This is done by making the first character of the message a control-G character (ASCII 7, BEL). Two messages are normally modified in this way: No room for any more lines and Buffer hasn't been saved. These messages are severe enough to justify an audible warning. However, if the user objects to the noise all that is required is to remove the control-G characters from the message file. Note that another way to make se silent is to use the oq option. This has the effect of silencing all the bleeps normally produced, not just those that are specified by the message file.
When creating a modified or translated message file, remember that space on the status line is limited and messages should not be too long. In fact, a useful modification for experienced users is a file of terse messages.