Go to the previous, next section.
It is often very useful to be able to repeat a command, or perhaps correct
a mistake in what you have just typed. Ways of doing this are usually
referred to as `history', and SM has two distinct mechanisms.
One is very similar to that of the Unix C-Shell,
and the other allows you to edit commands using a syntax similar to the popular
editor `emacs', or a generalisation of the DCL history under VMS.
If you are not familiar with Unix, emacs, or VMS don't despair; a
description of the commands and how to invoke them follows in this
document.
Both of these mechanisms are implemented by the routine which reads input
lines. As each line is sent to the parser, it is copied onto a
history list. This list may be printed with HISTORY
, and
the commands may be
re-used by referring to them by number, as ^nn
, or by a unique
abbreviation, as ^abbrev
. In addition, the last command may be
repeated by using ^^
and the last word of the last command by
^$
.@footnote #{ ^^
and ^$
really do get back the
last command typed, even if it isn't on the history list. If you
want the last remembered command, use up-arrow or ^P
}
These symbols are expanded as soon as they are recognised (see examples,
or experiment), and are then available for modification by the editor.
Sometimes a ^string
will retrieve a command beginning
string
, but not the one that you want. Version 2.1.1 no longer
supports the use of ^TAB
to search for the next-most-recent command beginning string
,
but you can use the search commands (^R and ^S) instead.
Some people really don't want ^
to be their
history character, either because they're used to something else (such
as !), or because they want to type lots of real ^
s (e.g. you are using
TeX-style strings); if this describes you, rebind them -- see the next
section.
If you are considering the history list as a sort of programme to be
repeated you may think that HISTORY
lists the commands in the
wrong order; if so use HISTORY -
.
For example, if I type:
PROMPT @ echo I like SM HISTORYSM will set the prompt to be
@
, replace the macro echo
by
its value WRITE STANDARD
and print
I like SMand then
3 HISTORY 2 echo I like SM 1 PROMPT @(The actual numbers will be different, depending on what other commands you have executed, and also because SM may have read a history file. In that case there'll be many more commands on the list, but no matter.) If I then type
^2 <CR>(that is ^2 not control-2) the screen will look like
@ echo I like SM I like SMas if I had just typed it in (
@
is the prompt) . Typing
^^ (Yes, ^$ ) <CR>will now result in SM printing (truthfully)
I like SM (Yes, SM )
It is possible to delete commands from the history buffer with the
DELETE
command. If the command is given with zero, one, or two
arguments, then
the specified range is deleted (but their numbers are not re-used). If
no arguments are given, the last command on the buffer is deleted, and
its number is released to be re-used. In other words, the command
DELETE
will delete first itself, and then the
previous command from the history list. The command DELETE HISTORY
only removes itself from the history list, and
several of the common commands are defined as macros which use it,
for instance dev
is defined as
DELETE HISTORY DEVICE
. This means that the command will not
appear on the history list, to confuse you when you do a playback. But
if you now innocently use dev
in a macro, that macro won't appear
on the list either. Still worse, if you use dev
twice in one
macro, the previous command will be deleted as well which could be quite
confusing.
You can also delete lines of history using ESC-^D
as
described shortly.
The numbering is consecutive, starting at zero. Each command retains its
number until you use a HISTORY
command to list the remembered
commands, in which case they are all renumbered, and it is these new numbers
that are listed.
By default only 80 lines are remembered, and as you continue typing earlier ones fall off the list.@findex history
Because the history buffer is also used to compose complex commands, this
limit can be aggravating. You may be able to defeat this by
putting many commands on
each line (you may have to use \n
to terminate label
commands explicitly)
or by writing macros. Alternatively you can define a longer history buffer
when you start SM by including an entry history
in your
environment file
which gives the number of commands to be remembered. If you set
history
to be 0
the history list is made infinitely long.
Incidently, it is
the total
number of commands that matters, not the range of history
numbers present.
This limit on the number of history lines isn't enforced while writing a
macro onto the history list (using WRITE HISTORY
). You can
use this fact to write a sneaky macro that extends your history; type
HELP extend_history
if you are interested.
Some people seem to like their history editors to remember where they were,
so that after they retrieve and execute a command the next ^P
or
will retrieve the command one further back on the
history list (that is, if you have just retrieved command number 123
and executed it as command number 234, then ^P will get you
command number 124; you can execute it as command number 235). If
this describes you, define the variable remember_history_line
,
which you can either do directly, or by putting a line
remember_history_line 1
in your `.sm' file.
The editor allows you to modify commands, either as you type them or as you retrieve them from the history list. The various editing commands may be bound to keys of your choosing, but the default bindings are given in this list of possible commands:
^A
^B
^C
^D
^E
^F
^H
^I (TAB)
tabsize
in your `.sm' file.
^J (LF)
^K
^L
^M (CR)
^N
^O
^P
^Q
^R
APROPOS
). If you specify a zero-length string
(i.e. simply hit carriage return) the previous search string will be reused.
^S
^T
^U
^V
^W
^Y
^Z
^? (DEL)
ESC-^D
ESC-<
ESC->
ESC-g
ESC-q
ESC-s
ESC-v
ESC-y
Some ESC-letter combinations are available which operate upon complete words. A word is defined as a whitespace delimited string, so 2.998e8 is a perfectly good word. In addition, it is possible to undelete words that have been deleted with an ESC-d or ESC-h.
ESC-b
ESC-d
ESC-f
ESC-h
ESC-u
ESC-u
's will restore more words. When no more are
available, the bell is rung.
Any printing character is inserted before the cursor (unless overwrite has been set with ^T ). Illegal characters ring the terminal bell. If you insert a non-printing character on a line, the cursor may get confused.
If ever you are stuck at the command interpreter, and you want to send
a signal to the operating system (e.g. a ^Y to DCL), but
SM is catching the key and using it for its own purposes, the
easiest thing to do is to define a macro such as
MACRO aa {aa2
, and then run it. While it is running (i.e.
until you type ^C) keys should have their usual functions.
Go to the previous, next section.