History

Magma provides a history system which allows the recall and editing of previous lines. The history system is invoked by typing commands which begin with the history character `%'. Currently, the following commands are available.

%p
List the contents of the history buffer. Each line is preceded by its history line number.
%pn
List the history line n in %p format.
%pn1 n2
List the history lines in the range n1 to n2 in %p format.
%P
List the contents of the history buffer. The initial numbers are not printed.
%Pn
List the history line n in %P format.
%Pn1 n2
List the history lines in the range n1 to n2 in %P format.
%s
List the contents of the history buffer with an initial statement for each line to reset the random number seed to the value it was just before the line was executed. This is useful when one wishes to redo a computation using exactly the same seed as before but does not know what the seed was at the time.
%sn
Print the history line n in %s format.
%sn1 n2
Print the history lines in the range n1 to n2 in %s format.
%S
As for %s except that the statement to set the seed is only printed if the seed has changed since the previous time it was printed. Also, it is not printed if it would appear in the middle of a statement (i.e., the last line did not end in a semicolon).
%Sn
Print the history line n in %S format.
%Sn1 n2
Print the history lines in the range n1 to n2 in %S format.
%
Reenter the last line into the input stream.
%n
Reenter the line specified by line number n into the input stream.
%n1 n2
Reenter the history lines in the range n1 to n2 into the input stream.
%e
Edit the last line. The editor is taken to be the value of the EDITOR environment variable if is set, otherwise "/bin/ed" is used. If after the editor has exited the file has not been changed then nothing is done. Otherwise the contents of the new file are reentered into the input stream.
%en
Edit the line specified by line number n.
%en1 n2
Edit the history lines in the range n1 to n2.
%! shell-command
Execute the given command in the Unix shell then return to Magma.
V2.28, 13 July 2023