Edit History - Maple Help

Command-Line Edit History

Description

 • In addition to allowing the command history to be traversed and searched as described in Command-Line Editing, the command-line version of Maple provides several commands for interactively manipulating that command history.

Definition of Terms

 • The following terms are used throughout the remainder of this page:

Command History

 The entire saved history of at most interface(historysize) commands. This is generally preserved between Maple sessions in the user's ".maple_history" file (or other file specified by interface(historyfile)).

Session History

 The tail of the command history consisting of just the commands that were entered in the current session. When a session starts, the session history is initially empty.

History Command

 One of the meta-commands described in this document for manipulating the command and session histories.
 • The following example is used to illustrate the history commands that follow. If, in the first session after installing Maple, you executed the commands,

 p1 := plot(sin): p2 := plot(cos): plots[display](p1,p2); quit;

and then in a second session, the commands,

 y := 1/(x^4+1); int(y,x); diff(%,x); simplify(%); normal(%,expanded);

then the command history would look like this (bottom is most recent):

 p1 := plot(sin): beginning of command history p2 := plot(cos): plots[display](p1,p2); y := 1/(x^4+1); beginning of session history int(y,x); diff(%,x); simplify(%); normal(%,expanded); current input line

 • Note that the final quit (or done or stop) command is not saved between sessions.

History Meta-Commands

 • The following are the history manipulation meta-commands. Each must begin with !! with no preceding whitespace, followed immediately by the character or word identifying the meta-command. Each command has a short single-character form, and a long word form. If an argument is specified, whitespace may precede the argument.
 • For those commands having an argument shown as specifier, the argument is optional. If present, it can be one of:
 • A positive integer, specifying how many lines of the history (beginning with the most recent) are to be affected.
 • A search string, preceded by a "/" character. All lines of the history from the most recent containing the string, to the most recent are affected. If the string does not begin with whitespace or a digit the "/" may be omitted.

!!= specifier

!!list specifier

 If invoked with a specifier, lists the specified range of non-history commands from the command history.
 If invoked without an argument, lists the entire session history.
 If a !!=specifier command is invoked as the first command in a session (i.e. before there is a session history), those lines are considered to be session history from that point on (internally, the session history pointer is moved backward to the first command that was selected by the specifier).
 To visually separate the displayed history from the rest of the session, each non-comment line is preceded by either << if interface(numberlines) is false, or by (*n*), where n is the numeric specifier currently corresponding to that line, if interface(numberlines) is true. Comment lines are displayed without any preceding annotation.

!!! specifier

!!play specifier

 If invoked with a specifier, plays back (reexecutes) the specified range of commands stored in the command history.
 If invoked with no argument, plays back all the commands in the session history.
 In both cases, the commands are not added to the history again.
 Like the !!=specifier command, if a !!!specifier command is invoked as the first command in session, the specified lines become session history.
 While history commands are being executed, each line is echoed, preceded by >> , a double default prompt. This is suppressed if interface(echo) is 0.
 In the example session, !!! would execute the five commands beginning with y := 1/(x^4+1);, and, !!!8 would reexecute the eight commands beginning with p1 := plot(sin):.

!!. specifier

!!step specifier

 This plays back the same commands that the corresponding !!! command would, but one step at a time. Each line is first displayed and made available for editing, and is not executed until the user presses Enter.
 Any changes made to the displayed command before pressing Enter will update the history in-place.
 Traversing the history during playback, whether using the up and down arrow keys, or the Ctrl-R search facility, will cancel playback if the command finally executed is outside the range of commands that were being played back. Otherwise, playback will resume from that point in the command history.
 During playback, entering any history meta-command will stop playback and process the new command. The null command, !!, will stop playback, do nothing else, and return to a normal prompt.

!!- specifier

!!drop specifier

 Drops the specified recent lines from the command history. If the specifier is omitted, removes one entry.
 In the example session, !!-3 would remove the diff, simplify, and normal commands from the history, as would !!-/diff.

!!< filename

 Replaces the current session history with the contents of the specified file. Those parts of the command history predating the current session are not affected.
 In the example session, the lines read from the file would replace the five commands beginning with y := 1/(x^4+1);.

!!+ filename

!!append filename

 Appends the contents of the specified file to the command history. This is similar to !!<, except that the existing session history, if any, is not replaced.

!!> filename

!!save filename

 Writes the session history into the specified file as plain text. This can be edited externally if desired. In the example session, the five commands beginning with y := 1/(x^4+1); would be written to the file.

!!?

!!help

 Lists a short summary of all the meta-commands, including information on how to find this help page.

!!

!!stop

 This meta-command does nothing, but if issued during a !!. playback, will stop the playback (as any history meta-command would do).
 Note that you would usually issue this meta-command when the input line is already displaying a Maple command for editing and reexecution. The !! command can be entered by just typing it, followed by a space at the beginning of such a line. The rest of the line will be ignored, and it will not be updated (i.e., it will be left as it was in the history).

Notes on the History Meta-Commands

 • The !! history meta-commands are themselves added to the history when invoked, however:
 • They are not saved between sessions in the ".maple_history" file.
 • They are not written to the file produced by the !!>filename command.
 • They are not counted when applying a numeric specifier.
 • They are ignored by a search specifier and the command line editor's search command (Ctrl-R).
 • They do not appear in history commands displayed by !!=.
 • They are not reexecuted by the !!! and !!/ commands.
 • If you foresee having to go back to specific places in the history repeatedly, entering short comment lines such as #a, #b, etc. will make it easy to refer to these locations. A command such as !!./#a, or the slightly shorter !!.#a, will start playback from that point.
 • If the user interface variable historytimestamp is set to true in the user's Maple initialization file, then a timestamp indicating the date and time that the current session began is inserted into the command history just prior to the session history (i.e., the session history still starts out empty in the fresh session). This timestamp, and those of older sessions, will appear as comments in the command history.