home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / doc / history.n < prev    next >
Text File  |  1993-05-03  |  7KB  |  182 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/history.n,v 1.1 93/05/03 17:09:47 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS history tcl
  25. .BS
  26. '\" Note:  do not modify the .SH NAME line immediately below!
  27. .SH NAME
  28. history \- Manipulate the history list
  29. .SH SYNOPSIS
  30. \fBhistory \fR?\fIoption\fR? ?\fIarg arg ...\fR?
  31. .BE
  32.  
  33. .SH DESCRIPTION
  34. .PP
  35. The \fBhistory\fR command performs one of several operations related to
  36. recently-executed commands recorded in a history list.  Each of
  37. these recorded commands is referred to as an ``event''.  When
  38. specifying an event to the \fBhistory\fR command, the following
  39. forms may be used:
  40. .IP [1]
  41. A number:  if positive, it refers to the event with
  42. that number (all events are numbered starting at 1).  If the number
  43. is negative, it selects an event relative to the current event
  44. (\fB\-1\fR refers to the previous event, \fB\-2\fR to the one before that, and
  45. so on).
  46. .IP [2]
  47. A string:  selects the most recent event that matches the string.
  48. An event is considered to match the string either if the string is
  49. the same as the first characters of the event, or if the string
  50. matches the event in the sense of the \fBstring match\fR command.
  51. .LP
  52. The \fBhistory\fR command can take any of the following forms:
  53. .TP
  54. \fBhistory\fR
  55. Same
  56. as \fBhistory info\fR, described below.
  57. .TP
  58. \fBhistory add\fI command \fR?\fBexec\fR?
  59. Adds the \fIcommand\fR argument to the history list as a new event.  If
  60. \fBexec\fR is specified (or abbreviated) then the command is also
  61. executed and its result is returned.  If \fBexec\fR isn't specified
  62. then an empty string is returned as result.
  63. .TP
  64. \fBhistory change\fI newValue\fR ?\fIevent\fR?
  65. Replaces the value recorded for an event with \fInewValue\fR.  \fIEvent\fR
  66. specifies the event to replace, and
  67. defaults to the \fIcurrent\fR event (not event \fB\-1\fR).  This command
  68. is intended for use in commands that implement new forms of history
  69. substitution and wish to replace the current event (which invokes the
  70. substitution) with the command created through substitution.  The return
  71. value is an empty string.
  72. .TP
  73. \fBhistory event\fR ?\fIevent\fR?
  74. Returns the value of the event given by \fIevent\fR.  \fIEvent\fR
  75. defaults to \fB\-1\fR.  This command causes history revision to occur:
  76. see below for details.
  77. .TP
  78. \fBhistory info \fR?\fIcount\fR?
  79. Returns a formatted string (intended for humans to read) giving
  80. the event number and contents for each of the events in the history
  81. list except the current event.  If \fIcount\fR is specified
  82. then only the most recent \fIcount\fR events are returned.
  83. .TP
  84. \fBhistory keep \fIcount\fR
  85. This command may be used to change the size of the history list to
  86. \fIcount\fR events.  Initially, 20 events are retained in the history
  87. list.  This command returns an empty string.
  88. .TP
  89. \fBhistory nextid\fR
  90. Returns the number of the next event to be recorded
  91. in the history list.  It is useful for things like printing the
  92. event number in command-line prompts.
  93. .TP
  94. \fBhistory redo \fR?\fIevent\fR?
  95. Re-executes the command indicated by \fIevent\fR and return its result.
  96. \fIEvent\fR defaults to \fB\-1\fR.  This command results in history
  97. revision:  see below for details.
  98. .TP
  99. \fBhistory substitute \fIold new \fR?\fIevent\fR?
  100. Retrieves the command given by \fIevent\fR
  101. (\fB\-1\fR by default), replace any occurrences of \fIold\fR by
  102. \fInew\fR in the command (only simple character equality is supported;
  103. no wild cards), execute the resulting command, and return the result
  104. of that execution.  This command results in history
  105. revision:  see below for details.
  106. .TP
  107. \fBhistory words \fIselector\fR ?\fIevent\fR?
  108. Retrieves from the command given by \fIevent\fR (\fB\-1\fR by default)
  109. the words given by \fIselector\fR, and return those words in a string
  110. separated by spaces.  The \fBselector\fR argument has three forms.
  111. If it is a single number then it selects the word given by that
  112. number (\fB0\fR for the command name, \fB1\fR for its first argument,
  113. and so on).  If it consists of two numbers separated by a dash,
  114. then it selects all the arguments between those two.  Otherwise
  115. \fBselector\fR is treated as a pattern; all words matching that
  116. pattern (in the sense of \fBstring match\fR) are returned.  In
  117. the numeric forms \fB$\fR may be used
  118. to select the last word of a command.
  119. For example, suppose the most recent command in the history list is
  120. .RS
  121. .DS
  122. \fBformat  {%s is %d years old} Alice [expr $ageInMonths/12]\fR
  123. .DE
  124. Below are some history commands and the results they would produce:
  125. .DS
  126. .ta 4c
  127. .fi
  128. .UL Command "    "
  129. .UL Result
  130. .nf
  131.  
  132. \fBhistory words $    [expr $ageInMonths/12]\fR
  133. \fBhistory words 1-2    {%s is %d years  old} Alice\fR
  134. \fBhistory words *a*o*    {%s is %d years old} [expr $ageInMonths/12]\fR
  135. .DE
  136. \fBHistory words\fR results in history revision:  see below for details.
  137. .RE
  138. .SH "HISTORY REVISION"
  139. .PP
  140. The history options \fBevent\fR, \fBredo\fR, \fBsubstitute\fR,
  141. and \fBwords\fR result in ``history revision''.
  142. When one of these options is invoked then the current event
  143. is modified to eliminate the history command and replace it with
  144. the result of the history command.
  145. For example, suppose that the most recent command in the history
  146. list is
  147. .DS
  148. \fBset a [expr $b+2]\fR
  149. .DE
  150. and suppose that the next command invoked is one of the ones on
  151. the left side of the table below.  The command actually recorded in
  152. the history event will be the corresponding one on the right side
  153. of the table.
  154. .ne 1.5c
  155. .DS
  156. .ta 4c
  157. .fi
  158. .UL "Command Typed" "    "
  159. .UL "Command Recorded"
  160. .nf
  161.  
  162. \fBhistory redo    set a [expr $b+2]\fR
  163. \fBhistory s a b    set b [expr $b+2]\fR
  164. \fBset c [history w 2]    set c [expr $b+2]\fR
  165. .DE
  166. History revision is needed because event specifiers like \fB\-1\fR
  167. are only valid at a particular time:  once more events have been
  168. added to the history list a different event specifier would be
  169. needed.
  170. History revision occurs even when \fBhistory\fR is invoked
  171. indirectly from the current event (e.g. a user types a command
  172. that invokes a Tcl procedure that invokes \fBhistory\fR):  the
  173. top-level command whose execution eventually resulted in a
  174. \fBhistory\fR command is replaced.
  175. If you wish to invoke commands like \fBhistory words\fR without
  176. history revision, you can use \fBhistory event\fR to save the
  177. current history event and then use \fBhistory change\fR to
  178. restore it later.
  179.  
  180. .SH KEYWORDS
  181. event, history, record, revision
  182.