2 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
3 <!-- Created on June, 27 2002 by texi2html 1.64 -->
5 Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
6 Karl Berry <karl@freefriends.org>
7 Olaf Bachmann <obachman@mathematik.uni-kl.de>
9 Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
10 Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
14 <TITLE>GNU History Library:
</TITLE>
16 <META NAME=
"description" CONTENT=
"GNU History Library: ">
17 <META NAME=
"keywords" CONTENT=
"GNU History Library: ">
18 <META NAME=
"resource-type" CONTENT=
"document">
19 <META NAME=
"distribution" CONTENT=
"global">
20 <META NAME=
"Generator" CONTENT=
"texi2html 1.64">
24 <BODY LANG=
"" BGCOLOR=
"#FFFFFF" TEXT=
"#000000" LINK=
"#0000FF" VLINK=
"#800080" ALINK=
"#FF0000">
26 <A NAME=
"SEC_Top"></A>
27 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
28 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
29 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
30 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
31 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
33 <H1>GNU History Library
</H1></P><P>
35 This document describes the GNU History library, a programming tool that
36 provides a consistent user interface for recalling lines of previously
40 <BLOCKQUOTE><TABLE BORDER=
0 CELLSPACING=
0>
41 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC1">1. Using History Interactively
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">GNU History User's Manual.
</TD></TR>
42 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC6">2. Programming with GNU History
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">GNU History Programmer's Manual.
</TD></TR>
43 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC19">A. Concept Index
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Index of concepts described in this manual.
</TD></TR>
44 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC20">B. Function and Variable Index
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Index of externally visible functions
45 and variables.
</TD></TR>
51 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
52 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top"> < </A>]
</TD>
53 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC2"> > </A>]
</TD>
54 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<< ]
</TD>
55 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top"> Up
</A>]
</TD>
56 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> >> </A>]
</TD>
57 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
58 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
59 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
60 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
62 <A NAME=
"Using History Interactively"></A>
63 <H1> 1. Using History Interactively
</H1>
67 This chapter describes how to use the GNU History Library interactively,
68 from a user's standpoint. It should be considered a user's guide. For
69 information on using the GNU History Library in your own programs,
70 see section
<A HREF=
"history.html#SEC6">2. Programming with GNU History
</A>.
73 <BLOCKQUOTE><TABLE BORDER=
0 CELLSPACING=
0>
74 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC2">1.1 History Expansion
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">What it feels like using History as a user.
</TD></TR>
78 <A NAME=
"History Interaction"></A>
81 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
82 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC1"> < </A>]
</TD>
83 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC3"> > </A>]
</TD>
84 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<< ]
</TD>
85 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC1"> Up
</A>]
</TD>
86 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> >> </A>]
</TD>
87 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
88 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
89 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
90 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
92 <H2> 1.1 History Expansion
</H2>
96 The History library provides a history expansion feature that is similar
97 to the history expansion provided by
<CODE>csh
</CODE>. This section
98 describes the syntax used to manipulate the history information.
101 History expansions introduce words from the history list into
102 the input stream, making it easy to repeat commands, insert the
103 arguments to a previous command into the current input line, or
104 fix errors in previous commands quickly.
107 History expansion takes place in two parts. The first is to determine
108 which line from the history list should be used during substitution.
109 The second is to select portions of that line for inclusion into the
110 current one. The line selected from the history is called the
111 <EM>event
</EM>, and the portions of that line that are acted upon are
112 called
<EM>words
</EM>. Various
<EM>modifiers
</EM> are available to manipulate
113 the selected words. The line is broken into words in the same fashion
114 that Bash does, so that several words
115 surrounded by quotes are considered one word.
116 History expansions are introduced by the appearance of the
117 history expansion character, which is
<SAMP>`!'
</SAMP> by default.
120 <BLOCKQUOTE><TABLE BORDER=
0 CELLSPACING=
0>
121 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC3">1.1.1 Event Designators
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">How to specify which history line to use.
</TD></TR>
122 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC4">1.1.2 Word Designators
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Specifying which words are of interest.
</TD></TR>
123 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC5">1.1.3 Modifiers
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Modifying the results of substitution.
</TD></TR>
124 </TABLE></BLOCKQUOTE>
127 <A NAME=
"Event Designators"></A>
130 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
131 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC2"> < </A>]
</TD>
132 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC4"> > </A>]
</TD>
133 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<< ]
</TD>
134 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC2"> Up
</A>]
</TD>
135 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> >> </A>]
</TD>
136 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
137 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
138 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
139 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
141 <H3> 1.1.1 Event Designators
</H3>
145 An event designator is a reference to a command line entry in the
153 <DD>Start a history substitution, except when followed by a space, tab,
154 the end of the line,
<SAMP>`='
</SAMP> or
<SAMP>`('
</SAMP>.
157 <DT><CODE>!
<VAR>n
</VAR></CODE>
158 <DD>Refer to command line
<VAR>n
</VAR>.
161 <DT><CODE>!-
<VAR>n
</VAR></CODE>
162 <DD>Refer to the command
<VAR>n
</VAR> lines back.
166 <DD>Refer to the previous command. This is a synonym for
<SAMP>`!-
1'
</SAMP>.
169 <DT><CODE>!
<VAR>string
</VAR></CODE>
170 <DD>Refer to the most recent command starting with
<VAR>string
</VAR>.
173 <DT><CODE>!?
<VAR>string
</VAR>[?]
</CODE>
174 <DD>Refer to the most recent command containing
<VAR>string
</VAR>. The trailing
175 <SAMP>`?'
</SAMP> may be omitted if the
<VAR>string
</VAR> is followed immediately by
179 <DT><CODE>^
<VAR>string1
</VAR>^
<VAR>string2
</VAR>^
</CODE>
180 <DD>Quick Substitution. Repeat the last command, replacing
<VAR>string1
</VAR>
181 with
<VAR>string2
</VAR>. Equivalent to
182 <CODE>!!:s/
<VAR>string1
</VAR>/
<VAR>string2
</VAR>/
</CODE>.
186 <DD>The entire command line typed so far.
192 <A NAME=
"Word Designators"></A>
195 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
196 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC3"> < </A>]
</TD>
197 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC5"> > </A>]
</TD>
198 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC5"> << </A>]
</TD>
199 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC2"> Up
</A>]
</TD>
200 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> >> </A>]
</TD>
201 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
202 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
203 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
204 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
206 <H3> 1.1.2 Word Designators
</H3>
210 Word designators are used to select desired words from the event.
211 A
<SAMP>`:'
</SAMP> separates the event specification from the word designator. It
212 may be omitted if the word designator begins with a
<SAMP>`^'
</SAMP>,
<SAMP>`$'
</SAMP>,
213 <SAMP>`*'
</SAMP>,
<SAMP>`-'
</SAMP>, or
<SAMP>`%'
</SAMP>. Words are numbered from the beginning
214 of the line, with the first word being denoted by
0 (zero). Words are
215 inserted into the current line separated by single spaces.
223 <DD>designates the preceding command. When you type this, the preceding
224 command is repeated in toto.
227 <DT><CODE>!!:$
</CODE>
228 <DD>designates the last argument of the preceding command. This may be
229 shortened to
<CODE>!$
</CODE>.
232 <DT><CODE>!fi:
2</CODE>
233 <DD>designates the second argument of the most recent command starting with
234 the letters
<CODE>fi
</CODE>.
238 Here are the word designators:
242 <DT><CODE>0 (zero)
</CODE>
243 <DD>The
<CODE>0</CODE>th word. For many applications, this is the command word.
246 <DT><CODE><VAR>n
</VAR></CODE>
247 <DD>The
<VAR>n
</VAR>th word.
251 <DD>The first argument; that is, word
1.
255 <DD>The last argument.
259 <DD>The word matched by the most recent
<SAMP>`?
<VAR>string
</VAR>?'
</SAMP> search.
262 <DT><CODE><VAR>x
</VAR>-
<VAR>y
</VAR></CODE>
263 <DD>A range of words;
<SAMP>`-
<VAR>y
</VAR>'
</SAMP> abbreviates
<SAMP>`
0-
<VAR>y
</VAR>'
</SAMP>.
267 <DD>All of the words, except the
<CODE>0</CODE>th. This is a synonym for
<SAMP>`
1-$'
</SAMP>.
268 It is not an error to use
<SAMP>`*'
</SAMP> if there is just one word in the event;
269 the empty string is returned in that case.
272 <DT><CODE><VAR>x
</VAR>*
</CODE>
273 <DD>Abbreviates
<SAMP>`
<VAR>x
</VAR>-$'
</SAMP>
276 <DT><CODE><VAR>x
</VAR>-
</CODE>
277 <DD>Abbreviates
<SAMP>`
<VAR>x
</VAR>-$'
</SAMP> like
<SAMP>`
<VAR>x
</VAR>*'
</SAMP>, but omits the last word.
283 If a word designator is supplied without an event specification, the
284 previous command is used as the event.
287 <A NAME=
"Modifiers"></A>
290 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
291 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC4"> < </A>]
</TD>
292 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> > </A>]
</TD>
293 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<< ]
</TD>
294 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC2"> Up
</A>]
</TD>
295 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> >> </A>]
</TD>
296 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
297 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
298 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
299 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
301 <H3> 1.1.3 Modifiers
</H3>
305 After the optional word designator, you can add a sequence of one or more
306 of the following modifiers, each preceded by a
<SAMP>`:'
</SAMP>.
312 <DD>Remove a trailing pathname component, leaving only the head.
316 <DD>Remove all leading pathname components, leaving the tail.
320 <DD>Remove a trailing suffix of the form
<SAMP>`.
<VAR>suffix
</VAR>'
</SAMP>, leaving
325 <DD>Remove all but the trailing suffix.
329 <DD>Print the new command but do not execute it.
332 <DT><CODE>s/
<VAR>old
</VAR>/
<VAR>new
</VAR>/
</CODE>
333 <DD>Substitute
<VAR>new
</VAR> for the first occurrence of
<VAR>old
</VAR> in the
334 event line. Any delimiter may be used in place of
<SAMP>`/'
</SAMP>.
335 The delimiter may be quoted in
<VAR>old
</VAR> and
<VAR>new
</VAR>
336 with a single backslash. If
<SAMP>`
&'
</SAMP> appears in
<VAR>new
</VAR>,
337 it is replaced by
<VAR>old
</VAR>. A single backslash will quote
338 the
<SAMP>`
&'
</SAMP>. The final delimiter is optional if it is the last
339 character on the input line.
342 <DT><CODE>&</CODE>
343 <DD>Repeat the previous substitution.
347 <DD>Cause changes to be applied over the entire event line. Used in
348 conjunction with
<SAMP>`s'
</SAMP>, as in
<CODE>gs/
<VAR>old
</VAR>/
<VAR>new
</VAR>/
</CODE>,
349 or with
<SAMP>`
&'
</SAMP>.
355 <A NAME=
"Programming with GNU History"></A>
358 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
359 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC5"> < </A>]
</TD>
360 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC7"> > </A>]
</TD>
361 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<< ]
</TD>
362 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top"> Up
</A>]
</TD>
363 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19"> >> </A>]
</TD>
364 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
365 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
366 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
367 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
369 <H1> 2. Programming with GNU History
</H1>
373 This chapter describes how to interface programs that you write
374 with the GNU History Library.
375 It should be considered a technical guide.
376 For information on the interactive use of GNU History, see section
<A HREF=
"history.html#SEC1">1. Using History Interactively
</A>.
379 <BLOCKQUOTE><TABLE BORDER=
0 CELLSPACING=
0>
380 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC7">2.1 Introduction to History
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">What is the GNU History library for?
</TD></TR>
381 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC8">2.2 History Storage
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">How information is stored.
</TD></TR>
382 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC9">2.3 History Functions
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Functions that you can use.
</TD></TR>
383 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Variables that control behaviour.
</TD></TR>
384 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC18">2.5 History Programming Example
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Example of using the GNU History Library.
</TD></TR>
385 </TABLE></BLOCKQUOTE>
388 <A NAME=
"Introduction to History"></A>
391 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
392 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> < </A>]
</TD>
393 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC8"> > </A>]
</TD>
394 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<< ]
</TD>
395 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> Up
</A>]
</TD>
396 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19"> >> </A>]
</TD>
397 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
398 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
399 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
400 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
402 <H2> 2.1 Introduction to History
</H2>
406 Many programs read input from the user a line at a time. The GNU
407 History library is able to keep track of those lines, associate arbitrary
408 data with each line, and utilize information from previous lines in
412 The programmer using the History library has available functions
413 for remembering lines on a history list, associating arbitrary data
414 with a line, removing lines from the list, searching through the list
415 for a line containing an arbitrary text string, and referencing any line
416 in the list directly. In addition, a history
<EM>expansion
</EM> function
417 is available which provides for a consistent user interface across
421 The user using programs written with the History library has the
422 benefit of a consistent user interface with a set of well-known
423 commands for manipulating the text of previous lines and using that text
424 in new commands. The basic history manipulation commands are similar to
425 the history substitution provided by
<CODE>csh
</CODE>.
428 If the programmer desires, he can use the Readline library, which
429 includes some history manipulation by default, and has the added
430 advantage of command line editing.
433 Before declaring any functions using any functionality the History
434 library provides in other code, an application writer should include
435 the file
<CODE><readline/history.h
></CODE> in any file that uses the
436 History library's features. It supplies extern declarations for all
437 of the library's public functions and variables, and declares all of
438 the public data structures.
441 <A NAME=
"History Storage"></A>
444 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
445 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC7"> < </A>]
</TD>
446 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> > </A>]
</TD>
447 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> << </A>]
</TD>
448 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> Up
</A>]
</TD>
449 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19"> >> </A>]
</TD>
450 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
451 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
452 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
453 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
455 <H2> 2.2 History Storage
</H2>
459 The history list is an array of history entries. A history entry is
463 <TABLE><tr><td> </td><td class=example
><pre>typedef void *histdata_t;
465 typedef struct _hist_entry {
469 </pre></td></tr></table></P><P>
471 The history list itself might therefore be declared as
474 <TABLE><tr><td> </td><td class=example
><pre>HIST_ENTRY **the_history_list;
475 </pre></td></tr></table></P><P>
477 The state of the History library is encapsulated into a single structure:
480 <TABLE><tr><td> </td><td class=example
><pre>/*
481 * A structure used to pass around the current state of the history.
483 typedef struct _hist_state {
484 HIST_ENTRY **entries; /* Pointer to the entries themselves. */
485 int offset; /* The location pointer within this array. */
486 int length; /* Number of elements within this array. */
487 int size; /* Number of slots allocated to this array. */
490 </pre></td></tr></table></P><P>
492 If the flags member includes
<CODE>HS_STIFLED
</CODE>, the history has been
496 <A NAME=
"History Functions"></A>
499 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
500 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC8"> < </A>]
</TD>
501 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC10"> > </A>]
</TD>
502 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> << </A>]
</TD>
503 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> Up
</A>]
</TD>
504 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> >> </A>]
</TD>
505 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
506 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
507 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
508 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
510 <H2> 2.3 History Functions
</H2>
514 This section describes the calling sequence for the various functions
515 exported by the GNU History library.
518 <BLOCKQUOTE><TABLE BORDER=
0 CELLSPACING=
0>
519 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC10">2.3.1 Initializing History and State Management
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Functions to call when you
520 want to use history in a
522 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC11">2.3.2 History List Management
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Functions used to manage the list
523 of history entries.
</TD></TR>
524 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC12">2.3.3 Information About the History List
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Functions returning information about
525 the history list.
</TD></TR>
526 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC13">2.3.4 Moving Around the History List
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Functions used to change the position
527 in the history list.
</TD></TR>
528 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC14">2.3.5 Searching the History List
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Functions to search the history list
529 for entries containing a string.
</TD></TR>
530 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC15">2.3.6 Managing the History File
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Functions that read and write a file
531 containing the history list.
</TD></TR>
532 <TR><TD ALIGN=
"left" VALIGN=
"TOP"><A HREF=
"history.html#SEC16">2.3.7 History Expansion
</A></TD><TD> </TD><TD ALIGN=
"left" VALIGN=
"TOP">Functions to perform csh-like history
534 </TABLE></BLOCKQUOTE>
537 <A NAME=
"Initializing History and State Management"></A>
540 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
541 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> < </A>]
</TD>
542 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC11"> > </A>]
</TD>
543 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> << </A>]
</TD>
544 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> Up
</A>]
</TD>
545 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> >> </A>]
</TD>
546 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
547 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
548 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
549 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
551 <H3> 2.3.1 Initializing History and State Management
</H3>
552 <!--docid::SEC10::-->
555 This section describes functions used to initialize and manage
556 the state of the History library when you want to use the history
557 functions in your program.
562 <DT><U>Function:
</U> void
<B>using_history
</B> <I>(void)
</I>
563 <DD>Begin a session in which the history functions might be used. This
564 initializes the interactive variables.
570 <DT><U>Function:
</U> HISTORY_STATE *
<B>history_get_history_state
</B> <I>(void)
</I>
571 <DD>Return a structure describing the current state of the input history.
577 <DT><U>Function:
</U> void
<B>history_set_history_state
</B> <I>(HISTORY_STATE *state)
</I>
578 <DD>Set the state of the history list according to
<VAR>state
</VAR>.
582 <A NAME=
"History List Management"></A>
585 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
586 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC10"> < </A>]
</TD>
587 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC12"> > </A>]
</TD>
588 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC12"> << </A>]
</TD>
589 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> Up
</A>]
</TD>
590 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> >> </A>]
</TD>
591 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
592 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
593 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
594 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
596 <H3> 2.3.2 History List Management
</H3>
597 <!--docid::SEC11::-->
600 These functions manage individual entries on the history list, or set
601 parameters managing the list itself.
606 <DT><U>Function:
</U> void
<B>add_history
</B> <I>(const char *string)
</I>
607 <DD>Place
<VAR>string
</VAR> at the end of the history list. The associated data
608 field (if any) is set to
<CODE>NULL
</CODE>.
614 <DT><U>Function:
</U> HIST_ENTRY *
<B>remove_history
</B> <I>(int which)
</I>
615 <DD>Remove history entry at offset
<VAR>which
</VAR> from the history. The
616 removed element is returned so you can free the line, data,
617 and containing structure.
623 <DT><U>Function:
</U> HIST_ENTRY *
<B>replace_history_entry
</B> <I>(int which, const char *line, histdata_t data)
</I>
624 <DD>Make the history entry at offset
<VAR>which
</VAR> have
<VAR>line
</VAR> and
<VAR>data
</VAR>.
625 This returns the old entry so you can dispose of the data. In the case
626 of an invalid
<VAR>which
</VAR>, a
<CODE>NULL
</CODE> pointer is returned.
632 <DT><U>Function:
</U> void
<B>clear_history
</B> <I>(void)
</I>
633 <DD>Clear the history list by deleting all the entries.
639 <DT><U>Function:
</U> void
<B>stifle_history
</B> <I>(int max)
</I>
640 <DD>Stifle the history list, remembering only the last
<VAR>max
</VAR> entries.
646 <DT><U>Function:
</U> int
<B>unstifle_history
</B> <I>(void)
</I>
647 <DD>Stop stifling the history. This returns the previously-set
648 maximum number of history entries (as set by
<CODE>stifle_history()
</CODE>).
649 The value is positive if the history was
650 stifled, negative if it wasn't.
656 <DT><U>Function:
</U> int
<B>history_is_stifled
</B> <I>(void)
</I>
657 <DD>Returns non-zero if the history is stifled, zero if it is not.
661 <A NAME=
"Information About the History List"></A>
664 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
665 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC11"> < </A>]
</TD>
666 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC13"> > </A>]
</TD>
667 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC13"> << </A>]
</TD>
668 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> Up
</A>]
</TD>
669 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> >> </A>]
</TD>
670 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
671 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
672 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
673 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
675 <H3> 2.3.3 Information About the History List
</H3>
676 <!--docid::SEC12::-->
679 These functions return information about the entire history list or
680 individual list entries.
685 <DT><U>Function:
</U> HIST_ENTRY **
<B>history_list
</B> <I>(void)
</I>
686 <DD>Return a
<CODE>NULL
</CODE> terminated array of
<CODE>HIST_ENTRY *
</CODE> which is the
687 current input history. Element
0 of this list is the beginning of time.
688 If there is no history, return
<CODE>NULL
</CODE>.
694 <DT><U>Function:
</U> int
<B>where_history
</B> <I>(void)
</I>
695 <DD>Returns the offset of the current history element.
701 <DT><U>Function:
</U> HIST_ENTRY *
<B>current_history
</B> <I>(void)
</I>
702 <DD>Return the history entry at the current position, as determined by
703 <CODE>where_history()
</CODE>. If there is no entry there, return a
<CODE>NULL
</CODE>
710 <DT><U>Function:
</U> HIST_ENTRY *
<B>history_get
</B> <I>(int offset)
</I>
711 <DD>Return the history entry at position
<VAR>offset
</VAR>, starting from
712 <CODE>history_base
</CODE> (see section
<A HREF=
"history.html#SEC17">2.4 History Variables
</A>).
713 If there is no entry there, or if
<VAR>offset
</VAR>
714 is greater than the history length, return a
<CODE>NULL
</CODE> pointer.
720 <DT><U>Function:
</U> int
<B>history_total_bytes
</B> <I>(void)
</I>
721 <DD>Return the number of bytes that the primary history entries are using.
722 This function returns the sum of the lengths of all the lines in the
727 <A NAME=
"Moving Around the History List"></A>
730 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
731 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC12"> < </A>]
</TD>
732 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC14"> > </A>]
</TD>
733 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC14"> << </A>]
</TD>
734 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> Up
</A>]
</TD>
735 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> >> </A>]
</TD>
736 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
737 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
738 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
739 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
741 <H3> 2.3.4 Moving Around the History List
</H3>
742 <!--docid::SEC13::-->
745 These functions allow the current index into the history list to be
751 <DT><U>Function:
</U> int
<B>history_set_pos
</B> <I>(int pos)
</I>
752 <DD>Set the current history offset to
<VAR>pos
</VAR>, an absolute index
754 Returns
1 on success,
0 if
<VAR>pos
</VAR> is less than zero or greater
755 than the number of history entries.
761 <DT><U>Function:
</U> HIST_ENTRY *
<B>previous_history
</B> <I>(void)
</I>
762 <DD>Back up the current history offset to the previous history entry, and
763 return a pointer to that entry. If there is no previous entry, return
764 a
<CODE>NULL
</CODE> pointer.
770 <DT><U>Function:
</U> HIST_ENTRY *
<B>next_history
</B> <I>(void)
</I>
771 <DD>Move the current history offset forward to the next history entry, and
772 return the a pointer to that entry. If there is no next entry, return
773 a
<CODE>NULL
</CODE> pointer.
777 <A NAME=
"Searching the History List"></A>
780 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
781 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC13"> < </A>]
</TD>
782 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC15"> > </A>]
</TD>
783 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC15"> << </A>]
</TD>
784 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> Up
</A>]
</TD>
785 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> >> </A>]
</TD>
786 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
787 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
788 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
789 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
791 <H3> 2.3.5 Searching the History List
</H3>
792 <!--docid::SEC14::-->
795 These functions allow searching of the history list for entries containing
796 a specific string. Searching may be performed both forward and backward
797 from the current history position. The search may be
<EM>anchored
</EM>,
798 meaning that the string must match at the beginning of the history entry.
804 <DT><U>Function:
</U> int
<B>history_search
</B> <I>(const char *string, int direction)
</I>
805 <DD>Search the history for
<VAR>string
</VAR>, starting at the current history offset.
806 If
<VAR>direction
</VAR> is less than
0, then the search is through
807 previous entries, otherwise through subsequent entries.
808 If
<VAR>string
</VAR> is found, then
809 the current history index is set to that history entry, and the value
810 returned is the offset in the line of the entry where
811 <VAR>string
</VAR> was found. Otherwise, nothing is changed, and a -
1 is
818 <DT><U>Function:
</U> int
<B>history_search_prefix
</B> <I>(const char *string, int direction)
</I>
819 <DD>Search the history for
<VAR>string
</VAR>, starting at the current history
820 offset. The search is anchored: matching lines must begin with
821 <VAR>string
</VAR>. If
<VAR>direction
</VAR> is less than
0, then the search is
822 through previous entries, otherwise through subsequent entries.
823 If
<VAR>string
</VAR> is found, then the
824 current history index is set to that entry, and the return value is
0.
825 Otherwise, nothing is changed, and a -
1 is returned.
831 <DT><U>Function:
</U> int
<B>history_search_pos
</B> <I>(const char *string, int direction, int pos)
</I>
832 <DD>Search for
<VAR>string
</VAR> in the history list, starting at
<VAR>pos
</VAR>, an
833 absolute index into the list. If
<VAR>direction
</VAR> is negative, the search
834 proceeds backward from
<VAR>pos
</VAR>, otherwise forward. Returns the absolute
835 index of the history element where
<VAR>string
</VAR> was found, or -
1 otherwise.
839 <A NAME=
"Managing the History File"></A>
842 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
843 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC14"> < </A>]
</TD>
844 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC16"> > </A>]
</TD>
845 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC16"> << </A>]
</TD>
846 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> Up
</A>]
</TD>
847 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> >> </A>]
</TD>
848 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
849 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
850 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
851 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
853 <H3> 2.3.6 Managing the History File
</H3>
854 <!--docid::SEC15::-->
857 The History library can read the history from and write it to a file.
858 This section documents the functions for managing a history file.
863 <DT><U>Function:
</U> int
<B>read_history
</B> <I>(const char *filename)
</I>
864 <DD>Add the contents of
<VAR>filename
</VAR> to the history list, a line at a time.
865 If
<VAR>filename
</VAR> is
<CODE>NULL
</CODE>, then read from
<TT>`~/.history'
</TT>.
866 Returns
0 if successful, or
<CODE>errno
</CODE> if not.
872 <DT><U>Function:
</U> int
<B>read_history_range
</B> <I>(const char *filename, int from, int to)
</I>
873 <DD>Read a range of lines from
<VAR>filename
</VAR>, adding them to the history list.
874 Start reading at line
<VAR>from
</VAR> and end at
<VAR>to
</VAR>.
875 If
<VAR>from
</VAR> is zero, start at the beginning. If
<VAR>to
</VAR> is less than
876 <VAR>from
</VAR>, then read until the end of the file. If
<VAR>filename
</VAR> is
877 <CODE>NULL
</CODE>, then read from
<TT>`~/.history'
</TT>. Returns
0 if successful,
878 or
<CODE>errno
</CODE> if not.
884 <DT><U>Function:
</U> int
<B>write_history
</B> <I>(const char *filename)
</I>
885 <DD>Write the current history to
<VAR>filename
</VAR>, overwriting
<VAR>filename
</VAR>
887 If
<VAR>filename
</VAR> is
<CODE>NULL
</CODE>, then write the history list to
888 <TT>`~/.history'
</TT>.
889 Returns
0 on success, or
<CODE>errno
</CODE> on a read or write error.
895 <DT><U>Function:
</U> int
<B>append_history
</B> <I>(int nelements, const char *filename)
</I>
896 <DD>Append the last
<VAR>nelements
</VAR> of the history list to
<VAR>filename
</VAR>.
897 If
<VAR>filename
</VAR> is
<CODE>NULL
</CODE>, then append to
<TT>`~/.history'
</TT>.
898 Returns
0 on success, or
<CODE>errno
</CODE> on a read or write error.
904 <DT><U>Function:
</U> int
<B>history_truncate_file
</B> <I>(const char *filename, int nlines)
</I>
905 <DD>Truncate the history file
<VAR>filename
</VAR>, leaving only the last
906 <VAR>nlines
</VAR> lines.
907 If
<VAR>filename
</VAR> is
<CODE>NULL
</CODE>, then
<TT>`~/.history'
</TT> is truncated.
908 Returns
0 on success, or
<CODE>errno
</CODE> on failure.
912 <A NAME=
"History Expansion"></A>
915 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
916 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC15"> < </A>]
</TD>
917 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> > </A>]
</TD>
918 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> << </A>]
</TD>
919 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC9"> Up
</A>]
</TD>
920 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> >> </A>]
</TD>
921 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
922 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
923 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
924 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
926 <H3> 2.3.7 History Expansion
</H3>
927 <!--docid::SEC16::-->
930 These functions implement history expansion.
935 <DT><U>Function:
</U> int
<B>history_expand
</B> <I>(char *string, char **output)
</I>
936 <DD>Expand
<VAR>string
</VAR>, placing the result into
<VAR>output
</VAR>, a pointer
937 to a string (see section
<A HREF=
"history.html#SEC2">1.1 History Expansion
</A>). Returns:
940 <DD>If no expansions took place (or, if the only change in
941 the text was the removal of escape characters preceding the history expansion
944 <DD>if expansions did take place;
946 <DD>if there was an error in expansion;
948 <DD>if the returned line should be displayed, but not executed,
949 as with the
<CODE>:p
</CODE> modifier (see section
<A HREF=
"history.html#SEC5">1.1.3 Modifiers
</A>).
953 If an error ocurred in expansion, then
<VAR>output
</VAR> contains a descriptive
960 <DT><U>Function:
</U> char *
<B>get_history_event
</B> <I>(const char *string, int *cindex, int qchar)
</I>
961 <DD>Returns the text of the history event beginning at
<VAR>string
</VAR> +
962 <VAR>*cindex
</VAR>.
<VAR>*cindex
</VAR> is modified to point to after the event
963 specifier. At function entry,
<VAR>cindex
</VAR> points to the index into
964 <VAR>string
</VAR> where the history event specification begins.
<VAR>qchar
</VAR>
965 is a character that is allowed to end the event specification in addition
966 to the
"normal" terminating characters.
972 <DT><U>Function:
</U> char **
<B>history_tokenize
</B> <I>(const char *string)
</I>
973 <DD>Return an array of tokens parsed out of
<VAR>string
</VAR>, much as the
974 shell might. The tokens are split on the characters in the
975 <VAR>history_word_delimiters
</VAR> variable,
976 and shell quoting conventions are obeyed.
982 <DT><U>Function:
</U> char *
<B>history_arg_extract
</B> <I>(int first, int last, const char *string)
</I>
983 <DD>Extract a string segment consisting of the
<VAR>first
</VAR> through
<VAR>last
</VAR>
984 arguments present in
<VAR>string
</VAR>. Arguments are split using
985 <CODE>history_tokenize
</CODE>.
989 <A NAME=
"History Variables"></A>
992 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
993 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC16"> < </A>]
</TD>
994 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC18"> > </A>]
</TD>
995 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC18"> << </A>]
</TD>
996 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> Up
</A>]
</TD>
997 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19"> >> </A>]
</TD>
998 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
999 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
1000 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
1001 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
1003 <H2> 2.4 History Variables
</H2>
1004 <!--docid::SEC17::-->
1007 This section describes the externally-visible variables exported by
1008 the GNU History Library.
1011 <A NAME=
"IDX33"></A>
1013 <DT><U>Variable:
</U> int
<B>history_base
</B>
1014 <DD>The logical offset of the first entry in the history list.
1018 <A NAME=
"IDX34"></A>
1020 <DT><U>Variable:
</U> int
<B>history_length
</B>
1021 <DD>The number of entries currently stored in the history list.
1025 <A NAME=
"IDX35"></A>
1027 <DT><U>Variable:
</U> int
<B>history_max_entries
</B>
1028 <DD>The maximum number of history entries. This must be changed using
1029 <CODE>stifle_history()
</CODE>.
1033 <A NAME=
"IDX36"></A>
1035 <DT><U>Variable:
</U> char
<B>history_expansion_char
</B>
1036 <DD>The character that introduces a history event. The default is
<SAMP>`!'
</SAMP>.
1037 Setting this to
0 inhibits history expansion.
1041 <A NAME=
"IDX37"></A>
1043 <DT><U>Variable:
</U> char
<B>history_subst_char
</B>
1044 <DD>The character that invokes word substitution if found at the start of
1045 a line. The default is
<SAMP>`^'
</SAMP>.
1049 <A NAME=
"IDX38"></A>
1051 <DT><U>Variable:
</U> char
<B>history_comment_char
</B>
1052 <DD>During tokenization, if this character is seen as the first character
1053 of a word, then it and all subsequent characters up to a newline are
1054 ignored, suppressing history expansion for the remainder of the line.
1055 This is disabled by default.
1059 <A NAME=
"IDX39"></A>
1061 <DT><U>Variable:
</U> char *
<B>history_word_delimiters
</B>
1062 <DD>The characters that separate tokens for
<CODE>history_tokenize()
</CODE>.
1063 The default value is
<CODE>" \t\n()<>;&|"</CODE>.
1067 <A NAME=
"IDX40"></A>
1069 <DT><U>Variable:
</U> char *
<B>history_no_expand_chars
</B>
1070 <DD>The list of characters which inhibit history expansion if found immediately
1071 following
<VAR>history_expansion_char
</VAR>. The default is space, tab, newline,
1072 carriage return, and
<SAMP>`='
</SAMP>.
1076 <A NAME=
"IDX41"></A>
1078 <DT><U>Variable:
</U> char *
<B>history_search_delimiter_chars
</B>
1079 <DD>The list of additional characters which can delimit a history search
1080 string, in addition to space, TAB,
<SAMP>`:'
</SAMP> and
<SAMP>`?'
</SAMP> in the case of
1081 a substring search. The default is empty.
1085 <A NAME=
"IDX42"></A>
1087 <DT><U>Variable:
</U> int
<B>history_quotes_inhibit_expansion
</B>
1088 <DD>If non-zero, single-quoted words are not scanned for the history expansion
1089 character. The default value is
0.
1093 <A NAME=
"IDX43"></A>
1095 <DT><U>Variable:
</U> rl_linebuf_func_t *
<B>history_inhibit_expansion_function
</B>
1096 <DD>This should be set to the address of a function that takes two arguments:
1097 a
<CODE>char *
</CODE> (
<VAR>string
</VAR>)
1098 and an
<CODE>int
</CODE> index into that string (
<VAR>i
</VAR>).
1099 It should return a non-zero value if the history expansion starting at
1100 <VAR>string[i]
</VAR> should not be performed; zero if the expansion should
1102 It is intended for use by applications like Bash that use the history
1103 expansion character for additional purposes.
1104 By default, this variable is set to
<CODE>NULL
</CODE>.
1108 <A NAME=
"History Programming Example"></A>
1110 <A NAME=
"SEC18"></A>
1111 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
1112 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC17"> < </A>]
</TD>
1113 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19"> > </A>]
</TD>
1114 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<< ]
</TD>
1115 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> Up
</A>]
</TD>
1116 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19"> >> </A>]
</TD>
1117 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
1118 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
1119 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
1120 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
1122 <H2> 2.5 History Programming Example
</H2>
1123 <!--docid::SEC18::-->
1126 The following program demonstrates simple use of the GNU History Library.
1129 <TABLE><tr><td> </td><td class=smallexample
><FONT SIZE=-
1><pre>#include
<stdio.h
>
1130 #include
<readline/history.h
>
1136 char line[
1024], *t;
1144 printf (
"history$ ");
1146 t = fgets (line, sizeof (line) -
1, stdin);
1147 if (t
&& *t)
1150 if (t[len -
1] == '\n')
1155 strcpy (line,
"quit");
1162 result = history_expand (line,
&expansion);
1164 fprintf (stderr,
"%s\n", expansion);
1166 if (result
< 0 || result ==
2)
1172 add_history (expansion);
1173 strncpy (line, expansion, sizeof (line) -
1);
1177 if (strcmp (line,
"quit") ==
0)
1179 else if (strcmp (line,
"save") ==
0)
1180 write_history (
"history_file");
1181 else if (strcmp (line,
"read") ==
0)
1182 read_history (
"history_file");
1183 else if (strcmp (line,
"list") ==
0)
1185 register HIST_ENTRY **the_list;
1188 the_list = history_list ();
1190 for (i =
0; the_list[i]; i++)
1191 printf (
"%d: %s\n", i + history_base, the_list[i]-
>line);
1193 else if (strncmp (line,
"delete",
6) ==
0)
1196 if ((sscanf (line +
6,
"%d",
&which)) ==
1)
1198 HIST_ENTRY *entry = remove_history (which);
1200 fprintf (stderr,
"No such entry %d\n", which);
1203 free (entry-
>line);
1209 fprintf (stderr,
"non-numeric arg given to `delete'\n");
1214 </FONT></pre></td></tr></table></P><P>
1216 <A NAME=
"Concept Index"></A>
1218 <A NAME=
"SEC19"></A>
1219 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
1220 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC18"> < </A>]
</TD>
1221 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC20"> > </A>]
</TD>
1222 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC6"> << </A>]
</TD>
1223 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top"> Up
</A>]
</TD>
1224 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC20"> >> </A>]
</TD>
1225 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
1226 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
1227 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
1228 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
1230 <H1> A. Concept Index
</H1>
1231 <!--docid::SEC19::-->
1232 <table><tr><th valign=top
>Jump to:
</th><td><A HREF=
"history.html#cp_A" style=
"text-decoration:none"><b>A
</b></A>
1234 <A HREF=
"history.html#cp_E" style=
"text-decoration:none"><b>E
</b></A>
1236 <A HREF=
"history.html#cp_H" style=
"text-decoration:none"><b>H
</b></A>
1238 </td></tr></table><br><P></P>
1240 <TR><TD></TD><TH ALIGN=LEFT
>Index Entry
</TH><TH ALIGN=LEFT
> Section
</TH></TR>
1241 <TR><TD COLSPAN=
3> <HR></TD></TR>
1242 <TR><TH><A NAME=
"cp_A"></A>A
</TH><TD></TD><TD></TD></TR>
1243 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX20">anchored search
</A></TD><TD valign=top
><A HREF=
"history.html#SEC14">2.3.5 Searching the History List
</A></TD></TR>
1244 <TR><TD COLSPAN=
3> <HR></TD></TR>
1245 <TR><TH><A NAME=
"cp_E"></A>E
</TH><TD></TD><TD></TD></TR>
1246 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#SEC3">event designators
</A></TD><TD valign=top
><A HREF=
"history.html#SEC3">1.1.1 Event Designators
</A></TD></TR>
1247 <TR><TD COLSPAN=
3> <HR></TD></TR>
1248 <TR><TH><A NAME=
"cp_H"></A>H
</TH><TD></TD><TD></TD></TR>
1249 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX1">history events
</A></TD><TD valign=top
><A HREF=
"history.html#SEC3">1.1.1 Event Designators
</A></TD></TR>
1250 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#SEC2">history expansion
</A></TD><TD valign=top
><A HREF=
"history.html#SEC2">1.1 History Expansion
</A></TD></TR>
1251 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#SEC14">History Searching
</A></TD><TD valign=top
><A HREF=
"history.html#SEC14">2.3.5 Searching the History List
</A></TD></TR>
1252 <TR><TD COLSPAN=
3> <HR></TD></TR>
1253 </TABLE><P></P><table><tr><th valign=top
>Jump to:
</th><td><A HREF=
"history.html#cp_A" style=
"text-decoration:none"><b>A
</b></A>
1255 <A HREF=
"history.html#cp_E" style=
"text-decoration:none"><b>E
</b></A>
1257 <A HREF=
"history.html#cp_H" style=
"text-decoration:none"><b>H
</b></A>
1259 </td></tr></table><br><P>
1261 <A NAME=
"Function and Variable Index"></A>
1263 <A NAME=
"SEC20"></A>
1264 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
1265 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19"> < </A>]
</TD>
1266 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
> ]
</TD>
1267 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<< ]
</TD>
1268 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top"> Up
</A>]
</TD>
1269 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
>> ]
</TD>
1270 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT"> <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
1271 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
1272 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
1273 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
1275 <H1> B. Function and Variable Index
</H1>
1276 <!--docid::SEC20::-->
1277 <table><tr><th valign=top
>Jump to:
</th><td><A HREF=
"history.html#vr_A" style=
"text-decoration:none"><b>A
</b></A>
1279 <A HREF=
"history.html#vr_C" style=
"text-decoration:none"><b>C
</b></A>
1281 <A HREF=
"history.html#vr_G" style=
"text-decoration:none"><b>G
</b></A>
1283 <A HREF=
"history.html#vr_H" style=
"text-decoration:none"><b>H
</b></A>
1285 <A HREF=
"history.html#vr_N" style=
"text-decoration:none"><b>N
</b></A>
1287 <A HREF=
"history.html#vr_P" style=
"text-decoration:none"><b>P
</b></A>
1289 <A HREF=
"history.html#vr_R" style=
"text-decoration:none"><b>R
</b></A>
1291 <A HREF=
"history.html#vr_S" style=
"text-decoration:none"><b>S
</b></A>
1293 <A HREF=
"history.html#vr_U" style=
"text-decoration:none"><b>U
</b></A>
1295 <A HREF=
"history.html#vr_W" style=
"text-decoration:none"><b>W
</b></A>
1297 </td></tr></table><br><P></P>
1299 <TR><TD></TD><TH ALIGN=LEFT
>Index Entry
</TH><TH ALIGN=LEFT
> Section
</TH></TR>
1300 <TR><TD COLSPAN=
3> <HR></TD></TR>
1301 <TR><TH><A NAME=
"vr_A"></A>A
</TH><TD></TD><TD></TD></TR>
1302 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX5"><CODE>add_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC11">2.3.2 History List Management
</A></TD></TR>
1303 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX27"><CODE>append_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC15">2.3.6 Managing the History File
</A></TD></TR>
1304 <TR><TD COLSPAN=
3> <HR></TD></TR>
1305 <TR><TH><A NAME=
"vr_C"></A>C
</TH><TD></TD><TD></TD></TR>
1306 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX8"><CODE>clear_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC11">2.3.2 History List Management
</A></TD></TR>
1307 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX14"><CODE>current_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC12">2.3.3 Information About the History List
</A></TD></TR>
1308 <TR><TD COLSPAN=
3> <HR></TD></TR>
1309 <TR><TH><A NAME=
"vr_G"></A>G
</TH><TD></TD><TD></TD></TR>
1310 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX30"><CODE>get_history_event
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC16">2.3.7 History Expansion
</A></TD></TR>
1311 <TR><TD COLSPAN=
3> <HR></TD></TR>
1312 <TR><TH><A NAME=
"vr_H"></A>H
</TH><TD></TD><TD></TD></TR>
1313 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX32"><CODE>history_arg_extract
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC16">2.3.7 History Expansion
</A></TD></TR>
1314 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX33"><CODE>history_base
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1315 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX38"><CODE>history_comment_char
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1316 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX29"><CODE>history_expand
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC16">2.3.7 History Expansion
</A></TD></TR>
1317 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX36"><CODE>history_expansion_char
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1318 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX15"><CODE>history_get
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC12">2.3.3 Information About the History List
</A></TD></TR>
1319 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX3"><CODE>history_get_history_state
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC10">2.3.1 Initializing History and State Management
</A></TD></TR>
1320 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX43"><CODE>history_inhibit_expansion_function
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1321 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX11"><CODE>history_is_stifled
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC11">2.3.2 History List Management
</A></TD></TR>
1322 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX34"><CODE>history_length
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1323 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX12"><CODE>history_list
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC12">2.3.3 Information About the History List
</A></TD></TR>
1324 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX35"><CODE>history_max_entries
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1325 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX40"><CODE>history_no_expand_chars
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1326 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX42"><CODE>history_quotes_inhibit_expansion
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1327 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX21"><CODE>history_search
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC14">2.3.5 Searching the History List
</A></TD></TR>
1328 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX41"><CODE>history_search_delimiter_chars
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1329 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX23"><CODE>history_search_pos
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC14">2.3.5 Searching the History List
</A></TD></TR>
1330 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX22"><CODE>history_search_prefix
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC14">2.3.5 Searching the History List
</A></TD></TR>
1331 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX4"><CODE>history_set_history_state
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC10">2.3.1 Initializing History and State Management
</A></TD></TR>
1332 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX17"><CODE>history_set_pos
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC13">2.3.4 Moving Around the History List
</A></TD></TR>
1333 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX37"><CODE>history_subst_char
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1334 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX31"><CODE>history_tokenize
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC16">2.3.7 History Expansion
</A></TD></TR>
1335 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX16"><CODE>history_total_bytes
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC12">2.3.3 Information About the History List
</A></TD></TR>
1336 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX28"><CODE>history_truncate_file
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC15">2.3.6 Managing the History File
</A></TD></TR>
1337 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX39"><CODE>history_word_delimiters
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC17">2.4 History Variables
</A></TD></TR>
1338 <TR><TD COLSPAN=
3> <HR></TD></TR>
1339 <TR><TH><A NAME=
"vr_N"></A>N
</TH><TD></TD><TD></TD></TR>
1340 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX19"><CODE>next_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC13">2.3.4 Moving Around the History List
</A></TD></TR>
1341 <TR><TD COLSPAN=
3> <HR></TD></TR>
1342 <TR><TH><A NAME=
"vr_P"></A>P
</TH><TD></TD><TD></TD></TR>
1343 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX18"><CODE>previous_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC13">2.3.4 Moving Around the History List
</A></TD></TR>
1344 <TR><TD COLSPAN=
3> <HR></TD></TR>
1345 <TR><TH><A NAME=
"vr_R"></A>R
</TH><TD></TD><TD></TD></TR>
1346 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX24"><CODE>read_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC15">2.3.6 Managing the History File
</A></TD></TR>
1347 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX25"><CODE>read_history_range
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC15">2.3.6 Managing the History File
</A></TD></TR>
1348 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX6"><CODE>remove_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC11">2.3.2 History List Management
</A></TD></TR>
1349 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX7"><CODE>replace_history_entry
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC11">2.3.2 History List Management
</A></TD></TR>
1350 <TR><TD COLSPAN=
3> <HR></TD></TR>
1351 <TR><TH><A NAME=
"vr_S"></A>S
</TH><TD></TD><TD></TD></TR>
1352 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX9"><CODE>stifle_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC11">2.3.2 History List Management
</A></TD></TR>
1353 <TR><TD COLSPAN=
3> <HR></TD></TR>
1354 <TR><TH><A NAME=
"vr_U"></A>U
</TH><TD></TD><TD></TD></TR>
1355 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX10"><CODE>unstifle_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC11">2.3.2 History List Management
</A></TD></TR>
1356 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX2"><CODE>using_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC10">2.3.1 Initializing History and State Management
</A></TD></TR>
1357 <TR><TD COLSPAN=
3> <HR></TD></TR>
1358 <TR><TH><A NAME=
"vr_W"></A>W
</TH><TD></TD><TD></TD></TR>
1359 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX13"><CODE>where_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC12">2.3.3 Information About the History List
</A></TD></TR>
1360 <TR><TD></TD><TD valign=top
><A HREF=
"history.html#IDX26"><CODE>write_history
</CODE></A></TD><TD valign=top
><A HREF=
"history.html#SEC15">2.3.6 Managing the History File
</A></TD></TR>
1361 <TR><TD COLSPAN=
3> <HR></TD></TR>
1362 </TABLE><P></P><table><tr><th valign=top
>Jump to:
</th><td><A HREF=
"history.html#vr_A" style=
"text-decoration:none"><b>A
</b></A>
1364 <A HREF=
"history.html#vr_C" style=
"text-decoration:none"><b>C
</b></A>
1366 <A HREF=
"history.html#vr_G" style=
"text-decoration:none"><b>G
</b></A>
1368 <A HREF=
"history.html#vr_H" style=
"text-decoration:none"><b>H
</b></A>
1370 <A HREF=
"history.html#vr_N" style=
"text-decoration:none"><b>N
</b></A>
1372 <A HREF=
"history.html#vr_P" style=
"text-decoration:none"><b>P
</b></A>
1374 <A HREF=
"history.html#vr_R" style=
"text-decoration:none"><b>R
</b></A>
1376 <A HREF=
"history.html#vr_S" style=
"text-decoration:none"><b>S
</b></A>
1378 <A HREF=
"history.html#vr_U" style=
"text-decoration:none"><b>U
</b></A>
1380 <A HREF=
"history.html#vr_W" style=
"text-decoration:none"><b>W
</b></A>
1382 </td></tr></table><br><P>
1385 <A NAME=
"SEC_Contents"></A>
1386 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
1387 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
1388 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
1389 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
1390 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
1392 <H1>Table of Contents
</H1>
1394 <A NAME=
"TOC1" HREF=
"history.html#SEC1">1. Using History Interactively
</A>
1397 <A NAME=
"TOC2" HREF=
"history.html#SEC2">1.1 History Expansion
</A>
1400 <A NAME=
"TOC3" HREF=
"history.html#SEC3">1.1.1 Event Designators
</A>
1402 <A NAME=
"TOC4" HREF=
"history.html#SEC4">1.1.2 Word Designators
</A>
1404 <A NAME=
"TOC5" HREF=
"history.html#SEC5">1.1.3 Modifiers
</A>
1408 <A NAME=
"TOC6" HREF=
"history.html#SEC6">2. Programming with GNU History
</A>
1411 <A NAME=
"TOC7" HREF=
"history.html#SEC7">2.1 Introduction to History
</A>
1413 <A NAME=
"TOC8" HREF=
"history.html#SEC8">2.2 History Storage
</A>
1415 <A NAME=
"TOC9" HREF=
"history.html#SEC9">2.3 History Functions
</A>
1418 <A NAME=
"TOC10" HREF=
"history.html#SEC10">2.3.1 Initializing History and State Management
</A>
1420 <A NAME=
"TOC11" HREF=
"history.html#SEC11">2.3.2 History List Management
</A>
1422 <A NAME=
"TOC12" HREF=
"history.html#SEC12">2.3.3 Information About the History List
</A>
1424 <A NAME=
"TOC13" HREF=
"history.html#SEC13">2.3.4 Moving Around the History List
</A>
1426 <A NAME=
"TOC14" HREF=
"history.html#SEC14">2.3.5 Searching the History List
</A>
1428 <A NAME=
"TOC15" HREF=
"history.html#SEC15">2.3.6 Managing the History File
</A>
1430 <A NAME=
"TOC16" HREF=
"history.html#SEC16">2.3.7 History Expansion
</A>
1433 <A NAME=
"TOC17" HREF=
"history.html#SEC17">2.4 History Variables
</A>
1435 <A NAME=
"TOC18" HREF=
"history.html#SEC18">2.5 History Programming Example
</A>
1438 <A NAME=
"TOC19" HREF=
"history.html#SEC19">A. Concept Index
</A>
1440 <A NAME=
"TOC20" HREF=
"history.html#SEC20">B. Function and Variable Index
</A>
1444 <A NAME=
"SEC_OVERVIEW"></A>
1445 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
1446 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
1447 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
1448 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
1449 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
1451 <H1>Short Table of Contents
</H1>
1453 <A NAME=
"TOC1" HREF=
"history.html#SEC1">1. Using History Interactively
</A>
1455 <A NAME=
"TOC6" HREF=
"history.html#SEC6">2. Programming with GNU History
</A>
1457 <A NAME=
"TOC19" HREF=
"history.html#SEC19">A. Concept Index
</A>
1459 <A NAME=
"TOC20" HREF=
"history.html#SEC20">B. Function and Variable Index
</A>
1464 <A NAME=
"SEC_About"></A>
1465 <TABLE CELLPADDING=
1 CELLSPACING=
1 BORDER=
0>
1466 <TR><TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Top">Top
</A>]
</TD>
1467 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_Contents">Contents
</A>]
</TD>
1468 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC19">Index
</A>]
</TD>
1469 <TD VALIGN=
"MIDDLE" ALIGN=
"LEFT">[
<A HREF=
"history.html#SEC_About"> ?
</A>]
</TD>
1471 <H1>About this document
</H1>
1472 This document was generated by
<I>Chet Ramey
</I> on
<I>June,
27 2002</I>
1473 using
<A HREF=
"http://www.mathematik.uni-kl.de/~obachman/Texi2html
1474 "><I>texi2html
</I></A>
1476 The buttons in the navigation panels have the following meaning:
1478 <table border =
"1">
1483 <TH> From
1.2.3 go to
</TH>
1492 previous section in reading order
1505 next section in reading order
1518 previous or up-and-previous section
1544 next or up-and-next section
1557 cover (top) of document
1604 where the
<STRONG> Example
</STRONG> assumes that the current position
1605 is at
<STRONG> Subsubsection One-Two-Three
</STRONG> of a document of
1606 the following structure:
1608 <LI> 1. Section One
</LI>
1610 <LI>1.1 Subsection One-One
</LI>
1614 <LI>1.2 Subsection One-Two
</LI>
1616 <LI>1.2.1 Subsubsection One-Two-One
1617 </LI><LI>1.2.2 Subsubsection One-Two-Two
1618 </LI><LI>1.2.3 Subsubsection One-Two-Three
<STRONG>
1619 <== Current Position
</STRONG>
1620 </LI><LI>1.2.4 Subsubsection One-Two-Four
1622 <LI>1.3 Subsection One-Three
</LI>
1626 <LI>1.4 Subsection One-Four
</LI>
1633 This document was generated
1634 by
<I>Chet Ramey
</I> on
<I>June,
27 2002</I>
1635 using
<A HREF=
"http://www.mathematik.uni-kl.de/~obachman/Texi2html
1636 "><I>texi2html
</I></A>