now handle doc subdir, too
[deliverable/binutils-gdb.git] / readline / history.texi
CommitLineData
681fa9a8
RP
1\input texinfo.tex
2@setfilename history.info
3
4@c start-menu
5* History: (history). The GNU History library.
6@c end-menu
7
8@ifinfo
9This file documents the GNU History library.
10
11Copyright (C) 1988 Free Software Foundation, Inc.
12Authored by Brian Fox.
13
14Permission is granted to make and distribute verbatim copies of this manual
15provided the copyright notice and this permission notice are preserved on
16all copies.
17
18@ignore
19Permission is granted to process this file through Tex and print the
20results, provided the printed document carries copying permission notice
21identical to this one except for the removal of this paragraph (this
22paragraph not being relevant to the printed manual).
23@end ignore
24
25Permission is granted to copy and distribute modified versions of this
26manual under the conditions for verbatim copying, provided also that the
27GNU Copyright statement is available to the distributee, and provided that
28the entire resulting derived work is distributed under the terms of a
29permission notice identical to this one.
30
31Permission is granted to copy and distribute translations of this manual
32into another language, under the above conditions for modified versions.
33@end ifinfo
34
35@node Top, Introduction, , (DIR)
36
37This document describes the GNU History library, a programming tool that
38provides a consistent user interface for recalling lines of previously
39typed input.
40
41@menu
42* Introduction:: What is the GNU History library for?
43* Interactive Use:: What it feels like using History as a user.
44* Programming:: How to use History in your programs.
45@end menu
46
47@node Introduction, Interactive Use, , Top
48@unnumbered Introduction
49
50Many programs read input from the user a line at a time. The GNU history
51library is able to keep track of those lines, associate arbitrary data with
52each line, and utilize information from previous lines in making up new
53ones.
54
55The programmer using the History library has available to him functions for
56remembering lines on a history stack, associating arbitrary data with a
57line, removing lines from the stack, searching through the stack for a
58line containing an arbitrary text string, and referencing any line on the
59stack directly. In addition, a history @dfn{expansion} function is
60available which provides for a consistent user interface across many
61different programs.
62
63The end-user using programs written with the History library has the
64benifit of a consistent user interface, with a set of well-known commands
65for manipulating the text of previous lines and using that text in new
66commands. The basic history manipulation commands are similar to the
67history substitution used by Csh.
68
69If the programmer desires, he can use the Readline library, which includes
70history manipulation by default, and has the added advantage of Emacs style
71command line editing.
72
73@node Interactive Use, Programming, Introduction, Top
74@chapter Interactive Use
75
76@section History Expansion
77@cindex expansion
78
79The History library provides a history expansion feature that is similar to
80the history expansion in Csh. The following text describes what syntax
81features are available.
82
83History expansion takes place in two parts. The first is to determine
84which line from the previous history should be used during substitution.
85The second is to select portions of that line for inclusion into the
86current one. The line selected from the previous history is called the
87@dfn{event}, and the portions of that line that are acted upon are called
88@dfn{words}. The line is broken into words in the same fashion that the
89Bash shell does, so that several English (or Unix) words surrounded by
90quotes are considered as one word.
91
92@menu
93* Event Designators:: How to specify which history line to use.
94* Word Designators:: Specifying which words are of interest.
95* Modifiers:: Modifying the results of susbstitution.
96@end menu
97
98@node Event Designators, Word Designators, , Interactive Use
99@subsection Event Designators
100@cindex event designators
101
102An event designator is a reference to a command line entry in the history
103list.
104
105@table @var
106
107@item !
108Start a history subsititution, except when followed by a @key{SPC},
109@key{TAB}, @key{RET}, @key{=} or @key{(}.
110
111@item !!
112Refer to the previous command. This is a synonym for @code{!-1}.
113
114@item !n
115Refer to command line @var{n}.
116
117@item !-n
118Refer to the current command line minus @var{n}.
119
120@item !string
121Refer to the most recent command starting with @var{string}.
122
123@item !?string[?]
124Refer to the most recent command containing @var{string}.
125
126@end table
127
128@node Word Designators, Modifiers, Event Designators, Interactive Use
129@subsection Word Designators
130
131A @key{:} separates the event specification from the word designator. It
132can be omitted if the word designator begins with a @key{^}, @key{$},
133@key{*} or @key{%}. Words are numbered from the beginning of the line,
134with the first word being denoted by a 0 (zero).
135
136@table @asis
137
138@item @var{0} (zero)
139The zero'th word. For many applications, this is the command word.
140
141@item n
142The @var{n}'th word.
143
144@item @var{^}
145The first argument. that is, word 1.
146
147@item @var{$}
148The last argument.
149
150@item @var{%}
151The word matched by the most recent @code{?string?} search.
152
153@item @var{x}-@var{y}
154A range of words; @code{-@var{y}} is equivalent to @code{0-@var{y}}.
155
156@item @var{*}
157All of the words, excepting the zero'th. This is a synonym for @samp{1-$}.
158It is not an error to use @samp{*} if there is just one word in the event.
159The empty string is returned in that case.
160
161@end table
162
163@node Modifiers, , Word Designators, Interactive Use
164@subsection Modifiers
165
166After the optional word designator, you can add a sequence of one or more
167of the following modifiers, each preceded by a @key{:}.
168
169@table @code
170
171@item #
172The entire command line typed so far. This means the current command,
173not the previous command, so it really isn't a word designator, and doesn't
174belong in this section.
175
176@item h
177Remove a trailing pathname component, leaving only the head.
178
179@item r
180Remove a trailing suffix of the form ".xxx", leaving the basename (root).
181
182@item e
183Remove all but the suffix (end).
184
185@item t
186Remove all leading pathname components (before the last slash), leaving
187the tail.
188
189@item p
190Print the new command but do not execute it. This takes effect
191immediately, so it should be the last specifier on the line.
192
193@end table
194
195@node Programming, , Interactive Use, Top
196@chapter Programming
197
198@bye
This page took 0.02949 seconds and 4 git commands to generate.