Debian Codegraph @

doc/history.n

raw
1 '\"
2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\"
8 .TH history n "" Tcl "Tcl Built-In Commands"
9 .so man.macros
10 .BS
11 '\" Note: do not modify the .SH NAME line immediately below!
12 .SH NAME
13 history \- Manipulate the history list
14 .SH SYNOPSIS
15 \fBhistory \fR?\fIoption\fR? ?\fIarg arg ...\fR?
16 .BE
17 .SH DESCRIPTION
18 .PP
19 The \fBhistory\fR command performs one of several operations related to
20 recently-executed commands recorded in a history list. Each of
21 these recorded commands is referred to as an
22 .QW event .
23 When specifying an event to the \fBhistory\fR command, the following
24 forms may be used:
25 .IP [1]
26 A number: if positive, it refers to the event with
27 that number (all events are numbered starting at 1). If the number
28 is negative, it selects an event relative to the current event
29 (\fB\-1\fR refers to the previous event, \fB\-2\fR to the one before that, and
30 so on). Event \fB0\fR refers to the current event.
31 .IP [2]
32 A string: selects the most recent event that matches the string.
33 An event is considered to match the string either if the string is
34 the same as the first characters of the event, or if the string
35 matches the event in the sense of the \fBstring match\fR command.
36 .PP
37 The \fBhistory\fR command can take any of the following forms:
38 .TP
39 \fBhistory\fR
40 Same
41 as \fBhistory info\fR, described below.
42 .TP
43 \fBhistory add\fI command \fR?\fBexec\fR?
44 Adds the \fIcommand\fR argument to the history list as a new event. If
45 \fBexec\fR is specified (or abbreviated) then the command is also
46 executed and its result is returned. If \fBexec\fR is not specified
47 then an empty string is returned as result.
48 .TP
49 \fBhistory change\fI newValue\fR ?\fIevent\fR?
50 Replaces the value recorded for an event with \fInewValue\fR. \fIEvent\fR
51 specifies the event to replace, and
52 defaults to the \fIcurrent\fR event (not event \fB\-1\fR). This command
53 is intended for use in commands that implement new forms of history
54 substitution and wish to replace the current event (which invokes the
55 substitution) with the command created through substitution. The return
56 value is an empty string.
57 .TP
58 \fBhistory clear\fR
59 Erase the history list. The current keep limit is retained.
60 The history event numbers are reset.
61 .TP
62 \fBhistory event\fR ?\fIevent\fR?
63 Returns the value of the event given by \fIevent\fR. \fIEvent\fR
64 defaults to \fB\-1\fR.
65 .TP
66 \fBhistory info \fR?\fIcount\fR?
67 Returns a formatted string (intended for humans to read) giving
68 the event number and contents for each of the events in the history
69 list except the current event. If \fIcount\fR is specified
70 then only the most recent \fIcount\fR events are returned.
71 .TP
72 \fBhistory keep \fR?\fIcount\fR?
73 This command may be used to change the size of the history list to
74 \fIcount\fR events. Initially, 20 events are retained in the history
75 list. If \fIcount\fR is not specified, the current keep limit is returned.
76 .TP
77 \fBhistory nextid\fR
78 Returns the number of the next event to be recorded
79 in the history list. It is useful for things like printing the
80 event number in command-line prompts.
81 .TP
82 \fBhistory redo \fR?\fIevent\fR?
83 Re-executes the command indicated by \fIevent\fR and returns its result.
84 \fIEvent\fR defaults to \fB\-1\fR. This command results in history
85 revision: see below for details.
86 .SH "HISTORY REVISION"
87 .PP
88 Pre-8.0 Tcl had a complex history revision mechanism.
89 The current mechanism is more limited, and the old
90 history operations \fBsubstitute\fR and \fBwords\fR have been removed.
91 (As a consolation, the \fBclear\fR operation was added.)
92 .PP
93 The history option \fBredo\fR results in much simpler
94 .QW "history revision" .
95 When this option is invoked then the most recent event
96 is modified to eliminate the history command and replace it with
97 the result of the history command.
98 If you want to redo an event without modifying history, then use
99 the \fBevent\fR operation to retrieve some event,
100 and the \fBadd\fR operation to add it to history and execute it.
101 .SH KEYWORDS
102 event, history, record