Import of readline-2.2.1
[platform/upstream/binutils.git] / readline / doc / readline.html
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.51
4      from /usr/homes/chet/src/bash/readline-2.2/doc/rlman.texinfo on 2 April 1998 -->
5
6 <TITLE>GNU Readline Library</TITLE>
7 </HEAD>
8 <BODY>
9 <H1>GNU Readline Library</H1>
10 <H2>Edition 2.2, for <CODE>Readline Library</CODE> Version 2.1.</H2>
11 <H2>September 1997</H2>
12 <ADDRESS>Brian Fox, Free Software Foundation</ADDRESS>
13 <ADDRESS>Chet Ramey, Case Western Reserve University</ADDRESS>
14 <P>
15 <P><HR><P>
16
17 <P>
18 @dircategory Libraries
19 @direntry
20 * Readline: (readline).       The GNU readline library API
21
22 </P>
23
24 <P>
25 This document describes the GNU Readline Library, a utility which aids
26 in the consistency of user interface across discrete programs that need
27 to provide a command line interface.
28
29 </P>
30 <P>
31 Published by the Free Software Foundation <BR>
32 675 Massachusetts Avenue, <BR>
33 Cambridge, MA 02139 USA
34
35 </P>
36 <P>
37 Permission is granted to make and distribute verbatim copies of
38 this manual provided the copyright notice and this permission notice
39 are preserved on all copies.
40
41 </P>
42 <P>
43 Permission is granted to copy and distribute modified versions of this
44 manual under the conditions for verbatim copying, provided that the entire
45 resulting derived work is distributed under the terms of a permission
46 notice identical to this one.
47
48 </P>
49 <P>
50 Permission is granted to copy and distribute translations of this manual
51 into another language, under the above conditions for modified versions,
52 except that this permission notice may be stated in a translation approved
53 by the Foundation.
54
55 </P>
56 <P>
57 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
58
59 </P>
60
61
62
63 <H1><A NAME="SEC1" HREF="readline_toc.html#TOC1">Command Line Editing</A></H1>
64
65 <P>
66 This chapter describes the basic features of the GNU
67 command line editing interface.
68
69 </P>
70
71
72
73 <H2><A NAME="SEC2" HREF="readline_toc.html#TOC2">Introduction to Line Editing</A></H2>
74
75 <P>
76 The following paragraphs describe the notation used to represent
77 keystrokes.
78
79 </P>
80 <P>
81 The text <KBD>C-k</KBD> is read as `Control-K' and describes the character
82 produced when the <KBD>k</KBD> key is pressed while the Control key
83 is depressed.
84
85 </P>
86 <P>
87 The text <KBD>M-k</KBD> is read as `Meta-K' and describes the character
88 produced when the meta key (if you have one) is depressed, and the <KBD>k</KBD>
89 key is pressed.  If you do not have a meta key, the identical keystroke
90 can be generated by typing <KBD>ESC</KBD> <I>first</I>, and then typing <KBD>k</KBD>.
91 Either process is known as <STRONG>metafying</STRONG> the <KBD>k</KBD> key.
92
93 </P>
94 <P>
95 The text <KBD>M-C-k</KBD> is read as `Meta-Control-k' and describes the
96 character produced by <STRONG>metafying</STRONG> <KBD>C-k</KBD>.
97
98 </P>
99 <P>
100 In addition, several keys have their own names.  Specifically,
101 <KBD>DEL</KBD>, <KBD>ESC</KBD>, <KBD>LFD</KBD>, <KBD>SPC</KBD>, <KBD>RET</KBD>, and <KBD>TAB</KBD> all
102 stand for themselves when seen in this text, or in an init file
103 (@xref{Readline Init File}).
104
105 </P>
106
107
108 <H2><A NAME="SEC3" HREF="readline_toc.html#TOC3">Readline Interaction</A></H2>
109 <P>
110 <A NAME="IDX1"></A>
111
112 </P>
113 <P>
114 Often during an interactive session you type in a long line of text,
115 only to notice that the first word on the line is misspelled.  The
116 Readline library gives you a set of commands for manipulating the text
117 as you type it in, allowing you to just fix your typo, and not forcing
118 you to retype the majority of the line.  Using these editing commands,
119 you move the cursor to the place that needs correction, and delete or
120 insert the text of the corrections.  Then, when you are satisfied with
121 the line, you simply press <KBD>RETURN</KBD>.  You do not have to be at the
122 end of the line to press <KBD>RETURN</KBD>; the entire line is accepted
123 regardless of the location of the cursor within the line.
124
125 </P>
126
127
128
129 <H3><A NAME="SEC4" HREF="readline_toc.html#TOC4">Readline Init File Syntax</A></H3>
130
131 <P>
132 There are only a few basic constructs allowed in the
133 Readline init file.  Blank lines are ignored.
134 Lines beginning with a <SAMP>`#'</SAMP> are comments.
135 Lines beginning with a <SAMP>`$'</SAMP> indicate conditional
136 constructs (see section <A HREF="readline.html#SEC5">Conditional Init Constructs</A>).  Other lines
137 denote variable settings and key bindings.
138
139 </P>
140 <DL COMPACT>
141
142 <DT>Variable Settings
143 <DD>
144 You can modify the run-time behavior of Readline by
145 altering the values of variables in Readline
146 using the <CODE>set</CODE> command within the init file.  Here is how to
147 change from the default Emacs-like key binding to use
148 <CODE>vi</CODE> line editing commands:
149
150
151 <PRE>
152 set editing-mode vi
153 </PRE>
154
155 A great deal of run-time behavior is changeable with the following
156 variables.
157
158 <DL COMPACT>
159
160 <DT><CODE>bell-style</CODE>
161 <DD>
162 <A NAME="IDX2"></A>
163 Controls what happens when Readline wants to ring the terminal bell.
164 If set to <SAMP>`none'</SAMP>, Readline never rings the bell.  If set to
165 <SAMP>`visible'</SAMP>, Readline uses a visible bell if one is available.
166 If set to <SAMP>`audible'</SAMP> (the default), Readline attempts to ring
167 the terminal's bell.
168
169 <DT><CODE>comment-begin</CODE>
170 <DD>
171 <A NAME="IDX3"></A>
172 The string to insert at the beginning of the line when the
173 <CODE>insert-comment</CODE> command is executed.  The default value
174 is <CODE>"#"</CODE>.
175
176 <DT><CODE>completion-ignore-case</CODE>
177 <DD>
178 If set to <SAMP>`on'</SAMP>, Readline performs filename matching and completion
179 in a case-insensitive fashion.
180 The default value is <SAMP>`off'</SAMP>.
181
182 <DT><CODE>completion-query-items</CODE>
183 <DD>
184 <A NAME="IDX4"></A>
185 The number of possible completions that determines when the user is
186 asked whether he wants to see the list of possibilities.  If the
187 number of possible completions is greater than this value,
188 Readline will ask the user whether or not he wishes to view
189 them; otherwise, they are simply listed.  The default limit is
190 <CODE>100</CODE>.
191
192 <DT><CODE>convert-meta</CODE>
193 <DD>
194 <A NAME="IDX5"></A>
195 If set to <SAMP>`on'</SAMP>, Readline will convert characters with the
196 eighth bit set to an ASCII key sequence by stripping the eighth
197 bit and prepending an <KBD>ESC</KBD> character, converting them to a
198 meta-prefixed key sequence.  The default value is <SAMP>`on'</SAMP>.
199
200 <DT><CODE>disable-completion</CODE>
201 <DD>
202 <A NAME="IDX6"></A>
203 If set to <SAMP>`On'</SAMP>, Readline will inhibit word completion.
204 Completion  characters will be inserted into the line as if they had
205 been mapped to <CODE>self-insert</CODE>.  The default is <SAMP>`off'</SAMP>.
206
207 <DT><CODE>editing-mode</CODE>
208 <DD>
209 <A NAME="IDX7"></A>
210 The <CODE>editing-mode</CODE> variable controls which default set of
211 key bindings is used.  By default, Readline starts up in Emacs editing
212 mode, where the keystrokes are most similar to Emacs.  This variable can be
213 set to either <SAMP>`emacs'</SAMP> or <SAMP>`vi'</SAMP>.
214
215 <DT><CODE>enable-keypad</CODE>
216 <DD>
217 <A NAME="IDX8"></A>
218 When set to <SAMP>`on'</SAMP>, Readline will try to enable the application
219 keypad when it is called.  Some systems need this to enable the
220 arrow keys.  The default is <SAMP>`off'</SAMP>.
221
222 <DT><CODE>expand-tilde</CODE>
223 <DD>
224 <A NAME="IDX9"></A>
225 If set to <SAMP>`on'</SAMP>, tilde expansion is performed when Readline
226 attempts word completion.  The default is <SAMP>`off'</SAMP>.
227
228 <DT><CODE>horizontal-scroll-mode</CODE>
229 <DD>
230 <A NAME="IDX10"></A>
231 This variable can be set to either <SAMP>`on'</SAMP> or <SAMP>`off'</SAMP>.  Setting it
232 to <SAMP>`on'</SAMP> means that the text of the lines being edited will scroll
233 horizontally on a single screen line when they are longer than the width
234 of the screen, instead of wrapping onto a new screen line.  By default,
235 this variable is set to <SAMP>`off'</SAMP>.
236
237 <DT><CODE>keymap</CODE>
238 <DD>
239 <A NAME="IDX11"></A>
240 Sets Readline's idea of the current keymap for key binding commands.
241 Acceptable <CODE>keymap</CODE> names are
242 <CODE>emacs</CODE>,
243 <CODE>emacs-standard</CODE>,
244 <CODE>emacs-meta</CODE>,
245 <CODE>emacs-ctlx</CODE>,
246 <CODE>vi</CODE>,
247 <CODE>vi-command</CODE>, and
248 <CODE>vi-insert</CODE>.
249 <CODE>vi</CODE> is equivalent to <CODE>vi-command</CODE>; <CODE>emacs</CODE> is
250 equivalent to <CODE>emacs-standard</CODE>.  The default value is <CODE>emacs</CODE>.
251 The value of the <CODE>editing-mode</CODE> variable also affects the
252 default keymap.
253
254 <DT><CODE>mark-directories</CODE>
255 <DD>
256 If set to <SAMP>`on'</SAMP>, completed directory names have a slash
257 appended.  The default is <SAMP>`on'</SAMP>.
258
259 <DT><CODE>mark-modified-lines</CODE>
260 <DD>
261 <A NAME="IDX12"></A>
262 This variable, when set to <SAMP>`on'</SAMP>, causes Readline to display an
263 asterisk (<SAMP>`*'</SAMP>) at the start of history lines which have been modified.
264 This variable is <SAMP>`off'</SAMP> by default.
265
266 <DT><CODE>input-meta</CODE>
267 <DD>
268 <A NAME="IDX13"></A>
269 <A NAME="IDX14"></A>
270 If set to <SAMP>`on'</SAMP>, Readline will enable eight-bit input (it
271 will not strip the eighth bit from the characters it reads),
272 regardless of what the terminal claims it can support.  The
273 default value is <SAMP>`off'</SAMP>.  The name <CODE>meta-flag</CODE> is a
274 synonym for this variable.
275
276 <DT><CODE>output-meta</CODE>
277 <DD>
278 <A NAME="IDX15"></A>
279 If set to <SAMP>`on'</SAMP>, Readline will display characters with the
280 eighth bit set directly rather than as a meta-prefixed escape
281 sequence.  The default is <SAMP>`off'</SAMP>.
282
283 <DT><CODE>print-completions-horizontally</CODE>
284 <DD>
285 If set to <SAMP>`on'</SAMP>, Readline will display completions with matches
286 sorted horizontally in alphabetical order, rather than down the screen.
287 The default is <SAMP>`off'</SAMP>.
288
289 <DT><CODE>show-all-if-ambiguous</CODE>
290 <DD>
291 <A NAME="IDX16"></A>
292 This alters the default behavior of the completion functions.  If
293 set to <SAMP>`on'</SAMP>, 
294 words which have more than one possible completion cause the
295 matches to be listed immediately instead of ringing the bell.
296 The default value is <SAMP>`off'</SAMP>.
297
298 <DT><CODE>visible-stats</CODE>
299 <DD>
300 <A NAME="IDX17"></A>
301 If set to <SAMP>`on'</SAMP>, a character denoting a file's type
302 is appended to the filename when listing possible
303 completions.  The default is <SAMP>`off'</SAMP>.
304
305 </DL>
306
307 <DT>Key Bindings
308 <DD>
309 The syntax for controlling key bindings in the init file is
310 simple.  First you have to know the name of the command that you
311 want to change.  The following sections contain tables of the command
312 name, the default keybinding, if any, and a short description of what
313 the command does.
314
315 Once you know the name of the command, simply place the name of the key
316 you wish to bind the command to, a colon, and then the name of the
317 command on a line in the init file.  The name of the key
318 can be expressed in different ways, depending on which is most
319 comfortable for you.
320
321 <DL COMPACT>
322
323 <DT><VAR>keyname</VAR>: <VAR>function-name</VAR> or <VAR>macro</VAR>
324 <DD>
325 <VAR>keyname</VAR> is the name of a key spelled out in English.  For example:
326
327 <PRE>
328 Control-u: universal-argument
329 Meta-Rubout: backward-kill-word
330 Control-o: "&#62; output"
331 </PRE>
332
333 In the above example, <KBD>C-u</KBD> is bound to the function
334 <CODE>universal-argument</CODE>, and <KBD>C-o</KBD> is bound to run the macro
335 expressed on the right hand side (that is, to insert the text
336 <SAMP>`&#62; output'</SAMP> into the line).
337
338 <DT>"<VAR>keyseq</VAR>": <VAR>function-name</VAR> or <VAR>macro</VAR>
339 <DD>
340 <VAR>keyseq</VAR> differs from <VAR>keyname</VAR> above in that strings
341 denoting an entire key sequence can be specified, by placing
342 the key sequence in double quotes.  Some GNU Emacs style key
343 escapes can be used, as in the following example, but the
344 special character names are not recognized.
345
346
347 <PRE>
348 "\C-u": universal-argument
349 "\C-x\C-r": re-read-init-file
350 "\e[11~": "Function Key 1"
351 </PRE>
352
353 In the above example, <KBD>C-u</KBD> is bound to the function
354 <CODE>universal-argument</CODE> (just as it was in the first example),
355 <SAMP>`<KBD>C-x</KBD> <KBD>C-r</KBD>'</SAMP> is bound to the function <CODE>re-read-init-file</CODE>,
356 and <SAMP>`<KBD>ESC</KBD> <KBD>[</KBD> <KBD>1</KBD> <KBD>1</KBD> <KBD>~</KBD>'</SAMP> is bound to insert
357 the text <SAMP>`Function Key 1'</SAMP>.
358
359 </DL>
360
361 The following GNU Emacs style escape sequences are available when
362 specifying key sequences:
363
364 <DL COMPACT>
365
366 <DT><CODE><KBD>\C-</KBD></CODE>
367 <DD>
368 control prefix
369 <DT><CODE><KBD>\M-</KBD></CODE>
370 <DD>
371 meta prefix
372 <DT><CODE><KBD>\e</KBD></CODE>
373 <DD>
374 an escape character
375 <DT><CODE><KBD>\\</KBD></CODE>
376 <DD>
377 backslash
378 <DT><CODE><KBD>\"</KBD></CODE>
379 <DD>
380 <KBD>"</KBD>
381 <DT><CODE><KBD>\'</KBD></CODE>
382 <DD>
383 <KBD>'</KBD>
384 </DL>
385
386 In addition to the GNU Emacs style escape sequences, a second
387 set of backslash escapes is available:
388
389 <DL COMPACT>
390
391 <DT><CODE>\a</CODE>
392 <DD>
393 alert (bell)
394 <DT><CODE>\b</CODE>
395 <DD>
396 backspace
397 <DT><CODE>\d</CODE>
398 <DD>
399 delete
400 <DT><CODE>\f</CODE>
401 <DD>
402 form feed
403 <DT><CODE>\n</CODE>
404 <DD>
405 newline
406 <DT><CODE>\r</CODE>
407 <DD>
408 carriage return
409 <DT><CODE>\t</CODE>
410 <DD>
411 horizontal tab
412 <DT><CODE>\v</CODE>
413 <DD>
414 vertical tab
415 <DT><CODE>\<VAR>nnn</VAR></CODE>
416 <DD>
417 the character whose ASCII code is the octal value <VAR>nnn</VAR>
418 (one to three digits)
419 <DT><CODE>\x<VAR>nnn</VAR></CODE>
420 <DD>
421 the character whose ASCII code is the hexadecimal value <VAR>nnn</VAR>
422 (one to three digits)
423 </DL>
424
425 When entering the text of a macro, single or double quotes must
426 be used to indicate a macro definition.
427 Unquoted text is assumed to be a function name.
428 In the macro body, the backslash escapes described above are expanded.
429 Backslash will quote any other character in the macro text,
430 including <SAMP>`"'</SAMP> and <SAMP>`''</SAMP>.
431 For example, the following binding will make <SAMP>`C-x \'</SAMP>
432 insert a single <SAMP>`\'</SAMP> into the line:
433
434 <PRE>
435 "\C-x\\": "\\"
436 </PRE>
437
438 </DL>
439
440
441
442 <H3><A NAME="SEC5" HREF="readline_toc.html#TOC5">Conditional Init Constructs</A></H3>
443
444 <P>
445 Readline implements a facility similar in spirit to the conditional
446 compilation features of the C preprocessor which allows key
447 bindings and variable settings to be performed as the result
448 of tests.  There are four parser directives used.
449
450 </P>
451 <DL COMPACT>
452
453 <DT><CODE>$if</CODE>
454 <DD>
455 The <CODE>$if</CODE> construct allows bindings to be made based on the
456 editing mode, the terminal being used, or the application using
457 Readline.  The text of the test extends to the end of the line;
458 no characters are required to isolate it.
459
460 <DL COMPACT>
461
462 <DT><CODE>mode</CODE>
463 <DD>
464 The <CODE>mode=</CODE> form of the <CODE>$if</CODE> directive is used to test
465 whether Readline is in <CODE>emacs</CODE> or <CODE>vi</CODE> mode.
466 This may be used in conjunction
467 with the <SAMP>`set keymap'</SAMP> command, for instance, to set bindings in
468 the <CODE>emacs-standard</CODE> and <CODE>emacs-ctlx</CODE> keymaps only if
469 Readline is starting out in <CODE>emacs</CODE> mode.
470
471 <DT><CODE>term</CODE>
472 <DD>
473 The <CODE>term=</CODE> form may be used to include terminal-specific
474 key bindings, perhaps to bind the key sequences output by the
475 terminal's function keys.  The word on the right side of the
476 <SAMP>`='</SAMP> is tested against both the full name of the terminal and
477 the portion of the terminal name before the first <SAMP>`-'</SAMP>.  This
478 allows <CODE>sun</CODE> to match both <CODE>sun</CODE> and <CODE>sun-cmd</CODE>,
479 for instance.
480
481 <DT><CODE>application</CODE>
482 <DD>
483 The <VAR>application</VAR> construct is used to include
484 application-specific settings.  Each program using the Readline
485 library sets the <VAR>application name</VAR>, and you can test for it. 
486 This could be used to bind key sequences to functions useful for
487 a specific program.  For instance, the following command adds a
488 key sequence that quotes the current or previous word in Bash:
489
490 <PRE>
491 $if Bash
492 # Quote the current or previous word
493 "\C-xq": "\eb\"\ef\""
494 $endif
495 </PRE>
496
497 </DL>
498
499 <DT><CODE>$endif</CODE>
500 <DD>
501 This command, as seen in the previous example, terminates an
502 <CODE>$if</CODE> command.
503
504 <DT><CODE>$else</CODE>
505 <DD>
506 Commands in this branch of the <CODE>$if</CODE> directive are executed if
507 the test fails.
508
509 <DT><CODE>$include</CODE>
510 <DD>
511 This directive takes a single filename as an argument and reads commands
512 and bindings from that file.
513
514 <PRE>
515 $include /etc/inputrc
516 </PRE>
517
518 </DL>
519
520
521
522 <H3><A NAME="SEC6" HREF="readline_toc.html#TOC6">Sample Init File</A></H3>
523
524 <P>
525 Here is an example of an inputrc file.  This illustrates key
526 binding, variable assignment, and conditional syntax.
527
528 </P>
529
530 <PRE>
531 # This file controls the behaviour of line input editing for
532 # programs that use the Gnu Readline library.  Existing programs
533 # include FTP, Bash, and Gdb.
534 #
535 # You can re-read the inputrc file with C-x C-r.
536 # Lines beginning with '#' are comments.
537 #
538 # First, include any systemwide bindings and variable assignments from
539 # /etc/Inputrc
540 $include /etc/Inputrc
541
542 #
543 # Set various bindings for emacs mode.
544
545 set editing-mode emacs 
546
547 $if mode=emacs
548
549 Meta-Control-h: backward-kill-word      Text after the function name is ignored
550
551 #
552 # Arrow keys in keypad mode
553 #
554 #"\M-OD":        backward-char
555 #"\M-OC":        forward-char
556 #"\M-OA":        previous-history
557 #"\M-OB":        next-history
558 #
559 # Arrow keys in ANSI mode
560 #
561 "\M-[D":        backward-char
562 "\M-[C":        forward-char
563 "\M-[A":        previous-history
564 "\M-[B":        next-history
565 #
566 # Arrow keys in 8 bit keypad mode
567 #
568 #"\M-\C-OD":       backward-char
569 #"\M-\C-OC":       forward-char
570 #"\M-\C-OA":       previous-history
571 #"\M-\C-OB":       next-history
572 #
573 # Arrow keys in 8 bit ANSI mode
574 #
575 #"\M-\C-[D":       backward-char
576 #"\M-\C-[C":       forward-char
577 #"\M-\C-[A":       previous-history
578 #"\M-\C-[B":       next-history
579
580 C-q: quoted-insert
581
582 $endif
583
584 # An old-style binding.  This happens to be the default.
585 TAB: complete
586
587 # Macros that are convenient for shell interaction
588 $if Bash
589 # edit the path
590 "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
591 # prepare to type a quoted word -- insert open and close double quotes
592 # and move to just after the open quote
593 "\C-x\"": "\"\"\C-b"
594 # insert a backslash (testing backslash escapes in sequences and macros)
595 "\C-x\\": "\\"
596 # Quote the current or previous word
597 "\C-xq": "\eb\"\ef\""
598 # Add a binding to refresh the line, which is unbound
599 "\C-xr": redraw-current-line
600 # Edit variable on current line.
601 "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
602 $endif
603
604 # use a visible bell if one is available
605 set bell-style visible
606
607 # don't strip characters to 7 bits when reading
608 set input-meta on
609
610 # allow iso-latin1 characters to be inserted rather than converted to
611 # prefix-meta sequences
612 set convert-meta off
613
614 # display characters with the eighth bit set directly rather than
615 # as meta-prefixed characters
616 set output-meta on
617
618 # if there are more than 150 possible completions for a word, ask the
619 # user if he wants to see all of them
620 set completion-query-items 150
621
622 # For FTP
623 $if Ftp
624 "\C-xg": "get \M-?"
625 "\C-xt": "put \M-?"
626 "\M-.": yank-last-arg
627 $endif
628 </PRE>
629
630
631
632 <H2><A NAME="SEC7" HREF="readline_toc.html#TOC7">Bindable Readline Commands</A></H2>
633
634 <P>
635 This section describes Readline commands that may be bound to key
636 sequences.
637
638 </P>
639
640
641 <H3><A NAME="SEC8" HREF="readline_toc.html#TOC8">Commands For Moving</A></H3>
642 <DL COMPACT>
643
644 <DT><CODE>beginning-of-line (C-a)</CODE>
645 <DD>
646 <A NAME="IDX18"></A>
647 Move to the start of the current line.
648
649 <DT><CODE>end-of-line (C-e)</CODE>
650 <DD>
651 <A NAME="IDX19"></A>
652 Move to the end of the line.
653
654 <DT><CODE>forward-char (C-f)</CODE>
655 <DD>
656 <A NAME="IDX20"></A>
657 Move forward a character.
658
659 <DT><CODE>backward-char (C-b)</CODE>
660 <DD>
661 <A NAME="IDX21"></A>
662 Move back a character.
663
664 <DT><CODE>forward-word (M-f)</CODE>
665 <DD>
666 <A NAME="IDX22"></A>
667 Move forward to the end of the next word.  Words are composed of
668 letters and digits.
669
670 <DT><CODE>backward-word (M-b)</CODE>
671 <DD>
672 <A NAME="IDX23"></A>
673 Move back to the start of this, or the previous, word.  Words are
674 composed of letters and digits.
675
676 <DT><CODE>clear-screen (C-l)</CODE>
677 <DD>
678 <A NAME="IDX24"></A>
679 Clear the screen and redraw the current line,
680 leaving the current line at the top of the screen.
681
682 <DT><CODE>redraw-current-line ()</CODE>
683 <DD>
684 <A NAME="IDX25"></A>
685 Refresh the current line.  By default, this is unbound.
686
687 </DL>
688
689
690
691 <H3><A NAME="SEC9" HREF="readline_toc.html#TOC9">Commands For Manipulating The History</A></H3>
692
693 <DL COMPACT>
694
695 <DT><CODE>accept-line (Newline, Return)</CODE>
696 <DD>
697 <A NAME="IDX26"></A>
698 Accept the line regardless of where the cursor is.  If this line is
699 non-empty, add it to the history list.  If this line was a history
700 line, then restore the history line to its original state.
701
702 <DT><CODE>previous-history (C-p)</CODE>
703 <DD>
704 <A NAME="IDX27"></A>
705 Move `up' through the history list.
706
707 <DT><CODE>next-history (C-n)</CODE>
708 <DD>
709 <A NAME="IDX28"></A>
710 Move `down' through the history list.
711
712 <DT><CODE>beginning-of-history (M-&#60;)</CODE>
713 <DD>
714 <A NAME="IDX29"></A>
715 Move to the first line in the history.
716
717 <DT><CODE>end-of-history (M-&#62;)</CODE>
718 <DD>
719 <A NAME="IDX30"></A>
720 Move to the end of the input history, i.e., the line currently
721 being entered.
722
723 <DT><CODE>reverse-search-history (C-r)</CODE>
724 <DD>
725 <A NAME="IDX31"></A>
726 Search backward starting at the current line and moving `up' through
727 the history as necessary.  This is an incremental search.
728
729 <DT><CODE>forward-search-history (C-s)</CODE>
730 <DD>
731 <A NAME="IDX32"></A>
732 Search forward starting at the current line and moving `down' through
733 the the history as necessary.  This is an incremental search.
734
735 <DT><CODE>non-incremental-reverse-search-history (M-p)</CODE>
736 <DD>
737 <A NAME="IDX33"></A>
738 Search backward starting at the current line and moving `up'
739 through the history as necessary using a non-incremental search
740 for a string supplied by the user.
741
742 <DT><CODE>non-incremental-forward-search-history (M-n)</CODE>
743 <DD>
744 <A NAME="IDX34"></A>
745 Search forward starting at the current line and moving `down'
746 through the the history as necessary using a non-incremental search
747 for a string supplied by the user.
748
749 <DT><CODE>history-search-forward ()</CODE>
750 <DD>
751 <A NAME="IDX35"></A>
752 Search forward through the history for the string of characters
753 between the start of the current line and the current cursor
754 position (the <VAR>point</VAR>).  This is a non-incremental search.  By
755 default, this command is unbound.
756
757 <DT><CODE>history-search-backward ()</CODE>
758 <DD>
759 <A NAME="IDX36"></A>
760 Search backward through the history for the string of characters
761 between the start of the current line and the point.  This
762 is a non-incremental search.  By default, this command is unbound.
763
764 <DT><CODE>yank-nth-arg (M-C-y)</CODE>
765 <DD>
766 <A NAME="IDX37"></A>
767 Insert the first argument to the previous command (usually
768 the second word on the previous line).  With an argument <VAR>n</VAR>,
769 insert the <VAR>n</VAR>th word from the previous command (the words
770 in the previous command begin with word 0).  A negative argument
771 inserts the <VAR>n</VAR>th word from the end of the previous command.
772
773 <DT><CODE>yank-last-arg (M-., M-_)</CODE>
774 <DD>
775 <A NAME="IDX38"></A>
776 Insert last argument to the previous command (the last word of the
777 previous history entry).  With an
778 argument, behave exactly like <CODE>yank-nth-arg</CODE>.
779 Successive calls to <CODE>yank-last-arg</CODE> move back through the history
780 list, inserting the last argument of each line in turn.
781
782 </DL>
783
784
785
786 <H3><A NAME="SEC10" HREF="readline_toc.html#TOC10">Commands For Changing Text</A></H3>
787
788 <DL COMPACT>
789
790 <DT><CODE>delete-char (C-d)</CODE>
791 <DD>
792 <A NAME="IDX39"></A>
793 Delete the character under the cursor.  If the cursor is at the
794 beginning of the line, there are no characters in the line, and
795 the last character typed was not bound to <CODE>delete-char</CODE>, then
796 return <CODE>EOF</CODE>.
797
798 <DT><CODE>backward-delete-char (Rubout)</CODE>
799 <DD>
800 <A NAME="IDX40"></A>
801 Delete the character behind the cursor.  A numeric argument means
802 to kill the characters instead of deleting them.
803
804 <DT><CODE>quoted-insert (C-q, C-v)</CODE>
805 <DD>
806 <A NAME="IDX41"></A>
807 Add the next character typed to the line verbatim.  This is
808 how to insert key sequences like <KBD>C-q</KBD>, for example.
809
810 <DT><CODE>tab-insert (M-TAB)</CODE>
811 <DD>
812 <A NAME="IDX42"></A>
813 Insert a tab character.
814
815 <DT><CODE>self-insert (a, b, A, 1, !, ...)</CODE>
816 <DD>
817 <A NAME="IDX43"></A>
818 Insert yourself.
819
820 <DT><CODE>transpose-chars (C-t)</CODE>
821 <DD>
822 <A NAME="IDX44"></A>
823 Drag the character before the cursor forward over
824 the character at the cursor, moving the
825 cursor forward as well.  If the insertion point
826 is at the end of the line, then this
827 transposes the last two characters of the line.
828 Negative arguments don't work.
829
830 <DT><CODE>transpose-words (M-t)</CODE>
831 <DD>
832 <A NAME="IDX45"></A>
833 Drag the word behind the cursor past the word in front of the cursor
834 moving the cursor over that word as well.
835
836 <DT><CODE>upcase-word (M-u)</CODE>
837 <DD>
838 <A NAME="IDX46"></A>
839 Uppercase the current (or following) word.  With a negative argument,
840 uppercase the previous word, but do not move the cursor.
841
842 <DT><CODE>downcase-word (M-l)</CODE>
843 <DD>
844 <A NAME="IDX47"></A>
845 Lowercase the current (or following) word.  With a negative argument,
846 lowercase the previous word, but do not move the cursor.
847
848 <DT><CODE>capitalize-word (M-c)</CODE>
849 <DD>
850 <A NAME="IDX48"></A>
851 Capitalize the current (or following) word.  With a negative argument,
852 capitalize the previous word, but do not move the cursor.
853
854 </DL>
855
856
857
858 <H3><A NAME="SEC11" HREF="readline_toc.html#TOC11">Killing And Yanking</A></H3>
859
860 <DL COMPACT>
861
862 <DT><CODE>kill-line (C-k)</CODE>
863 <DD>
864 <A NAME="IDX49"></A>
865 Kill the text from the current cursor position to the end of the line.
866
867 <DT><CODE>backward-kill-line (C-x Rubout)</CODE>
868 <DD>
869 <A NAME="IDX50"></A>
870 Kill backward to the beginning of the line.
871
872 <DT><CODE>unix-line-discard (C-u)</CODE>
873 <DD>
874 <A NAME="IDX51"></A>
875 Kill backward from the cursor to the beginning of the current line.
876 The killed text is saved on the kill-ring.
877
878 <DT><CODE>kill-whole-line ()</CODE>
879 <DD>
880 <A NAME="IDX52"></A>
881 Kill all characters on the current line, no matter where the
882 cursor is.  By default, this is unbound.
883
884 <DT><CODE>kill-word (M-d)</CODE>
885 <DD>
886 <A NAME="IDX53"></A>
887 Kill from the cursor to the end of the current word, or if between
888 words, to the end of the next word.  Word boundaries are the same
889 as <CODE>forward-word</CODE>.
890
891 <DT><CODE>backward-kill-word (M-DEL)</CODE>
892 <DD>
893 <A NAME="IDX54"></A>
894 Kill the word behind the cursor.  Word boundaries are the same
895 as <CODE>backward-word</CODE>.
896
897 <DT><CODE>unix-word-rubout (C-w)</CODE>
898 <DD>
899 <A NAME="IDX55"></A>
900 Kill the word behind the cursor, using white space as a word
901 boundary.  The killed text is saved on the kill-ring.
902
903 <DT><CODE>delete-horizontal-space ()</CODE>
904 <DD>
905 <A NAME="IDX56"></A>
906 Delete all spaces and tabs around point.  By default, this is unbound.
907
908 <DT><CODE>kill-region ()</CODE>
909 <DD>
910 <A NAME="IDX57"></A>
911 Kill the text between the point and the <EM>mark</EM> (saved
912 cursor position).  This text is referred to as the <VAR>region</VAR>.
913 By default, this command is unbound.
914
915 <DT><CODE>copy-region-as-kill ()</CODE>
916 <DD>
917 <A NAME="IDX58"></A>
918 Copy the text in the region to the kill buffer, so it can be yanked
919 right away.  By default, this command is unbound.
920
921 <DT><CODE>copy-backward-word ()</CODE>
922 <DD>
923 <A NAME="IDX59"></A>
924 Copy the word before point to the kill buffer.
925 The word boundaries are the same as <CODE>backward-word</CODE>.
926 By default, this command is unbound.
927
928 <DT><CODE>copy-forward-word ()</CODE>
929 <DD>
930 <A NAME="IDX60"></A>
931 Copy the word following point to the kill buffer.
932 The word boundaries are the same as <CODE>forward-word</CODE>.
933 By default, this command is unbound.
934
935 <DT><CODE>yank (C-y)</CODE>
936 <DD>
937 <A NAME="IDX61"></A>
938 Yank the top of the kill ring into the buffer at the current
939 cursor position.
940
941 <DT><CODE>yank-pop (M-y)</CODE>
942 <DD>
943 <A NAME="IDX62"></A>
944 Rotate the kill-ring, and yank the new top.  You can only do this if
945 the prior command is yank or yank-pop.
946 </DL>
947
948
949
950 <H3><A NAME="SEC12" HREF="readline_toc.html#TOC12">Specifying Numeric Arguments</A></H3>
951 <DL COMPACT>
952
953 <DT><CODE>digit-argument (M-0, M-1, ... M--)</CODE>
954 <DD>
955 <A NAME="IDX63"></A>
956 Add this digit to the argument already accumulating, or start a new
957 argument.  <KBD>M--</KBD> starts a negative argument.
958
959 <DT><CODE>universal-argument ()</CODE>
960 <DD>
961 <A NAME="IDX64"></A>
962 This is another way to specify an argument.
963 If this command is followed by one or more digits, optionally with a
964 leading minus sign, those digits define the argument.
965 If the command is followed by digits, executing <CODE>universal-argument</CODE>
966 again ends the numeric argument, but is otherwise ignored.
967 As a special case, if this command is immediately followed by a
968 character that is neither a digit or minus sign, the argument count
969 for the next command is multiplied by four.
970 The argument count is initially one, so executing this function the
971 first time makes the argument count four, a second time makes the
972 argument count sixteen, and so on.
973 By default, this is not bound to a key.
974 </DL>
975
976
977
978 <H3><A NAME="SEC13" HREF="readline_toc.html#TOC13">Letting Readline Type For You</A></H3>
979
980 <DL COMPACT>
981
982 <DT><CODE>complete (TAB)</CODE>
983 <DD>
984 <A NAME="IDX65"></A>
985 Attempt to do completion on the text before the cursor.  This is
986 application-specific.  Generally, if you are typing a filename
987 argument, you can do filename completion; if you are typing a command,
988 you can do command completion; if you are typing in a symbol to GDB, you
989 can do symbol name completion; if you are typing in a variable to Bash,
990 you can do variable name completion, and so on.
991
992 <DT><CODE>possible-completions (M-?)</CODE>
993 <DD>
994 <A NAME="IDX66"></A>
995 List the possible completions of the text before the cursor.
996
997 <DT><CODE>insert-completions (M-*)</CODE>
998 <DD>
999 <A NAME="IDX67"></A>
1000 Insert all completions of the text before point that would have
1001 been generated by <CODE>possible-completions</CODE>.
1002
1003 <DT><CODE>menu-complete ()</CODE>
1004 <DD>
1005 <A NAME="IDX68"></A>
1006 Similar to <CODE>complete</CODE>, but replaces the word to be completed
1007 with a single match from the list of possible completions.
1008 Repeated execution of <CODE>menu-complete</CODE> steps through the list
1009 of possible completions, inserting each match in turn.
1010 At the end of the list of completions, the bell is rung and the
1011 original text is restored.
1012 An argument of <VAR>n</VAR> moves <VAR>n</VAR> positions forward in the list
1013 of matches; a negative argument may be used to move backward
1014 through the list.
1015 This command is intended to be bound to <CODE>TAB</CODE>, but is unbound
1016 by default.
1017
1018 </DL>
1019
1020
1021
1022 <H3><A NAME="SEC14" HREF="readline_toc.html#TOC14">Keyboard Macros</A></H3>
1023 <DL COMPACT>
1024
1025 <DT><CODE>start-kbd-macro (C-x ()</CODE>
1026 <DD>
1027 <A NAME="IDX69"></A>
1028 Begin saving the characters typed into the current keyboard macro.
1029
1030 <DT><CODE>end-kbd-macro (C-x ))</CODE>
1031 <DD>
1032 <A NAME="IDX70"></A>
1033 Stop saving the characters typed into the current keyboard macro
1034 and save the definition.
1035
1036 <DT><CODE>call-last-kbd-macro (C-x e)</CODE>
1037 <DD>
1038 <A NAME="IDX71"></A>
1039 Re-execute the last keyboard macro defined, by making the characters
1040 in the macro appear as if typed at the keyboard.
1041
1042 </DL>
1043
1044
1045
1046 <H3><A NAME="SEC15" HREF="readline_toc.html#TOC15">Some Miscellaneous Commands</A></H3>
1047 <DL COMPACT>
1048
1049 <DT><CODE>re-read-init-file (C-x C-r)</CODE>
1050 <DD>
1051 <A NAME="IDX72"></A>
1052 Read in the contents of the inputrc file, and incorporate
1053 any bindings or variable assignments found there.
1054
1055 <DT><CODE>abort (C-g)</CODE>
1056 <DD>
1057 <A NAME="IDX73"></A>
1058 Abort the current editing command and
1059 ring the terminal's bell (subject to the setting of
1060 <CODE>bell-style</CODE>).
1061
1062 <DT><CODE>do-uppercase-version (M-a, M-b, M-<VAR>x</VAR>, ...)</CODE>
1063 <DD>
1064 <A NAME="IDX74"></A>
1065 If the metafied character <VAR>x</VAR> is lowercase, run the command
1066 that is bound to the corresponding uppercase character.
1067
1068 <DT><CODE>prefix-meta (ESC)</CODE>
1069 <DD>
1070 <A NAME="IDX75"></A>
1071 Make the next character typed be metafied.  This is for keyboards
1072 without a meta key.  Typing <SAMP>`ESC f'</SAMP> is equivalent to typing
1073 <SAMP>`M-f'</SAMP>.
1074
1075 <DT><CODE>undo (C-_, C-x C-u)</CODE>
1076 <DD>
1077 <A NAME="IDX76"></A>
1078 Incremental undo, separately remembered for each line.
1079
1080 <DT><CODE>revert-line (M-r)</CODE>
1081 <DD>
1082 <A NAME="IDX77"></A>
1083 Undo all changes made to this line.  This is like executing the <CODE>undo</CODE>
1084 command enough times to get back to the beginning.
1085
1086 <DT><CODE>tilde-expand (M-~)</CODE>
1087 <DD>
1088 <A NAME="IDX78"></A>
1089 Perform tilde expansion on the current word.
1090
1091 <DT><CODE>set-mark (C-@)</CODE>
1092 <DD>
1093 <A NAME="IDX79"></A>
1094 Set the mark to the current point.  If a
1095 numeric argument is supplied, the mark is set to that position.
1096
1097 <DT><CODE>exchange-point-and-mark (C-x C-x)</CODE>
1098 <DD>
1099 <A NAME="IDX80"></A>
1100 Swap the point with the mark.  The current cursor position is set to
1101 the saved position, and the old cursor position is saved as the mark.
1102
1103 <DT><CODE>character-search (C-])</CODE>
1104 <DD>
1105 <A NAME="IDX81"></A>
1106 A character is read and point is moved to the next occurrence of that
1107 character.  A negative count searches for previous occurrences.
1108
1109 <DT><CODE>character-search-backward (M-C-])</CODE>
1110 <DD>
1111 <A NAME="IDX82"></A>
1112 A character is read and point is moved to the previous occurrence
1113 of that character.  A negative count searches for subsequent
1114 occurrences.
1115
1116 <DT><CODE>insert-comment (M-#)</CODE>
1117 <DD>
1118 <A NAME="IDX83"></A>
1119 The value of the <CODE>comment-begin</CODE>
1120 variable is inserted at the beginning of the current line,
1121 and the line is accepted as if a newline had been typed.
1122
1123 <DT><CODE>dump-functions ()</CODE>
1124 <DD>
1125 <A NAME="IDX84"></A>
1126 Print all of the functions and their key bindings to the
1127 Readline output stream.  If a numeric argument is supplied,
1128 the output is formatted in such a way that it can be made part
1129 of an <VAR>inputrc</VAR> file.  This command is unbound by default.
1130
1131 <DT><CODE>dump-variables ()</CODE>
1132 <DD>
1133 <A NAME="IDX85"></A>
1134 Print all of the settable variables and their values to the
1135 Readline output stream.  If a numeric argument is supplied,
1136 the output is formatted in such a way that it can be made part
1137 of an <VAR>inputrc</VAR> file.  This command is unbound by default.
1138
1139 <DT><CODE>dump-macros ()</CODE>
1140 <DD>
1141 <A NAME="IDX86"></A>
1142 Print all of the Readline key sequences bound to macros and the
1143 strings they ouput.  If a numeric argument is supplied,
1144 the output is formatted in such a way that it can be made part
1145 of an <VAR>inputrc</VAR> file.  This command is unbound by default.
1146
1147 </DL>
1148
1149
1150
1151 <H2><A NAME="SEC16" HREF="readline_toc.html#TOC16">Readline vi Mode</A></H2>
1152
1153 <P>
1154 While the Readline library does not have a full set of <CODE>vi</CODE>
1155 editing functions, it does contain enough to allow simple editing
1156 of the line.  The Readline <CODE>vi</CODE> mode behaves as specified in
1157 the POSIX 1003.2 standard.
1158
1159 </P>
1160 <P>
1161 In order to switch interactively between <CODE>emacs</CODE> and <CODE>vi</CODE>
1162 editing modes, use the command M-C-j (toggle-editing-mode).
1163 The Readline default is <CODE>emacs</CODE> mode.
1164
1165 </P>
1166 <P>
1167 When you enter a line in <CODE>vi</CODE> mode, you are already placed in
1168 `insertion' mode, as if you had typed an <SAMP>`i'</SAMP>.  Pressing <KBD>ESC</KBD>
1169 switches you into `command' mode, where you can edit the text of the
1170 line with the standard <CODE>vi</CODE> movement keys, move to previous
1171 history lines with <SAMP>`k'</SAMP> and subsequent lines with <SAMP>`j'</SAMP>, and
1172 so forth.
1173
1174 </P>
1175
1176
1177
1178 <H1><A NAME="SEC17" HREF="readline_toc.html#TOC17">Programming with GNU Readline</A></H1>
1179
1180 <P>
1181 This chapter describes the interface between the GNU Readline Library and
1182 other programs.  If you are a programmer, and you wish to include the
1183 features found in GNU Readline
1184 such as completion, line editing, and interactive history manipulation
1185 in your own programs, this section is for you.
1186
1187 </P>
1188
1189
1190
1191 <H2><A NAME="SEC18" HREF="readline_toc.html#TOC18">Basic Behavior</A></H2>
1192
1193 <P>
1194 Many programs provide a command line interface, such as <CODE>mail</CODE>,
1195 <CODE>ftp</CODE>, and <CODE>sh</CODE>.  For such programs, the default behaviour of
1196 Readline is sufficient.  This section describes how to use Readline in
1197 the simplest way possible, perhaps to replace calls in your code to
1198 <CODE>gets()</CODE> or <CODE>fgets ()</CODE>.
1199
1200 </P>
1201 <P>
1202 <A NAME="IDX87"></A>
1203 <A NAME="IDX88"></A>
1204 The function <CODE>readline ()</CODE> prints a prompt and then reads and returns
1205 a single line of text from the user.  The line <CODE>readline</CODE>
1206 returns is allocated with <CODE>malloc ()</CODE>; you should <CODE>free ()</CODE>
1207 the line when you are done with it.  The declaration for <CODE>readline</CODE>
1208 in ANSI C is
1209
1210 </P>
1211
1212 <PRE>
1213 <CODE>char *readline (char *<VAR>prompt</VAR>);</CODE>
1214 </PRE>
1215
1216 <P>
1217 So, one might say
1218
1219 <PRE>
1220 <CODE>char *line = readline ("Enter a line: ");</CODE>
1221 </PRE>
1222
1223 <P>
1224 in order to read a line of text from the user.
1225 The line returned has the final newline removed, so only the
1226 text remains.
1227
1228 </P>
1229 <P>
1230 If <CODE>readline</CODE> encounters an <CODE>EOF</CODE> while reading the line, and the
1231 line is empty at that point, then <CODE>(char *)NULL</CODE> is returned.
1232 Otherwise, the line is ended just as if a newline had been typed.
1233
1234 </P>
1235 <P>
1236 If you want the user to be able to get at the line later, (with
1237 <KBD>C-p</KBD> for example), you must call <CODE>add_history ()</CODE> to save the
1238 line away in a <STRONG>history</STRONG> list of such lines.
1239
1240 </P>
1241
1242 <PRE>
1243 <CODE>add_history (line)</CODE>;
1244 </PRE>
1245
1246 <P>
1247 For full details on the GNU History Library, see the associated manual.
1248
1249 </P>
1250 <P>
1251 It is preferable to avoid saving empty lines on the history list, since
1252 users rarely have a burning need to reuse a blank line.  Here is
1253 a function which usefully replaces the standard <CODE>gets ()</CODE> library
1254 function, and has the advantage of no static buffer to overflow:
1255
1256 </P>
1257
1258 <PRE>
1259 /* A static variable for holding the line. */
1260 static char *line_read = (char *)NULL;
1261
1262 /* Read a string, and return a pointer to it.  Returns NULL on EOF. */
1263 char *
1264 rl_gets ()
1265 {
1266   /* If the buffer has already been allocated, return the memory
1267      to the free pool. */
1268   if (line_read)
1269     {
1270       free (line_read);
1271       line_read = (char *)NULL;
1272     }
1273
1274   /* Get a line from the user. */
1275   line_read = readline ("");
1276
1277   /* If the line has any text in it, save it on the history. */
1278   if (line_read &#38;&#38; *line_read)
1279     add_history (line_read);
1280
1281   return (line_read);
1282 }
1283 </PRE>
1284
1285 <P>
1286 This function gives the user the default behaviour of <KBD>TAB</KBD>
1287 completion: completion on file names.  If you do not want Readline to
1288 complete on filenames, you can change the binding of the <KBD>TAB</KBD> key
1289 with <CODE>rl_bind_key ()</CODE>.
1290
1291 </P>
1292
1293 <PRE>
1294 <CODE>int rl_bind_key (int <VAR>key</VAR>, int (*<VAR>function</VAR>)());</CODE>
1295 </PRE>
1296
1297 <P>
1298 <CODE>rl_bind_key ()</CODE> takes two arguments: <VAR>key</VAR> is the character that
1299 you want to bind, and <VAR>function</VAR> is the address of the function to
1300 call when <VAR>key</VAR> is pressed.  Binding <KBD>TAB</KBD> to <CODE>rl_insert ()</CODE>
1301 makes <KBD>TAB</KBD> insert itself.
1302 <CODE>rl_bind_key ()</CODE> returns non-zero if <VAR>key</VAR> is not a valid
1303 ASCII character code (between 0 and 255).
1304
1305 </P>
1306 <P>
1307 Thus, to disable the default <KBD>TAB</KBD> behavior, the following suffices:
1308
1309 <PRE>
1310 <CODE>rl_bind_key ('\t', rl_insert);</CODE>
1311 </PRE>
1312
1313 <P>
1314 This code should be executed once at the start of your program; you
1315 might write a function called <CODE>initialize_readline ()</CODE> which
1316 performs this and other desired initializations, such as installing
1317 custom completers (see section <A HREF="readline.html#SEC34">Custom Completers</A>).
1318
1319 </P>
1320
1321
1322 <H2><A NAME="SEC19" HREF="readline_toc.html#TOC19">Custom Functions</A></H2>
1323
1324 <P>
1325 Readline provides many functions for manipulating the text of
1326 the line, but it isn't possible to anticipate the needs of all
1327 programs.  This section describes the various functions and variables
1328 defined within the Readline library which allow a user program to add
1329 customized functionality to Readline.
1330
1331 </P>
1332
1333
1334
1335 <H3><A NAME="SEC20" HREF="readline_toc.html#TOC20">The Function Type</A></H3>
1336
1337 <P>
1338 For readabilty, we declare a new type of object, called
1339 <STRONG>Function</STRONG>.  A <CODE>Function</CODE> is a C function which
1340 returns an <CODE>int</CODE>.  The type declaration for <CODE>Function</CODE> is:
1341
1342 </P>
1343 <P>
1344 <CODE>typedef int Function ();</CODE>
1345
1346 </P>
1347 <P>
1348 The reason for declaring this new type is to make it easier to write
1349 code describing pointers to C functions.  Let us say we had a variable
1350 called <VAR>func</VAR> which was a pointer to a function.  Instead of the
1351 classic C declaration
1352
1353 </P>
1354 <P>
1355 <CODE>int (*)()func;</CODE>
1356
1357 </P>
1358 <P>
1359 we may write
1360
1361 </P>
1362 <P>
1363 <CODE>Function *func;</CODE>
1364
1365 </P>
1366 <P>
1367 Similarly, there are
1368
1369 </P>
1370
1371 <PRE>
1372 typedef void VFunction ();
1373 typedef char *CPFunction (); and
1374 typedef char **CPPFunction ();
1375 </PRE>
1376
1377 <P>
1378 for functions returning no value, <CODE>pointer to char</CODE>, and
1379 <CODE>pointer to pointer to char</CODE>, respectively.
1380
1381 </P>
1382
1383
1384 <H3><A NAME="SEC21" HREF="readline_toc.html#TOC21">Writing a New Function</A></H3>
1385
1386 <P>
1387 In order to write new functions for Readline, you need to know the
1388 calling conventions for keyboard-invoked functions, and the names of the
1389 variables that describe the current state of the line read so far.
1390
1391 </P>
1392 <P>
1393 The calling sequence for a command <CODE>foo</CODE> looks like
1394
1395 </P>
1396
1397 <PRE>
1398 <CODE>foo (int count, int key)</CODE>
1399 </PRE>
1400
1401 <P>
1402 where <VAR>count</VAR> is the numeric argument (or 1 if defaulted) and
1403 <VAR>key</VAR> is the key that invoked this function.
1404
1405 </P>
1406 <P>
1407 It is completely up to the function as to what should be done with the
1408 numeric argument.  Some functions use it as a repeat count, some
1409 as a flag, and others to choose alternate behavior (refreshing the current
1410 line as opposed to refreshing the screen, for example).  Some choose to
1411 ignore it.  In general, if a
1412 function uses the numeric argument as a repeat count, it should be able
1413 to do something useful with both negative and positive arguments.
1414 At the very least, it should be aware that it can be passed a
1415 negative argument.
1416
1417 </P>
1418
1419
1420 <H2><A NAME="SEC22" HREF="readline_toc.html#TOC22">Readline Variables</A></H2>
1421
1422 <P>
1423 These variables are available to function writers.
1424
1425 </P>
1426 <P>
1427 <DL>
1428 <DT><U>Variable:</U> char * <B>rl_line_buffer</B>
1429 <DD><A NAME="IDX89"></A>
1430 This is the line gathered so far.  You are welcome to modify the
1431 contents of the line, but see section <A HREF="readline.html#SEC28">Allowing Undoing</A>.
1432 </DL>
1433
1434 </P>
1435 <P>
1436 <DL>
1437 <DT><U>Variable:</U> int <B>rl_point</B>
1438 <DD><A NAME="IDX90"></A>
1439 The offset of the current cursor position in <CODE>rl_line_buffer</CODE>
1440 (the <EM>point</EM>).
1441 </DL>
1442
1443 </P>
1444 <P>
1445 <DL>
1446 <DT><U>Variable:</U> int <B>rl_end</B>
1447 <DD><A NAME="IDX91"></A>
1448 The number of characters present in <CODE>rl_line_buffer</CODE>.  When
1449 <CODE>rl_point</CODE> is at the end of the line, <CODE>rl_point</CODE> and
1450 <CODE>rl_end</CODE> are equal.
1451 </DL>
1452
1453 </P>
1454 <P>
1455 <DL>
1456 <DT><U>Variable:</U> int <B>rl_mark</B>
1457 <DD><A NAME="IDX92"></A>
1458 The mark (saved position) in the current line.  If set, the mark
1459 and point define a <EM>region</EM>.
1460 </DL>
1461
1462 </P>
1463 <P>
1464 <DL>
1465 <DT><U>Variable:</U> int <B>rl_done</B>
1466 <DD><A NAME="IDX93"></A>
1467 Setting this to a non-zero value causes Readline to return the current
1468 line immediately.
1469 </DL>
1470
1471 </P>
1472 <P>
1473 <DL>
1474 <DT><U>Variable:</U> int <B>rl_pending_input</B>
1475 <DD><A NAME="IDX94"></A>
1476 Setting this to a value makes it the next keystroke read.  This is a
1477 way to stuff a single character into the input stream.
1478 </DL>
1479
1480 </P>
1481 <P>
1482 <DL>
1483 <DT><U>Variable:</U> char * <B>rl_prompt</B>
1484 <DD><A NAME="IDX95"></A>
1485 The prompt Readline uses.  This is set from the argument to
1486 <CODE>readline ()</CODE>, and should not be assigned to directly.
1487 </DL>
1488
1489 </P>
1490 <P>
1491 <DL>
1492 <DT><U>Variable:</U> char * <B>rl_library_version</B>
1493 <DD><A NAME="IDX96"></A>
1494 The version number of this revision of the library.
1495 </DL>
1496
1497 </P>
1498 <P>
1499 <DL>
1500 <DT><U>Variable:</U> char * <B>rl_terminal_name</B>
1501 <DD><A NAME="IDX97"></A>
1502 The terminal type, used for initialization.
1503 </DL>
1504
1505 </P>
1506 <P>
1507 <DL>
1508 <DT><U>Variable:</U> char * <B>rl_readline_name</B>
1509 <DD><A NAME="IDX98"></A>
1510 This variable is set to a unique name by each application using Readline.
1511 The value allows conditional parsing of the inputrc file
1512 (see section <A HREF="readline.html#SEC5">Conditional Init Constructs</A>).
1513 </DL>
1514
1515 </P>
1516 <P>
1517 <DL>
1518 <DT><U>Variable:</U> FILE * <B>rl_instream</B>
1519 <DD><A NAME="IDX99"></A>
1520 The stdio stream from which Readline reads input.
1521 </DL>
1522
1523 </P>
1524 <P>
1525 <DL>
1526 <DT><U>Variable:</U> FILE * <B>rl_outstream</B>
1527 <DD><A NAME="IDX100"></A>
1528 The stdio stream to which Readline performs output.
1529 </DL>
1530
1531 </P>
1532 <P>
1533 <DL>
1534 <DT><U>Variable:</U> Function * <B>rl_startup_hook</B>
1535 <DD><A NAME="IDX101"></A>
1536 If non-zero, this is the address of a function to call just
1537 before <CODE>readline</CODE> prints the first prompt.
1538 </DL>
1539
1540 </P>
1541 <P>
1542 <DL>
1543 <DT><U>Variable:</U> Function * <B>rl_event_hook</B>
1544 <DD><A NAME="IDX102"></A>
1545 If non-zero, this is the address of a function to call periodically
1546 when readline is waiting for terminal input.
1547 </DL>
1548
1549 </P>
1550 <P>
1551 <DL>
1552 <DT><U>Variable:</U> Function * <B>rl_getc_function</B>
1553 <DD><A NAME="IDX103"></A>
1554 If non-zero, <CODE>readline</CODE> will call indirectly through this pointer
1555 to get a character from the input stream.  By default, it is set to
1556 <CODE>rl_getc</CODE>, the default <CODE>readline</CODE> character input function
1557 (see section <A HREF="readline.html#SEC31">Utility Functions</A>).
1558 </DL>
1559
1560 </P>
1561 <P>
1562 <DL>
1563 <DT><U>Variable:</U> VFunction * <B>rl_redisplay_function</B>
1564 <DD><A NAME="IDX104"></A>
1565 If non-zero, <CODE>readline</CODE> will call indirectly through this pointer
1566 to update the display with the current contents of the editing buffer.
1567 By default, it is set to <CODE>rl_redisplay</CODE>, the default <CODE>readline</CODE>
1568 redisplay function (see section <A HREF="readline.html#SEC29">Redisplay</A>).
1569 </DL>
1570
1571 </P>
1572 <P>
1573 <DL>
1574 <DT><U>Variable:</U> Keymap <B>rl_executing_keymap</B>
1575 <DD><A NAME="IDX105"></A>
1576 This variable is set to the keymap (see section <A HREF="readline.html#SEC25">Selecting a Keymap</A>) in which the
1577 currently executing readline function was found.
1578 </DL>
1579
1580 </P>
1581 <P>
1582 <DL>
1583 <DT><U>Variable:</U> Keymap <B>rl_binding_keymap</B>
1584 <DD><A NAME="IDX106"></A>
1585 This variable is set to the keymap (see section <A HREF="readline.html#SEC25">Selecting a Keymap</A>) in which the
1586 last key binding occurred.
1587 </DL>
1588
1589 </P>
1590
1591
1592 <H2><A NAME="SEC23" HREF="readline_toc.html#TOC23">Readline Convenience Functions</A></H2>
1593
1594
1595
1596 <H3><A NAME="SEC24" HREF="readline_toc.html#TOC24">Naming a Function</A></H3>
1597
1598 <P>
1599 The user can dynamically change the bindings of keys while using
1600 Readline.  This is done by representing the function with a descriptive
1601 name.  The user is able to type the descriptive name when referring to
1602 the function.  Thus, in an init file, one might find
1603
1604 </P>
1605
1606 <PRE>
1607 Meta-Rubout:    backward-kill-word
1608 </PRE>
1609
1610 <P>
1611 This binds the keystroke <KBD>Meta-Rubout</KBD> to the function
1612 <EM>descriptively</EM> named <CODE>backward-kill-word</CODE>.  You, as the
1613 programmer, should bind the functions you write to descriptive names as
1614 well.  Readline provides a function for doing that:
1615
1616 </P>
1617 <P>
1618 <DL>
1619 <DT><U>Function:</U> int <B>rl_add_defun</B> <I>(char *name, Function *function, int key)</I>
1620 <DD><A NAME="IDX107"></A>
1621 Add <VAR>name</VAR> to the list of named functions.  Make <VAR>function</VAR> be
1622 the function that gets called.  If <VAR>key</VAR> is not -1, then bind it to
1623 <VAR>function</VAR> using <CODE>rl_bind_key ()</CODE>.
1624 </DL>
1625
1626 </P>
1627 <P>
1628 Using this function alone is sufficient for most applications.  It is
1629 the recommended way to add a few functions to the default functions that
1630 Readline has built in.  If you need to do something other
1631 than adding a function to Readline, you may need to use the
1632 underlying functions described below.
1633
1634 </P>
1635
1636
1637 <H3><A NAME="SEC25" HREF="readline_toc.html#TOC25">Selecting a Keymap</A></H3>
1638
1639 <P>
1640 Key bindings take place on a <STRONG>keymap</STRONG>.  The keymap is the
1641 association between the keys that the user types and the functions that
1642 get run.  You can make your own keymaps, copy existing keymaps, and tell
1643 Readline which keymap to use.
1644
1645 </P>
1646 <P>
1647 <DL>
1648 <DT><U>Function:</U> Keymap <B>rl_make_bare_keymap</B> <I>()</I>
1649 <DD><A NAME="IDX108"></A>
1650 Returns a new, empty keymap.  The space for the keymap is allocated with
1651 <CODE>malloc ()</CODE>; you should <CODE>free ()</CODE> it when you are done.
1652 </DL>
1653
1654 </P>
1655 <P>
1656 <DL>
1657 <DT><U>Function:</U> Keymap <B>rl_copy_keymap</B> <I>(Keymap map)</I>
1658 <DD><A NAME="IDX109"></A>
1659 Return a new keymap which is a copy of <VAR>map</VAR>.
1660 </DL>
1661
1662 </P>
1663 <P>
1664 <DL>
1665 <DT><U>Function:</U> Keymap <B>rl_make_keymap</B> <I>()</I>
1666 <DD><A NAME="IDX110"></A>
1667 Return a new keymap with the printing characters bound to rl_insert,
1668 the lowercase Meta characters bound to run their equivalents, and
1669 the Meta digits bound to produce numeric arguments.
1670 </DL>
1671
1672 </P>
1673 <P>
1674 <DL>
1675 <DT><U>Function:</U> void <B>rl_discard_keymap</B> <I>(Keymap keymap)</I>
1676 <DD><A NAME="IDX111"></A>
1677 Free the storage associated with <VAR>keymap</VAR>.
1678 </DL>
1679
1680 </P>
1681 <P>
1682 Readline has several internal keymaps.  These functions allow you to
1683 change which keymap is active.
1684
1685 </P>
1686 <P>
1687 <DL>
1688 <DT><U>Function:</U> Keymap <B>rl_get_keymap</B> <I>()</I>
1689 <DD><A NAME="IDX112"></A>
1690 Returns the currently active keymap.
1691 </DL>
1692
1693 </P>
1694 <P>
1695 <DL>
1696 <DT><U>Function:</U> void <B>rl_set_keymap</B> <I>(Keymap keymap)</I>
1697 <DD><A NAME="IDX113"></A>
1698 Makes <VAR>keymap</VAR> the currently active keymap.
1699 </DL>
1700
1701 </P>
1702 <P>
1703 <DL>
1704 <DT><U>Function:</U> Keymap <B>rl_get_keymap_by_name</B> <I>(char *name)</I>
1705 <DD><A NAME="IDX114"></A>
1706 Return the keymap matching <VAR>name</VAR>.  <VAR>name</VAR> is one which would
1707 be supplied in a <CODE>set keymap</CODE> inputrc line (@xref{Readline Init File}).
1708 </DL>
1709
1710 </P>
1711 <P>
1712 <DL>
1713 <DT><U>Function:</U> char * <B>rl_get_keymap_name</B> <I>(Keymap keymap)</I>
1714 <DD><A NAME="IDX115"></A>
1715 Return the name matching <VAR>keymap</VAR>.  <VAR>name</VAR> is one which would
1716 be supplied in a <CODE>set keymap</CODE> inputrc line (@xref{Readline Init File}).
1717 </DL>
1718
1719 </P>
1720
1721
1722 <H3><A NAME="SEC26" HREF="readline_toc.html#TOC26">Binding Keys</A></H3>
1723
1724 <P>
1725 You associate keys with functions through the keymap.  Readline has
1726 several internal keymaps: <CODE>emacs_standard_keymap</CODE>,
1727 <CODE>emacs_meta_keymap</CODE>, <CODE>emacs_ctlx_keymap</CODE>,
1728 <CODE>vi_movement_keymap</CODE>, and <CODE>vi_insertion_keymap</CODE>.
1729 <CODE>emacs_standard_keymap</CODE> is the default, and the examples in
1730 this manual assume that.
1731
1732 </P>
1733 <P>
1734 These functions manage key bindings.
1735
1736 </P>
1737 <P>
1738 <DL>
1739 <DT><U>Function:</U> int <B>rl_bind_key</B> <I>(int key, Function *function)</I>
1740 <DD><A NAME="IDX116"></A>
1741 Binds <VAR>key</VAR> to <VAR>function</VAR> in the currently active keymap.
1742 Returns non-zero in the case of an invalid <VAR>key</VAR>.
1743 </DL>
1744
1745 </P>
1746 <P>
1747 <DL>
1748 <DT><U>Function:</U> int <B>rl_bind_key_in_map</B> <I>(int key, Function *function, Keymap map)</I>
1749 <DD><A NAME="IDX117"></A>
1750 Bind <VAR>key</VAR> to <VAR>function</VAR> in <VAR>map</VAR>.  Returns non-zero in the case
1751 of an invalid <VAR>key</VAR>.
1752 </DL>
1753
1754 </P>
1755 <P>
1756 <DL>
1757 <DT><U>Function:</U> int <B>rl_unbind_key</B> <I>(int key)</I>
1758 <DD><A NAME="IDX118"></A>
1759 Bind <VAR>key</VAR> to the null function in the currently active keymap.
1760 Returns non-zero in case of error.
1761 </DL>
1762
1763 </P>
1764 <P>
1765 <DL>
1766 <DT><U>Function:</U> int <B>rl_unbind_key_in_map</B> <I>(int key, Keymap map)</I>
1767 <DD><A NAME="IDX119"></A>
1768 Bind <VAR>key</VAR> to the null function in <VAR>map</VAR>.
1769 Returns non-zero in case of error.
1770 </DL>
1771
1772 </P>
1773 <P>
1774 <DL>
1775 <DT><U>Function:</U> int <B>rl_unbind_function_in_map</B> <I>(Function *function, Keymap map)</I>
1776 <DD><A NAME="IDX120"></A>
1777 Unbind all keys that execute <VAR>function</VAR> in <VAR>map</VAR>.
1778 </DL>
1779
1780 </P>
1781 <P>
1782 <DL>
1783 <DT><U>Function:</U> int <B>rl_unbind_command_in_map</B> <I>(char *command, Keymap map)</I>
1784 <DD><A NAME="IDX121"></A>
1785 Unbind all keys that are bound to <VAR>command</VAR> in <VAR>map</VAR>.
1786 </DL>
1787
1788 </P>
1789 <P>
1790 <DL>
1791 <DT><U>Function:</U> int <B>rl_generic_bind</B> <I>(int type, char *keyseq, char *data, Keymap map)</I>
1792 <DD><A NAME="IDX122"></A>
1793 Bind the key sequence represented by the string <VAR>keyseq</VAR> to the arbitrary
1794 pointer <VAR>data</VAR>.  <VAR>type</VAR> says what kind of data is pointed to by
1795 <VAR>data</VAR>; this can be a function (<CODE>ISFUNC</CODE>), a macro
1796 (<CODE>ISMACR</CODE>), or a keymap (<CODE>ISKMAP</CODE>).  This makes new keymaps as
1797 necessary.  The initial keymap in which to do bindings is <VAR>map</VAR>.
1798 </DL>
1799
1800 </P>
1801 <P>
1802 <DL>
1803 <DT><U>Function:</U> int <B>rl_parse_and_bind</B> <I>(char *line)</I>
1804 <DD><A NAME="IDX123"></A>
1805 Parse <VAR>line</VAR> as if it had been read from the <CODE>inputrc</CODE> file and
1806 perform any key bindings and variable assignments found
1807 (@xref{Readline Init File}).
1808 </DL>
1809
1810 </P>
1811 <P>
1812 <DL>
1813 <DT><U>Function:</U> int <B>rl_read_init_file</B> <I>(char *filename)</I>
1814 <DD><A NAME="IDX124"></A>
1815 Read keybindings and variable assignments from <VAR>filename</VAR>
1816 (@xref{Readline Init File}).
1817 </DL>
1818
1819 </P>
1820
1821
1822 <H3><A NAME="SEC27" HREF="readline_toc.html#TOC27">Associating Function Names and Bindings</A></H3>
1823
1824 <P>
1825 These functions allow you to find out what keys invoke named functions
1826 and the functions invoked by a particular key sequence.
1827
1828 </P>
1829 <P>
1830 <DL>
1831 <DT><U>Function:</U> Function * <B>rl_named_function</B> <I>(char *name)</I>
1832 <DD><A NAME="IDX125"></A>
1833 Return the function with name <VAR>name</VAR>.
1834 </DL>
1835
1836 </P>
1837 <P>
1838 <DL>
1839 <DT><U>Function:</U> Function * <B>rl_function_of_keyseq</B> <I>(char *keyseq, Keymap map, int *type)</I>
1840 <DD><A NAME="IDX126"></A>
1841 Return the function invoked by <VAR>keyseq</VAR> in keymap <VAR>map</VAR>.
1842 If <VAR>map</VAR> is NULL, the current keymap is used.  If <VAR>type</VAR> is
1843 not NULL, the type of the object is returned in it (one of <CODE>ISFUNC</CODE>,
1844 <CODE>ISKMAP</CODE>, or <CODE>ISMACR</CODE>).
1845 </DL>
1846
1847 </P>
1848 <P>
1849 <DL>
1850 <DT><U>Function:</U> char ** <B>rl_invoking_keyseqs</B> <I>(Function *function)</I>
1851 <DD><A NAME="IDX127"></A>
1852 Return an array of strings representing the key sequences used to
1853 invoke <VAR>function</VAR> in the current keymap.
1854 </DL>
1855
1856 </P>
1857 <P>
1858 <DL>
1859 <DT><U>Function:</U> char ** <B>rl_invoking_keyseqs_in_map</B> <I>(Function *function, Keymap map)</I>
1860 <DD><A NAME="IDX128"></A>
1861 Return an array of strings representing the key sequences used to
1862 invoke <VAR>function</VAR> in the keymap <VAR>map</VAR>.
1863 </DL>
1864
1865 </P>
1866 <P>
1867 <DL>
1868 <DT><U>Function:</U> void <B>rl_function_dumper</B> <I>(int readable)</I>
1869 <DD><A NAME="IDX129"></A>
1870 Print the readline function names and the key sequences currently
1871 bound to them to <CODE>rl_outstream</CODE>.  If <VAR>readable</VAR> is non-zero,
1872 the list is formatted in such a way that it can be made part of an
1873 <CODE>inputrc</CODE> file and re-read.
1874 </DL>
1875
1876 </P>
1877 <P>
1878 <DL>
1879 <DT><U>Function:</U> void <B>rl_list_funmap_names</B> <I>()</I>
1880 <DD><A NAME="IDX130"></A>
1881 Print the names of all bindable Readline functions to <CODE>rl_outstream</CODE>.
1882 </DL>
1883
1884 </P>
1885
1886
1887 <H3><A NAME="SEC28" HREF="readline_toc.html#TOC28">Allowing Undoing</A></H3>
1888
1889 <P>
1890 Supporting the undo command is a painless thing, and makes your
1891 functions much more useful.  It is certainly easy to try
1892 something if you know you can undo it.  I could use an undo function for
1893 the stock market.
1894
1895 </P>
1896 <P>
1897 If your function simply inserts text once, or deletes text once, and
1898 uses <CODE>rl_insert_text ()</CODE> or <CODE>rl_delete_text ()</CODE> to do it, then
1899 undoing is already done for you automatically.
1900
1901 </P>
1902 <P>
1903 If you do multiple insertions or multiple deletions, or any combination
1904 of these operations, you should group them together into one operation.
1905 This is done with <CODE>rl_begin_undo_group ()</CODE> and
1906 <CODE>rl_end_undo_group ()</CODE>.
1907
1908 </P>
1909 <P>
1910 The types of events that can be undone are:
1911
1912 </P>
1913
1914 <PRE>
1915 enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END }; 
1916 </PRE>
1917
1918 <P>
1919 Notice that <CODE>UNDO_DELETE</CODE> means to insert some text, and
1920 <CODE>UNDO_INSERT</CODE> means to delete some text.  That is, the undo code
1921 tells undo what to undo, not how to undo it.  <CODE>UNDO_BEGIN</CODE> and
1922 <CODE>UNDO_END</CODE> are tags added by <CODE>rl_begin_undo_group ()</CODE> and
1923 <CODE>rl_end_undo_group ()</CODE>.
1924
1925 </P>
1926 <P>
1927 <DL>
1928 <DT><U>Function:</U> int <B>rl_begin_undo_group</B> <I>()</I>
1929 <DD><A NAME="IDX131"></A>
1930 Begins saving undo information in a group construct.  The undo
1931 information usually comes from calls to <CODE>rl_insert_text ()</CODE> and
1932 <CODE>rl_delete_text ()</CODE>, but could be the result of calls to
1933 <CODE>rl_add_undo ()</CODE>.
1934 </DL>
1935
1936 </P>
1937 <P>
1938 <DL>
1939 <DT><U>Function:</U> int <B>rl_end_undo_group</B> <I>()</I>
1940 <DD><A NAME="IDX132"></A>
1941 Closes the current undo group started with <CODE>rl_begin_undo_group
1942 ()</CODE>.  There should be one call to <CODE>rl_end_undo_group ()</CODE>
1943 for each call to <CODE>rl_begin_undo_group ()</CODE>.
1944 </DL>
1945
1946 </P>
1947 <P>
1948 <DL>
1949 <DT><U>Function:</U> void <B>rl_add_undo</B> <I>(enum undo_code what, int start, int end, char *text)</I>
1950 <DD><A NAME="IDX133"></A>
1951 Remember how to undo an event (according to <VAR>what</VAR>).  The affected
1952 text runs from <VAR>start</VAR> to <VAR>end</VAR>, and encompasses <VAR>text</VAR>.
1953 </DL>
1954
1955 </P>
1956 <P>
1957 <DL>
1958 <DT><U>Function:</U> void <B>free_undo_list</B> <I>()</I>
1959 <DD><A NAME="IDX134"></A>
1960 Free the existing undo list.
1961 </DL>
1962
1963 </P>
1964 <P>
1965 <DL>
1966 <DT><U>Function:</U> int <B>rl_do_undo</B> <I>()</I>
1967 <DD><A NAME="IDX135"></A>
1968 Undo the first thing on the undo list.  Returns <CODE>0</CODE> if there was
1969 nothing to undo, non-zero if something was undone.
1970 </DL>
1971
1972 </P>
1973 <P>
1974 Finally, if you neither insert nor delete text, but directly modify the
1975 existing text (e.g., change its case), call <CODE>rl_modifying ()</CODE>
1976 once, just before you modify the text.  You must supply the indices of
1977 the text range that you are going to modify.
1978
1979 </P>
1980 <P>
1981 <DL>
1982 <DT><U>Function:</U> int <B>rl_modifying</B> <I>(int start, int end)</I>
1983 <DD><A NAME="IDX136"></A>
1984 Tell Readline to save the text between <VAR>start</VAR> and <VAR>end</VAR> as a
1985 single undo unit.  It is assumed that you will subsequently modify
1986 that text.
1987 </DL>
1988
1989 </P>
1990
1991
1992 <H3><A NAME="SEC29" HREF="readline_toc.html#TOC29">Redisplay</A></H3>
1993
1994 <P>
1995 <DL>
1996 <DT><U>Function:</U> void <B>rl_redisplay</B> <I>()</I>
1997 <DD><A NAME="IDX137"></A>
1998 Change what's displayed on the screen to reflect the current contents
1999 of <CODE>rl_line_buffer</CODE>.
2000 </DL>
2001
2002 </P>
2003 <P>
2004 <DL>
2005 <DT><U>Function:</U> int <B>rl_forced_update_display</B> <I>()</I>
2006 <DD><A NAME="IDX138"></A>
2007 Force the line to be updated and redisplayed, whether or not
2008 Readline thinks the screen display is correct.
2009 </DL>
2010
2011 </P>
2012 <P>
2013 <DL>
2014 <DT><U>Function:</U> int <B>rl_on_new_line</B> <I>()</I>
2015 <DD><A NAME="IDX139"></A>
2016 Tell the update routines that we have moved onto a new (empty) line,
2017 usually after ouputting a newline.
2018 </DL>
2019
2020 </P>
2021 <P>
2022 <DL>
2023 <DT><U>Function:</U> int <B>rl_reset_line_state</B> <I>()</I>
2024 <DD><A NAME="IDX140"></A>
2025 Reset the display state to a clean state and redisplay the current line
2026 starting on a new line.
2027 </DL>
2028
2029 </P>
2030 <P>
2031 <DL>
2032 <DT><U>Function:</U> int <B>rl_message</B> <I>(va_alist)</I>
2033 <DD><A NAME="IDX141"></A>
2034 The arguments are a string as would be supplied to <CODE>printf</CODE>.  The
2035 resulting string is displayed in the <STRONG>echo area</STRONG>.  The echo area
2036 is also used to display numeric arguments and search strings.
2037 </DL>
2038
2039 </P>
2040 <P>
2041 <DL>
2042 <DT><U>Function:</U> int <B>rl_clear_message</B> <I>()</I>
2043 <DD><A NAME="IDX142"></A>
2044 Clear the message in the echo area.
2045 </DL>
2046
2047 </P>
2048
2049
2050 <H3><A NAME="SEC30" HREF="readline_toc.html#TOC30">Modifying Text</A></H3>
2051
2052 <P>
2053 <DL>
2054 <DT><U>Function:</U> int <B>rl_insert_text</B> <I>(char *text)</I>
2055 <DD><A NAME="IDX143"></A>
2056 Insert <VAR>text</VAR> into the line at the current cursor position.
2057 </DL>
2058
2059 </P>
2060 <P>
2061 <DL>
2062 <DT><U>Function:</U> int <B>rl_delete_text</B> <I>(int start, int end)</I>
2063 <DD><A NAME="IDX144"></A>
2064 Delete the text between <VAR>start</VAR> and <VAR>end</VAR> in the current line.
2065 </DL>
2066
2067 </P>
2068 <P>
2069 <DL>
2070 <DT><U>Function:</U> char * <B>rl_copy_text</B> <I>(int start, int end)</I>
2071 <DD><A NAME="IDX145"></A>
2072 Return a copy of the text between <VAR>start</VAR> and <VAR>end</VAR> in
2073 the current line.
2074 </DL>
2075
2076 </P>
2077 <P>
2078 <DL>
2079 <DT><U>Function:</U> int <B>rl_kill_text</B> <I>(int start, int end)</I>
2080 <DD><A NAME="IDX146"></A>
2081 Copy the text between <VAR>start</VAR> and <VAR>end</VAR> in the current line
2082 to the kill ring, appending or prepending to the last kill if the
2083 last command was a kill command.  The text is deleted.
2084 If <VAR>start</VAR> is less than <VAR>end</VAR>,
2085 the text is appended, otherwise prepended.  If the last command was
2086 not a kill, a new kill ring slot is used.
2087 </DL>
2088
2089 </P>
2090
2091
2092 <H3><A NAME="SEC31" HREF="readline_toc.html#TOC31">Utility Functions</A></H3>
2093
2094 <P>
2095 <DL>
2096 <DT><U>Function:</U> int <B>rl_read_key</B> <I>()</I>
2097 <DD><A NAME="IDX147"></A>
2098 Return the next character available.  This handles input inserted into
2099 the input stream via <VAR>pending input</VAR> (see section <A HREF="readline.html#SEC22">Readline Variables</A>)
2100 and <CODE>rl_stuff_char ()</CODE>, macros, and characters read from the keyboard.
2101 </DL>
2102
2103 </P>
2104 <P>
2105 <DL>
2106 <DT><U>Function:</U> int <B>rl_getc</B> <I>(FILE *)</I>
2107 <DD><A NAME="IDX148"></A>
2108 Return the next character available from the keyboard.
2109 </DL>
2110
2111 </P>
2112 <P>
2113 <DL>
2114 <DT><U>Function:</U> int <B>rl_stuff_char</B> <I>(int c)</I>
2115 <DD><A NAME="IDX149"></A>
2116 Insert <VAR>c</VAR> into the Readline input stream.  It will be "read"
2117 before Readline attempts to read characters from the terminal with
2118 <CODE>rl_read_key ()</CODE>.
2119 </DL>
2120
2121 </P>
2122 <P>
2123 <DL>
2124 <DT><U>Function:</U> rl_extend_line_buffer <B>(int</B> <I>len)</I>
2125 <DD><A NAME="IDX150"></A>
2126 Ensure that <CODE>rl_line_buffer</CODE> has enough space to hold <VAR>len</VAR>
2127 characters, possibly reallocating it if necessary.
2128 </DL>
2129
2130 </P>
2131 <P>
2132 <DL>
2133 <DT><U>Function:</U> int <B>rl_initialize</B> <I>()</I>
2134 <DD><A NAME="IDX151"></A>
2135 Initialize or re-initialize Readline's internal state.
2136 </DL>
2137
2138 </P>
2139 <P>
2140 <DL>
2141 <DT><U>Function:</U> int <B>rl_reset_terminal</B> <I>(char *terminal_name)</I>
2142 <DD><A NAME="IDX152"></A>
2143 Reinitialize Readline's idea of the terminal settings using
2144 <VAR>terminal_name</VAR> as the terminal type (e.g., <CODE>vt100</CODE>).
2145 </DL>
2146
2147 </P>
2148 <P>
2149 <DL>
2150 <DT><U>Function:</U> int <B>alphabetic</B> <I>(int c)</I>
2151 <DD><A NAME="IDX153"></A>
2152 Return 1 if <VAR>c</VAR> is an alphabetic character.
2153 </DL>
2154
2155 </P>
2156 <P>
2157 <DL>
2158 <DT><U>Function:</U> int <B>numeric</B> <I>(int c)</I>
2159 <DD><A NAME="IDX154"></A>
2160 Return 1 if <VAR>c</VAR> is a numeric character.
2161 </DL>
2162
2163 </P>
2164 <P>
2165 <DL>
2166 <DT><U>Function:</U> int <B>ding</B> <I>()</I>
2167 <DD><A NAME="IDX155"></A>
2168 Ring the terminal bell, obeying the setting of <CODE>bell-style</CODE>.
2169 </DL>
2170
2171 </P>
2172 <P>
2173 The following are implemented as macros, defined in <CODE>chartypes.h</CODE>.
2174
2175 </P>
2176 <P>
2177 <DL>
2178 <DT><U>Function:</U> int <B>uppercase_p</B> <I>(int c)</I>
2179 <DD><A NAME="IDX156"></A>
2180 Return 1 if <VAR>c</VAR> is an uppercase alphabetic character.
2181 </DL>
2182
2183 </P>
2184 <P>
2185 <DL>
2186 <DT><U>Function:</U> int <B>lowercase_p</B> <I>(int c)</I>
2187 <DD><A NAME="IDX157"></A>
2188 Return 1 if <VAR>c</VAR> is a lowercase alphabetic character.
2189 </DL>
2190
2191 </P>
2192 <P>
2193 <DL>
2194 <DT><U>Function:</U> int <B>digit_p</B> <I>(int c)</I>
2195 <DD><A NAME="IDX158"></A>
2196 Return 1 if <VAR>c</VAR> is a numeric character.
2197 </DL>
2198
2199 </P>
2200 <P>
2201 <DL>
2202 <DT><U>Function:</U> int <B>to_upper</B> <I>(int c)</I>
2203 <DD><A NAME="IDX159"></A>
2204 If <VAR>c</VAR> is a lowercase alphabetic character, return the corresponding
2205 uppercase character.
2206 </DL>
2207
2208 </P>
2209 <P>
2210 <DL>
2211 <DT><U>Function:</U> int <B>to_lower</B> <I>(int c)</I>
2212 <DD><A NAME="IDX160"></A>
2213 If <VAR>c</VAR> is an uppercase alphabetic character, return the corresponding
2214 lowercase character.
2215 </DL>
2216
2217 </P>
2218 <P>
2219 <DL>
2220 <DT><U>Function:</U> int <B>digit_value</B> <I>(int c)</I>
2221 <DD><A NAME="IDX161"></A>
2222 If <VAR>c</VAR> is a number, return the value it represents.
2223 </DL>
2224
2225 </P>
2226
2227
2228 <H3><A NAME="SEC32" HREF="readline_toc.html#TOC32">Alternate Interface</A></H3>
2229
2230 <P>
2231 An alternate interface is available to plain <CODE>readline()</CODE>.  Some
2232 applications need to interleave keyboard I/O with file, device, or
2233 window system I/O, typically by using a main loop to <CODE>select()</CODE>
2234 on various file descriptors.  To accomodate this need, readline can
2235 also be invoked as a `callback' function from an event loop.  There
2236 are functions available to make this easy.
2237
2238 </P>
2239 <P>
2240 <DL>
2241 <DT><U>Function:</U> void <B>rl_callback_handler_install</B> <I>(char *prompt, Vfunction *lhandler)</I>
2242 <DD><A NAME="IDX162"></A>
2243 Set up the terminal for readline I/O and display the initial
2244 expanded value of <VAR>prompt</VAR>.  Save the value of <VAR>lhandler</VAR> to
2245 use as a callback when a complete line of input has been entered.
2246 </DL>
2247
2248 </P>
2249 <P>
2250 <DL>
2251 <DT><U>Function:</U> void <B>rl_callback_read_char</B> <I>()</I>
2252 <DD><A NAME="IDX163"></A>
2253 Whenever an application determines that keyboard input is available, it
2254 should call <CODE>rl_callback_read_char()</CODE>, which will read the next
2255 character from the current input source.  If that character completes the
2256 line, <CODE>rl_callback_read_char</CODE> will invoke the <VAR>lhandler</VAR>
2257 function saved by <CODE>rl_callback_handler_install</CODE> to process the
2258 line.  <CODE>EOF</CODE> is  indicated by calling <VAR>lhandler</VAR> with a
2259 <CODE>NULL</CODE> line.
2260 </DL>
2261
2262 </P>
2263 <P>
2264 <DL>
2265 <DT><U>Function:</U> void <B>rl_callback_handler_remove</B> <I>()</I>
2266 <DD><A NAME="IDX164"></A>
2267 Restore the terminal to its initial state and remove the line handler.
2268 This may be called from within a callback as well as independently.
2269 </DL>
2270
2271 </P>
2272
2273
2274 <H3><A NAME="SEC33" HREF="readline_toc.html#TOC33">An Example</A></H3>
2275
2276 <P>
2277 Here is a function which changes lowercase characters to their uppercase
2278 equivalents, and uppercase characters to lowercase.  If
2279 this function was bound to <SAMP>`M-c'</SAMP>, then typing <SAMP>`M-c'</SAMP> would
2280 change the case of the character under point.  Typing <SAMP>`M-1 0 M-c'</SAMP>
2281 would change the case of the following 10 characters, leaving the cursor on
2282 the last character changed.
2283
2284 </P>
2285
2286 <PRE>
2287 /* Invert the case of the COUNT following characters. */
2288 int
2289 invert_case_line (count, key)
2290      int count, key;
2291 {
2292   register int start, end, i;
2293
2294   start = rl_point;
2295
2296   if (rl_point &#62;= rl_end)
2297     return (0);
2298
2299   if (count &#60; 0)
2300     {
2301       direction = -1;
2302       count = -count;
2303     }
2304   else
2305     direction = 1;
2306       
2307   /* Find the end of the range to modify. */
2308   end = start + (count * direction);
2309
2310   /* Force it to be within range. */
2311   if (end &#62; rl_end)
2312     end = rl_end;
2313   else if (end &#60; 0)
2314     end = 0;
2315
2316   if (start == end)
2317     return (0);
2318
2319   if (start &#62; end)
2320     {
2321       int temp = start;
2322       start = end;
2323       end = temp;
2324     }
2325
2326   /* Tell readline that we are modifying the line, so it will save
2327      the undo information. */
2328   rl_modifying (start, end);
2329
2330   for (i = start; i != end; i++)
2331     {
2332       if (uppercase_p (rl_line_buffer[i]))
2333         rl_line_buffer[i] = to_lower (rl_line_buffer[i]);
2334       else if (lowercase_p (rl_line_buffer[i]))
2335         rl_line_buffer[i] = to_upper (rl_line_buffer[i]);
2336     }
2337   /* Move point to on top of the last character changed. */
2338   rl_point = (direction == 1) ? end - 1 : start;
2339   return (0);
2340 }
2341 </PRE>
2342
2343
2344
2345 <H2><A NAME="SEC34" HREF="readline_toc.html#TOC34">Custom Completers</A></H2>
2346
2347 <P>
2348 Typically, a program that reads commands from the user has a way of
2349 disambiguating commands and data.  If your program is one of these, then
2350 it can provide completion for commands, data, or both.
2351 The following sections describe how your program and Readline
2352 cooperate to provide this service.
2353
2354 </P>
2355
2356
2357
2358 <H3><A NAME="SEC35" HREF="readline_toc.html#TOC35">How Completing Works</A></H3>
2359
2360 <P>
2361 In order to complete some text, the full list of possible completions
2362 must be available.  That is, it is not possible to accurately
2363 expand a partial word without knowing all of the possible words
2364 which make sense in that context.  The Readline library provides
2365 the user interface to completion, and two of the most common
2366 completion functions:  filename and username.  For completing other types
2367 of text, you must write your own completion function.  This section
2368 describes exactly what such functions must do, and provides an example.
2369
2370 </P>
2371 <P>
2372 There are three major functions used to perform completion:
2373
2374 </P>
2375
2376 <OL>
2377 <LI>
2378
2379 The user-interface function <CODE>rl_complete ()</CODE>.  This function is
2380 called with the same arguments as other Readline
2381 functions intended for interactive use:  <VAR>count</VAR> and
2382 <VAR>invoking_key</VAR>.  It isolates the word to be completed and calls
2383 <CODE>completion_matches ()</CODE> to generate a list of possible completions.
2384 It then either lists the possible completions, inserts the possible
2385 completions, or actually performs the
2386 completion, depending on which behavior is desired.
2387
2388 <LI>
2389
2390 The internal function <CODE>completion_matches ()</CODE> uses your
2391 <STRONG>generator</STRONG> function to generate the list of possible matches, and
2392 then returns the array of these matches.  You should place the address
2393 of your generator function in <CODE>rl_completion_entry_function</CODE>.
2394
2395 <LI>
2396
2397 The generator function is called repeatedly from
2398 <CODE>completion_matches ()</CODE>, returning a string each time.  The
2399 arguments to the generator function are <VAR>text</VAR> and <VAR>state</VAR>.
2400 <VAR>text</VAR> is the partial word to be completed.  <VAR>state</VAR> is zero the
2401 first time the function is called, allowing the generator to perform
2402 any necessary initialization, and a positive non-zero integer for
2403 each subsequent call.  When the generator function returns
2404 <CODE>(char *)NULL</CODE> this signals <CODE>completion_matches ()</CODE> that there are
2405 no more possibilities left.  Usually the generator function computes the
2406 list of possible completions when <VAR>state</VAR> is zero, and returns them
2407 one at a time on subsequent calls.  Each string the generator function
2408 returns as a match must be allocated with <CODE>malloc()</CODE>; Readline
2409 frees the strings when it has finished with them.
2410
2411 </OL>
2412
2413 <P>
2414 <DL>
2415 <DT><U>Function:</U> int <B>rl_complete</B> <I>(int ignore, int invoking_key)</I>
2416 <DD><A NAME="IDX165"></A>
2417 Complete the word at or before point.  You have supplied the function
2418 that does the initial simple matching selection algorithm (see
2419 <CODE>completion_matches ()</CODE>).  The default is to do filename completion.
2420 </DL>
2421
2422 </P>
2423 <P>
2424 <DL>
2425 <DT><U>Variable:</U> Function * <B>rl_completion_entry_function</B>
2426 <DD><A NAME="IDX166"></A>
2427 This is a pointer to the generator function for <CODE>completion_matches
2428 ()</CODE>.  If the value of <CODE>rl_completion_entry_function</CODE> is
2429 <CODE>(Function *)NULL</CODE> then the default filename generator function,
2430 <CODE>filename_completion_function ()</CODE>, is used.
2431 </DL>
2432
2433 </P>
2434
2435
2436 <H3><A NAME="SEC36" HREF="readline_toc.html#TOC36">Completion Functions</A></H3>
2437
2438 <P>
2439 Here is the complete list of callable completion functions present in
2440 Readline.
2441
2442 </P>
2443 <P>
2444 <DL>
2445 <DT><U>Function:</U> int <B>rl_complete_internal</B> <I>(int what_to_do)</I>
2446 <DD><A NAME="IDX167"></A>
2447 Complete the word at or before point.  <VAR>what_to_do</VAR> says what to do
2448 with the completion.  A value of <SAMP>`?'</SAMP> means list the possible
2449 completions.  <SAMP>`TAB'</SAMP> means do standard completion.  <SAMP>`*'</SAMP> means
2450 insert all of the possible completions.  <SAMP>`!'</SAMP> means to display
2451 all of the possible completions, if there is more than one, as well as
2452 performing partial completion.
2453 </DL>
2454
2455 </P>
2456 <P>
2457 <DL>
2458 <DT><U>Function:</U> int <B>rl_complete</B> <I>(int ignore, int invoking_key)</I>
2459 <DD><A NAME="IDX168"></A>
2460 Complete the word at or before point.  You have supplied the function
2461 that does the initial simple matching selection algorithm (see
2462 <CODE>completion_matches ()</CODE> and <CODE>rl_completion_entry_function</CODE>).
2463 The default is to do filename
2464 completion.  This calls <CODE>rl_complete_internal ()</CODE> with an
2465 argument depending on <VAR>invoking_key</VAR>.
2466 </DL>
2467
2468 </P>
2469 <P>
2470 <DL>
2471 <DT><U>Function:</U> int <B>rl_possible_completions</B> <I>(int count, int invoking_key))</I>
2472 <DD><A NAME="IDX169"></A>
2473 List the possible completions.  See description of <CODE>rl_complete
2474 ()</CODE>.  This calls <CODE>rl_complete_internal ()</CODE> with an argument of
2475 <SAMP>`?'</SAMP>.
2476 </DL>
2477
2478 </P>
2479 <P>
2480 <DL>
2481 <DT><U>Function:</U> int <B>rl_insert_completions</B> <I>(int count, int invoking_key))</I>
2482 <DD><A NAME="IDX170"></A>
2483 Insert the list of possible completions into the line, deleting the
2484 partially-completed word.  See description of <CODE>rl_complete ()</CODE>.
2485 This calls <CODE>rl_complete_internal ()</CODE> with an argument of <SAMP>`*'</SAMP>.
2486 </DL>
2487
2488 </P>
2489 <P>
2490 <DL>
2491 <DT><U>Function:</U> char ** <B>completion_matches</B> <I>(char *text, CPFunction *entry_func)</I>
2492 <DD><A NAME="IDX171"></A>
2493 Returns an array of <CODE>(char *)</CODE> which is a list of completions for
2494 <VAR>text</VAR>.  If there are no completions, returns <CODE>(char **)NULL</CODE>.
2495 The first entry in the returned array is the substitution for <VAR>text</VAR>.
2496 The remaining entries are the possible completions.  The array is
2497 terminated with a <CODE>NULL</CODE> pointer.
2498
2499 </P>
2500 <P>
2501 <VAR>entry_func</VAR> is a function of two args, and returns a
2502 <CODE>(char *)</CODE>.  The first argument is <VAR>text</VAR>.  The second is a
2503 state argument; it is zero on the first call, and non-zero on subsequent
2504 calls.  <VAR>entry_func</VAR> returns a <CODE>NULL</CODE>  pointer to the caller
2505 when there are no more matches.
2506 </DL>
2507
2508 </P>
2509 <P>
2510 <DL>
2511 <DT><U>Function:</U> char * <B>filename_completion_function</B> <I>(char *text, int state)</I>
2512 <DD><A NAME="IDX172"></A>
2513 A generator function for filename completion in the general case.  Note
2514 that completion in Bash is a little different because of all
2515 the pathnames that must be followed when looking up completions for a
2516 command.  The Bash source is a useful reference for writing custom
2517 completion functions.
2518 </DL>
2519
2520 </P>
2521 <P>
2522 <DL>
2523 <DT><U>Function:</U> char * <B>username_completion_function</B> <I>(char *text, int state)</I>
2524 <DD><A NAME="IDX173"></A>
2525 A completion generator for usernames.  <VAR>text</VAR> contains a partial
2526 username preceded by a random character (usually <SAMP>`~'</SAMP>).  As with all
2527 completion generators, <VAR>state</VAR> is zero on the first call and non-zero
2528 for subsequent calls.
2529 </DL>
2530
2531 </P>
2532
2533
2534 <H3><A NAME="SEC37" HREF="readline_toc.html#TOC37">Completion Variables</A></H3>
2535
2536 <P>
2537 <DL>
2538 <DT><U>Variable:</U> Function * <B>rl_completion_entry_function</B>
2539 <DD><A NAME="IDX174"></A>
2540 A pointer to the generator function for <CODE>completion_matches ()</CODE>.
2541 <CODE>NULL</CODE> means to use <CODE>filename_entry_function ()</CODE>, the default
2542 filename completer.
2543 </DL>
2544
2545 </P>
2546 <P>
2547 <DL>
2548 <DT><U>Variable:</U> CPPFunction * <B>rl_attempted_completion_function</B>
2549 <DD><A NAME="IDX175"></A>
2550 A pointer to an alternative function to create matches.
2551 The function is called with <VAR>text</VAR>, <VAR>start</VAR>, and <VAR>end</VAR>.
2552 <VAR>start</VAR> and <VAR>end</VAR> are indices in <CODE>rl_line_buffer</CODE> saying
2553 what the boundaries of <VAR>text</VAR> are.  If this function exists and
2554 returns <CODE>NULL</CODE>, or if this variable is set to <CODE>NULL</CODE>, then
2555 <CODE>rl_complete ()</CODE> will call the value of
2556 <CODE>rl_completion_entry_function</CODE> to generate matches, otherwise the
2557 array of strings returned will be used.
2558 </DL>
2559
2560 </P>
2561 <P>
2562 <DL>
2563 <DT><U>Variable:</U> CPFunction * <B>rl_filename_quoting_function</B>
2564 <DD><A NAME="IDX176"></A>
2565 A pointer to a function that will quote a filename in an application-
2566 specific fashion.  This is called if filename completion is being
2567 attempted and one of the characters in <CODE>rl_filename_quote_characters</CODE>
2568 appears in a completed filename.  The function is called with
2569 <VAR>text</VAR>, <VAR>match_type</VAR>, and <VAR>quote_pointer</VAR>.  The <VAR>text</VAR>
2570 is the filename to be quoted.  The <VAR>match_type</VAR> is either
2571 <CODE>SINGLE_MATCH</CODE>, if there is only one completion match, or
2572 <CODE>MULT_MATCH</CODE>.  Some functions use this to decide whether or not to
2573 insert a closing quote character.  The <VAR>quote_pointer</VAR> is a pointer
2574 to any opening quote character the user typed.  Some functions choose
2575 to reset this character.
2576 </DL>
2577
2578 </P>
2579 <P>
2580 <DL>
2581 <DT><U>Variable:</U> CPFunction * <B>rl_filename_dequoting_function</B>
2582 <DD><A NAME="IDX177"></A>
2583 A pointer to a function that will remove application-specific quoting
2584 characters from a filename before completion is attempted, so those
2585 characters do not interfere with matching the text against names in
2586 the filesystem.  It is called with <VAR>text</VAR>, the text of the word
2587 to be dequoted, and <VAR>quote_char</VAR>, which is the quoting character 
2588 that delimits the filename (usually <SAMP>`''</SAMP> or <SAMP>`"'</SAMP>).  If
2589 <VAR>quote_char</VAR> is zero, the filename was not in an embedded string.
2590 </DL>
2591
2592 </P>
2593 <P>
2594 <DL>
2595 <DT><U>Variable:</U> Function * <B>rl_char_is_quoted_p</B>
2596 <DD><A NAME="IDX178"></A>
2597 A pointer to a function to call that determines whether or not a specific
2598 character in the line buffer is quoted, according to whatever quoting
2599 mechanism the program calling readline uses.  The function is called with
2600 two arguments: <VAR>text</VAR>, the text of the line, and <VAR>index</VAR>, the
2601 index of the character in the line.  It is used to decide whether a
2602 character found in <CODE>rl_completer_word_break_characters</CODE> should be
2603 used to break words for the completer.
2604 </DL>
2605
2606 </P>
2607 <P>
2608 <DL>
2609 <DT><U>Variable:</U> int <B>rl_completion_query_items</B>
2610 <DD><A NAME="IDX179"></A>
2611 Up to this many items will be displayed in response to a
2612 possible-completions call.  After that, we ask the user if she is sure
2613 she wants to see them all.  The default value is 100.
2614 </DL>
2615
2616 </P>
2617 <P>
2618 <DL>
2619 <DT><U>Variable:</U> char * <B>rl_basic_word_break_characters</B>
2620 <DD><A NAME="IDX180"></A>
2621 The basic list of characters that signal a break between words for the
2622 completer routine.  The default value of this variable is the characters
2623 which break words for completion in Bash, i.e.,
2624 <CODE>" \t\n\"\\'`@$&#62;&#60;=;|&#38;{("</CODE>.
2625 </DL>
2626
2627 </P>
2628 <P>
2629 <DL>
2630 <DT><U>Variable:</U> char * <B>rl_basic_quote_characters</B>
2631 <DD><A NAME="IDX181"></A>
2632 List of quote characters which can cause a word break.
2633 </DL>
2634
2635 </P>
2636 <P>
2637 <DL>
2638 <DT><U>Variable:</U> char * <B>rl_completer_word_break_characters</B>
2639 <DD><A NAME="IDX182"></A>
2640 The list of characters that signal a break between words for
2641 <CODE>rl_complete_internal ()</CODE>.  The default list is the value of
2642 <CODE>rl_basic_word_break_characters</CODE>.
2643 </DL>
2644
2645 </P>
2646 <P>
2647 <DL>
2648 <DT><U>Variable:</U> char * <B>rl_completer_quote_characters</B>
2649 <DD><A NAME="IDX183"></A>
2650 List of characters which can be used to quote a substring of the line.
2651 Completion occurs on the entire substring, and within the substring
2652 <CODE>rl_completer_word_break_characters</CODE> are treated as any other character,
2653 unless they also appear within this list.
2654 </DL>
2655
2656 </P>
2657 <P>
2658 <DL>
2659 <DT><U>Variable:</U> char * <B>rl_filename_quote_characters</B>
2660 <DD><A NAME="IDX184"></A>
2661 A list of characters that cause a filename to be quoted by the completer
2662 when they appear in a completed filename.  The default is the null string.
2663 </DL>
2664
2665 </P>
2666 <P>
2667 <DL>
2668 <DT><U>Variable:</U> char * <B>rl_special_prefixes</B>
2669 <DD><A NAME="IDX185"></A>
2670 The list of characters that are word break characters, but should be
2671 left in <VAR>text</VAR> when it is passed to the completion function.
2672 Programs can use this to help determine what kind of completing to do.
2673 For instance, Bash sets this variable to "$@" so that it can complete
2674 shell variables and hostnames.
2675 </DL>
2676
2677 </P>
2678 <P>
2679 <DL>
2680 <DT><U>Variable:</U> int <B>rl_completion_append_character</B>
2681 <DD><A NAME="IDX186"></A>
2682 When a single completion alternative matches at the end of the command
2683 line, this character is appended to the inserted completion text.  The
2684 default is a space character (<SAMP>` '</SAMP>).  Setting this to the null
2685 character (<SAMP>`\0'</SAMP>) prevents anything being appended automatically.
2686 This can be changed in custom completion functions to
2687 provide the "most sensible word separator character" according to
2688 an application-specific command line syntax specification.
2689 </DL>
2690
2691 </P>
2692 <P>
2693 <DL>
2694 <DT><U>Variable:</U> int <B>rl_ignore_completion_duplicates</B>
2695 <DD><A NAME="IDX187"></A>
2696 If non-zero, then disallow duplicates in the matches.  Default is 1.
2697 </DL>
2698
2699 </P>
2700 <P>
2701 <DL>
2702 <DT><U>Variable:</U> int <B>rl_filename_completion_desired</B>
2703 <DD><A NAME="IDX188"></A>
2704 Non-zero means that the results of the matches are to be treated as
2705 filenames.  This is <EM>always</EM> zero on entry, and can only be changed
2706 within a completion entry generator function.  If it is set to a non-zero
2707 value, directory names have a slash appended and Readline attempts to
2708 quote completed filenames if they contain any embedded word break
2709 characters.
2710 </DL>
2711
2712 </P>
2713 <P>
2714 <DL>
2715 <DT><U>Variable:</U> int <B>rl_filename_quoting_desired</B>
2716 <DD><A NAME="IDX189"></A>
2717 Non-zero means that the results of the matches are to be quoted using
2718 double quotes (or an application-specific quoting mechanism) if the
2719 completed filename contains any characters in
2720 <CODE>rl_filename_quote_chars</CODE>.  This is <EM>always</EM> non-zero
2721 on entry, and can only be changed within a completion entry generator
2722 function.  The quoting is effected via a call to the function pointed to
2723 by <CODE>rl_filename_quoting_function</CODE>.
2724 </DL>
2725
2726 </P>
2727 <P>
2728 <DL>
2729 <DT><U>Variable:</U> int <B>rl_inhibit_completion</B>
2730 <DD><A NAME="IDX190"></A>
2731 If this variable is non-zero, completion is inhibit&#60;ed.  The completion
2732 character will be inserted as any other bound to <CODE>self-insert</CODE>.
2733 </DL>
2734
2735 </P>
2736 <P>
2737 <DL>
2738 <DT><U>Variable:</U> Function * <B>rl_ignore_some_completions_function</B>
2739 <DD><A NAME="IDX191"></A>
2740 This function, if defined, is called by the completer when real filename
2741 completion is done, after all the matching names have been generated.
2742 It is passed a <CODE>NULL</CODE> terminated array of matches.
2743 The first element (<CODE>matches[0]</CODE>) is the
2744 maximal substring common to all matches. This function can
2745 re-arrange the list of matches as required, but each element deleted
2746 from the array must be freed.
2747 </DL>
2748
2749 </P>
2750 <P>
2751 <DL>
2752 <DT><U>Variable:</U> Function * <B>rl_directory_completion_hook</B>
2753 <DD><A NAME="IDX192"></A>
2754 This function, if defined, is allowed to modify the directory portion
2755 of filenames Readline completes.  It is called with the address of a
2756 string (the current directory name) as an argument.  It could be used
2757 to expand symbolic links or shell variables in pathnames.
2758 </DL>
2759
2760 </P>
2761
2762
2763 <H3><A NAME="SEC38" HREF="readline_toc.html#TOC38">A Short Completion Example</A></H3>
2764
2765 <P>
2766 Here is a small application demonstrating the use of the GNU Readline
2767 library.  It is called <CODE>fileman</CODE>, and the source code resides in
2768 <TT>`examples/fileman.c'</TT>.  This sample application provides
2769 completion of command names, line editing features, and access to the
2770 history list.
2771
2772 </P>
2773
2774 <PRE>
2775 /* fileman.c -- A tiny application which demonstrates how to use the
2776    GNU Readline library.  This application interactively allows users
2777    to manipulate files and their modes. */
2778
2779 #include &#60;stdio.h&#62;
2780 #include &#60;sys/types.h&#62;
2781 #include &#60;sys/file.h&#62;
2782 #include &#60;sys/stat.h&#62;
2783 #include &#60;sys/errno.h&#62;
2784
2785 #include &#60;readline/readline.h&#62;
2786 #include &#60;readline/history.h&#62;
2787
2788 extern char *getwd ();
2789 extern char *xmalloc ();
2790
2791 /* The names of functions that actually do the manipulation. */
2792 int com_list (), com_view (), com_rename (), com_stat (), com_pwd ();
2793 int com_delete (), com_help (), com_cd (), com_quit ();
2794
2795 /* A structure which contains information on the commands this program
2796    can understand. */
2797
2798 typedef struct {
2799   char *name;                   /* User printable name of the function. */
2800   Function *func;               /* Function to call to do the job. */
2801   char *doc;                    /* Documentation for this function.  */
2802 } COMMAND;
2803
2804 COMMAND commands[] = {
2805   { "cd", com_cd, "Change to directory DIR" },
2806   { "delete", com_delete, "Delete FILE" },
2807   { "help", com_help, "Display this text" },
2808   { "?", com_help, "Synonym for `help'" },
2809   { "list", com_list, "List files in DIR" },
2810   { "ls", com_list, "Synonym for `list'" },
2811   { "pwd", com_pwd, "Print the current working directory" },
2812   { "quit", com_quit, "Quit using Fileman" },
2813   { "rename", com_rename, "Rename FILE to NEWNAME" },
2814   { "stat", com_stat, "Print out statistics on FILE" },
2815   { "view", com_view, "View the contents of FILE" },
2816   { (char *)NULL, (Function *)NULL, (char *)NULL }
2817 };
2818
2819 /* Forward declarations. */
2820 char *stripwhite ();
2821 COMMAND *find_command ();
2822
2823 /* The name of this program, as taken from argv[0]. */
2824 char *progname;
2825
2826 /* When non-zero, this global means the user is done using this program. */
2827 int done;
2828
2829 char *
2830 dupstr (s)
2831      int s;
2832 {
2833   char *r;
2834
2835   r = xmalloc (strlen (s) + 1);
2836   strcpy (r, s);
2837   return (r);
2838 }
2839
2840 main (argc, argv)
2841      int argc;
2842      char **argv;
2843 {
2844   char *line, *s;
2845
2846   progname = argv[0];
2847
2848   initialize_readline ();       /* Bind our completer. */
2849
2850   /* Loop reading and executing lines until the user quits. */
2851   for ( ; done == 0; )
2852     {
2853       line = readline ("FileMan: ");
2854
2855       if (!line)
2856         break;
2857
2858       /* Remove leading and trailing whitespace from the line.
2859          Then, if there is anything left, add it to the history list
2860          and execute it. */
2861       s = stripwhite (line);
2862
2863       if (*s)
2864         {
2865           add_history (s);
2866           execute_line (s);
2867         }
2868
2869       free (line);
2870     }
2871   exit (0);
2872 }
2873
2874 /* Execute a command line. */
2875 int
2876 execute_line (line)
2877      char *line;
2878 {
2879   register int i;
2880   COMMAND *command;
2881   char *word;
2882
2883   /* Isolate the command word. */
2884   i = 0;
2885   while (line[i] &#38;&#38; whitespace (line[i]))
2886     i++;
2887   word = line + i;
2888
2889   while (line[i] &#38;&#38; !whitespace (line[i]))
2890     i++;
2891
2892   if (line[i])
2893     line[i++] = '\0';
2894
2895   command = find_command (word);
2896
2897   if (!command)
2898     {
2899       fprintf (stderr, "%s: No such command for FileMan.\n", word);
2900       return (-1);
2901     }
2902
2903   /* Get argument to command, if any. */
2904   while (whitespace (line[i]))
2905     i++;
2906
2907   word = line + i;
2908
2909   /* Call the function. */
2910   return ((*(command-&#62;func)) (word));
2911 }
2912
2913 /* Look up NAME as the name of a command, and return a pointer to that
2914    command.  Return a NULL pointer if NAME isn't a command name. */
2915 COMMAND *
2916 find_command (name)
2917      char *name;
2918 {
2919   register int i;
2920
2921   for (i = 0; commands[i].name; i++)
2922     if (strcmp (name, commands[i].name) == 0)
2923       return (&#38;commands[i]);
2924
2925   return ((COMMAND *)NULL);
2926 }
2927
2928 /* Strip whitespace from the start and end of STRING.  Return a pointer
2929    into STRING. */
2930 char *
2931 stripwhite (string)
2932      char *string;
2933 {
2934   register char *s, *t;
2935
2936   for (s = string; whitespace (*s); s++)
2937     ;
2938     
2939   if (*s == 0)
2940     return (s);
2941
2942   t = s + strlen (s) - 1;
2943   while (t &#62; s &#38;&#38; whitespace (*t))
2944     t--;
2945   *++t = '\0';
2946
2947   return s;
2948 }
2949
2950 /* **************************************************************** */
2951 /*                                                                  */
2952 /*                  Interface to Readline Completion                */
2953 /*                                                                  */
2954 /* **************************************************************** */
2955
2956 char *command_generator ();
2957 char **fileman_completion ();
2958
2959 /* Tell the GNU Readline library how to complete.  We want to try to complete
2960    on command names if this is the first word in the line, or on filenames
2961    if not. */
2962 initialize_readline ()
2963 {
2964   /* Allow conditional parsing of the ~/.inputrc file. */
2965   rl_readline_name = "FileMan";
2966
2967   /* Tell the completer that we want a crack first. */
2968   rl_attempted_completion_function = (CPPFunction *)fileman_completion;
2969 }
2970
2971 /* Attempt to complete on the contents of TEXT.  START and END bound the
2972    region of rl_line_buffer that contains the word to complete.  TEXT is
2973    the word to complete.  We can use the entire contents of rl_line_buffer
2974    in case we want to do some simple parsing.  Return the array of matches,
2975    or NULL if there aren't any. */
2976 char **
2977 fileman_completion (text, start, end)
2978      char *text;
2979      int start, end;
2980 {
2981   char **matches;
2982
2983   matches = (char **)NULL;
2984
2985   /* If this word is at the start of the line, then it is a command
2986      to complete.  Otherwise it is the name of a file in the current
2987      directory. */
2988   if (start == 0)
2989     matches = completion_matches (text, command_generator);
2990
2991   return (matches);
2992 }
2993
2994 /* Generator function for command completion.  STATE lets us know whether
2995    to start from scratch; without any state (i.e. STATE == 0), then we
2996    start at the top of the list. */
2997 char *
2998 command_generator (text, state)
2999      char *text;
3000      int state;
3001 {
3002   static int list_index, len;
3003   char *name;
3004
3005   /* If this is a new word to complete, initialize now.  This includes
3006      saving the length of TEXT for efficiency, and initializing the index
3007      variable to 0. */
3008   if (!state)
3009     {
3010       list_index = 0;
3011       len = strlen (text);
3012     }
3013
3014   /* Return the next name which partially matches from the command list. */
3015   while (name = commands[list_index].name)
3016     {
3017       list_index++;
3018
3019       if (strncmp (name, text, len) == 0)
3020         return (dupstr(name));
3021     }
3022
3023   /* If no names matched, then return NULL. */
3024   return ((char *)NULL);
3025 }
3026
3027 /* **************************************************************** */
3028 /*                                                                  */
3029 /*                       FileMan Commands                           */
3030 /*                                                                  */
3031 /* **************************************************************** */
3032
3033 /* String to pass to system ().  This is for the LIST, VIEW and RENAME
3034    commands. */
3035 static char syscom[1024];
3036
3037 /* List the file(s) named in arg. */
3038 com_list (arg)
3039      char *arg;
3040 {
3041   if (!arg)
3042     arg = "";
3043
3044   sprintf (syscom, "ls -FClg %s", arg);
3045   return (system (syscom));
3046 }
3047
3048 com_view (arg)
3049      char *arg;
3050 {
3051   if (!valid_argument ("view", arg))
3052     return 1;
3053
3054   sprintf (syscom, "more %s", arg);
3055   return (system (syscom));
3056 }
3057
3058 com_rename (arg)
3059      char *arg;
3060 {
3061   too_dangerous ("rename");
3062   return (1);
3063 }
3064
3065 com_stat (arg)
3066      char *arg;
3067 {
3068   struct stat finfo;
3069
3070   if (!valid_argument ("stat", arg))
3071     return (1);
3072
3073   if (stat (arg, &#38;finfo) == -1)
3074     {
3075       perror (arg);
3076       return (1);
3077     }
3078
3079   printf ("Statistics for `%s':\n", arg);
3080
3081   printf ("%s has %d link%s, and is %d byte%s in length.\n", arg,
3082           finfo.st_nlink,
3083           (finfo.st_nlink == 1) ? "" : "s",
3084           finfo.st_size,
3085           (finfo.st_size == 1) ? "" : "s");
3086   printf ("Inode Last Change at: %s", ctime (&#38;finfo.st_ctime));
3087   printf ("      Last access at: %s", ctime (&#38;finfo.st_atime));
3088   printf ("    Last modified at: %s", ctime (&#38;finfo.st_mtime));
3089   return (0);
3090 }
3091
3092 com_delete (arg)
3093      char *arg;
3094 {
3095   too_dangerous ("delete");
3096   return (1);
3097 }
3098
3099 /* Print out help for ARG, or for all of the commands if ARG is
3100    not present. */
3101 com_help (arg)
3102      char *arg;
3103 {
3104   register int i;
3105   int printed = 0;
3106
3107   for (i = 0; commands[i].name; i++)
3108     {
3109       if (!*arg || (strcmp (arg, commands[i].name) == 0))
3110         {
3111           printf ("%s\t\t%s.\n", commands[i].name, commands[i].doc);
3112           printed++;
3113         }
3114     }
3115
3116   if (!printed)
3117     {
3118       printf ("No commands match `%s'.  Possibilties are:\n", arg);
3119
3120       for (i = 0; commands[i].name; i++)
3121         {
3122           /* Print in six columns. */
3123           if (printed == 6)
3124             {
3125               printed = 0;
3126               printf ("\n");
3127             }
3128
3129           printf ("%s\t", commands[i].name);
3130           printed++;
3131         }
3132
3133       if (printed)
3134         printf ("\n");
3135     }
3136   return (0);
3137 }
3138
3139 /* Change to the directory ARG. */
3140 com_cd (arg)
3141      char *arg;
3142 {
3143   if (chdir (arg) == -1)
3144     {
3145       perror (arg);
3146       return 1;
3147     }
3148
3149   com_pwd ("");
3150   return (0);
3151 }
3152
3153 /* Print out the current working directory. */
3154 com_pwd (ignore)
3155      char *ignore;
3156 {
3157   char dir[1024], *s;
3158
3159   s = getwd (dir);
3160   if (s == 0)
3161     {
3162       printf ("Error getting pwd: %s\n", dir);
3163       return 1;
3164     }
3165
3166   printf ("Current directory is %s\n", dir);
3167   return 0;
3168 }
3169
3170 /* The user wishes to quit using this program.  Just set DONE non-zero. */
3171 com_quit (arg)
3172      char *arg;
3173 {
3174   done = 1;
3175   return (0);
3176 }
3177
3178 /* Function which tells you that you can't do this. */
3179 too_dangerous (caller)
3180      char *caller;
3181 {
3182   fprintf (stderr,
3183            "%s: Too dangerous for me to distribute.  Write it yourself.\n",
3184            caller);
3185 }
3186
3187 /* Return non-zero if ARG is a valid argument for CALLER, else print
3188    an error message and return zero. */
3189 int
3190 valid_argument (caller, arg)
3191      char *caller, *arg;
3192 {
3193   if (!arg || !*arg)
3194     {
3195       fprintf (stderr, "%s: Argument required.\n", caller);
3196       return (0);
3197     }
3198
3199   return (1);
3200 }
3201 </PRE>
3202
3203
3204
3205 <H1><A NAME="SEC39" HREF="readline_toc.html#TOC39">Concept Index</A></H1>
3206 <P>
3207 <H2>i</H2>
3208 <DIR>
3209 <LI><A HREF="readline.html#IDX1">interaction, readline</A>
3210 </DIR>
3211 <H2>r</H2>
3212 <DIR>
3213 <LI><A HREF="readline.html#IDX88">readline, function</A>
3214 </DIR>
3215
3216 </P>
3217
3218
3219 <H1><A NAME="SEC40" HREF="readline_toc.html#TOC40">Function and Variable Index</A></H1>
3220 <P>
3221 <H2>(</H2>
3222 <DIR>
3223 <LI><A HREF="readline.html#IDX150">(int</A>
3224 </DIR>
3225 <H2>a</H2>
3226 <DIR>
3227 <LI><A HREF="readline.html#IDX73">abort (C-g)</A>
3228 <LI><A HREF="readline.html#IDX26">accept-line (Newline, Return)</A>
3229 <LI><A HREF="readline.html#IDX153">alphabetic</A>
3230 </DIR>
3231 <H2>b</H2>
3232 <DIR>
3233 <LI><A HREF="readline.html#IDX21">backward-char (C-b)</A>
3234 <LI><A HREF="readline.html#IDX40">backward-delete-char (Rubout)</A>
3235 <LI><A HREF="readline.html#IDX50">backward-kill-line (C-x Rubout)</A>
3236 <LI><A HREF="readline.html#IDX54">backward-kill-word (M-DEL)</A>
3237 <LI><A HREF="readline.html#IDX23">backward-word (M-b)</A>
3238 <LI><A HREF="readline.html#IDX29">beginning-of-history (M-&#38;#60;)</A>
3239 <LI><A HREF="readline.html#IDX18">beginning-of-line (C-a)</A>
3240 <LI><A HREF="readline.html#IDX2">bell-style</A>
3241 </DIR>
3242 <H2>c</H2>
3243 <DIR>
3244 <LI><A HREF="readline.html#IDX71">call-last-kbd-macro (C-x e)</A>
3245 <LI><A HREF="readline.html#IDX48">capitalize-word (M-c)</A>
3246 <LI><A HREF="readline.html#IDX81">character-search (C-])</A>
3247 <LI><A HREF="readline.html#IDX82">character-search-backward (M-C-])</A>
3248 <LI><A HREF="readline.html#IDX24">clear-screen (C-l)</A>
3249 <LI><A HREF="readline.html#IDX3">comment-begin</A>
3250 <LI><A HREF="readline.html#IDX65">complete (TAB)</A>
3251 <LI><A HREF="readline.html#IDX4">completion-query-items</A>
3252 <LI><A HREF="readline.html#IDX171">completion_matches</A>
3253 <LI><A HREF="readline.html#IDX5">convert-meta</A>
3254 <LI><A HREF="readline.html#IDX59">copy-backward-word ()</A>
3255 <LI><A HREF="readline.html#IDX60">copy-forward-word ()</A>
3256 <LI><A HREF="readline.html#IDX58">copy-region-as-kill ()</A>
3257 </DIR>
3258 <H2>d</H2>
3259 <DIR>
3260 <LI><A HREF="readline.html#IDX39">delete-char (C-d)</A>
3261 <LI><A HREF="readline.html#IDX56">delete-horizontal-space ()</A>
3262 <LI><A HREF="readline.html#IDX63">digit-argument (M-0, M-1, ... M--)</A>
3263 <LI><A HREF="readline.html#IDX158">digit_p</A>
3264 <LI><A HREF="readline.html#IDX161">digit_value</A>
3265 <LI><A HREF="readline.html#IDX155">ding</A>
3266 <LI><A HREF="readline.html#IDX6">disable-completion</A>
3267 <LI><A HREF="readline.html#IDX74">do-uppercase-version (M-a, M-b, M-<VAR>x</VAR>, ...)</A>
3268 <LI><A HREF="readline.html#IDX47">downcase-word (M-l)</A>
3269 <LI><A HREF="readline.html#IDX84">dump-functions ()</A>
3270 <LI><A HREF="readline.html#IDX86">dump-macros ()</A>
3271 <LI><A HREF="readline.html#IDX85">dump-variables ()</A>
3272 </DIR>
3273 <H2>e</H2>
3274 <DIR>
3275 <LI><A HREF="readline.html#IDX7">editing-mode</A>
3276 <LI><A HREF="readline.html#IDX8">enable-keypad</A>
3277 <LI><A HREF="readline.html#IDX70">end-kbd-macro (C-x ))</A>
3278 <LI><A HREF="readline.html#IDX30">end-of-history (M-&#38;#62;)</A>
3279 <LI><A HREF="readline.html#IDX19">end-of-line (C-e)</A>
3280 <LI><A HREF="readline.html#IDX80">exchange-point-and-mark (C-x C-x)</A>
3281 <LI><A HREF="readline.html#IDX9">expand-tilde</A>
3282 </DIR>
3283 <H2>f</H2>
3284 <DIR>
3285 <LI><A HREF="readline.html#IDX172">filename_completion_function</A>
3286 <LI><A HREF="readline.html#IDX20">forward-char (C-f)</A>
3287 <LI><A HREF="readline.html#IDX32">forward-search-history (C-s)</A>
3288 <LI><A HREF="readline.html#IDX22">forward-word (M-f)</A>
3289 <LI><A HREF="readline.html#IDX134">free_undo_list</A>
3290 </DIR>
3291 <H2>h</H2>
3292 <DIR>
3293 <LI><A HREF="readline.html#IDX36">history-search-backward ()</A>
3294 <LI><A HREF="readline.html#IDX35">history-search-forward ()</A>
3295 <LI><A HREF="readline.html#IDX10">horizontal-scroll-mode</A>
3296 </DIR>
3297 <H2>i</H2>
3298 <DIR>
3299 <LI><A HREF="readline.html#IDX13">input-meta</A>
3300 <LI><A HREF="readline.html#IDX83">insert-comment (M-#)</A>
3301 <LI><A HREF="readline.html#IDX67">insert-completions (M-*)</A>
3302 </DIR>
3303 <H2>k</H2>
3304 <DIR>
3305 <LI><A HREF="readline.html#IDX11">keymap</A>
3306 <LI><A HREF="readline.html#IDX49">kill-line (C-k)</A>
3307 <LI><A HREF="readline.html#IDX57">kill-region ()</A>
3308 <LI><A HREF="readline.html#IDX52">kill-whole-line ()</A>
3309 <LI><A HREF="readline.html#IDX53">kill-word (M-d)</A>
3310 </DIR>
3311 <H2>l</H2>
3312 <DIR>
3313 <LI><A HREF="readline.html#IDX157">lowercase_p</A>
3314 </DIR>
3315 <H2>m</H2>
3316 <DIR>
3317 <LI><A HREF="readline.html#IDX12">mark-modified-lines</A>
3318 <LI><A HREF="readline.html#IDX68">menu-complete ()</A>
3319 <LI><A HREF="readline.html#IDX14">meta-flag</A>
3320 </DIR>
3321 <H2>n</H2>
3322 <DIR>
3323 <LI><A HREF="readline.html#IDX28">next-history (C-n)</A>
3324 <LI><A HREF="readline.html#IDX34">non-incremental-forward-search-history (M-n)</A>
3325 <LI><A HREF="readline.html#IDX33">non-incremental-reverse-search-history (M-p)</A>
3326 <LI><A HREF="readline.html#IDX154">numeric</A>
3327 </DIR>
3328 <H2>o</H2>
3329 <DIR>
3330 <LI><A HREF="readline.html#IDX15">output-meta</A>
3331 </DIR>
3332 <H2>p</H2>
3333 <DIR>
3334 <LI><A HREF="readline.html#IDX66">possible-completions (M-?)</A>
3335 <LI><A HREF="readline.html#IDX75">prefix-meta (ESC)</A>
3336 <LI><A HREF="readline.html#IDX27">previous-history (C-p)</A>
3337 </DIR>
3338 <H2>q</H2>
3339 <DIR>
3340 <LI><A HREF="readline.html#IDX41">quoted-insert (C-q, C-v)</A>
3341 </DIR>
3342 <H2>r</H2>
3343 <DIR>
3344 <LI><A HREF="readline.html#IDX72">re-read-init-file (C-x C-r)</A>
3345 <LI><A HREF="readline.html#IDX87">readline</A>
3346 <LI><A HREF="readline.html#IDX25">redraw-current-line ()</A>
3347 <LI><A HREF="readline.html#IDX31">reverse-search-history (C-r)</A>
3348 <LI><A HREF="readline.html#IDX77">revert-line (M-r)</A>
3349 <LI><A HREF="readline.html#IDX107">rl_add_defun</A>
3350 <LI><A HREF="readline.html#IDX133">rl_add_undo</A>
3351 <LI><A HREF="readline.html#IDX175">rl_attempted_completion_function</A>
3352 <LI><A HREF="readline.html#IDX181">rl_basic_quote_characters</A>
3353 <LI><A HREF="readline.html#IDX180">rl_basic_word_break_characters</A>
3354 <LI><A HREF="readline.html#IDX131">rl_begin_undo_group</A>
3355 <LI><A HREF="readline.html#IDX116">rl_bind_key</A>
3356 <LI><A HREF="readline.html#IDX117">rl_bind_key_in_map</A>
3357 <LI><A HREF="readline.html#IDX106">rl_binding_keymap</A>
3358 <LI><A HREF="readline.html#IDX162">rl_callback_handler_install</A>
3359 <LI><A HREF="readline.html#IDX164">rl_callback_handler_remove</A>
3360 <LI><A HREF="readline.html#IDX163">rl_callback_read_char</A>
3361 <LI><A HREF="readline.html#IDX178">rl_char_is_quoted_p</A>
3362 <LI><A HREF="readline.html#IDX142">rl_clear_message</A>
3363 <LI><A HREF="readline.html#IDX165">rl_complete</A>, <A HREF="rlman.html#IDX168">rl_complete</A>
3364 <LI><A HREF="readline.html#IDX167">rl_complete_internal</A>
3365 <LI><A HREF="readline.html#IDX183">rl_completer_quote_characters</A>
3366 <LI><A HREF="readline.html#IDX182">rl_completer_word_break_characters</A>
3367 <LI><A HREF="readline.html#IDX186">rl_completion_append_character</A>
3368 <LI><A HREF="readline.html#IDX166">rl_completion_entry_function</A>, <A HREF="rlman.html#IDX174">rl_completion_entry_function</A>
3369 <LI><A HREF="readline.html#IDX179">rl_completion_query_items</A>
3370 <LI><A HREF="readline.html#IDX109">rl_copy_keymap</A>
3371 <LI><A HREF="readline.html#IDX145">rl_copy_text</A>
3372 <LI><A HREF="readline.html#IDX144">rl_delete_text</A>
3373 <LI><A HREF="readline.html#IDX192">rl_directory_completion_hook</A>
3374 <LI><A HREF="readline.html#IDX111">rl_discard_keymap</A>
3375 <LI><A HREF="readline.html#IDX135">rl_do_undo</A>
3376 <LI><A HREF="readline.html#IDX93">rl_done</A>
3377 <LI><A HREF="readline.html#IDX91">rl_end</A>
3378 <LI><A HREF="readline.html#IDX132">rl_end_undo_group</A>
3379 <LI><A HREF="readline.html#IDX102">rl_event_hook</A>
3380 <LI><A HREF="readline.html#IDX105">rl_executing_keymap</A>
3381 <LI><A HREF="readline.html#IDX188">rl_filename_completion_desired</A>
3382 <LI><A HREF="readline.html#IDX177">rl_filename_dequoting_function</A>
3383 <LI><A HREF="readline.html#IDX184">rl_filename_quote_characters</A>
3384 <LI><A HREF="readline.html#IDX189">rl_filename_quoting_desired</A>
3385 <LI><A HREF="readline.html#IDX176">rl_filename_quoting_function</A>
3386 <LI><A HREF="readline.html#IDX138">rl_forced_update_display</A>
3387 <LI><A HREF="readline.html#IDX129">rl_function_dumper</A>
3388 <LI><A HREF="readline.html#IDX126">rl_function_of_keyseq</A>
3389 <LI><A HREF="readline.html#IDX122">rl_generic_bind</A>
3390 <LI><A HREF="readline.html#IDX112">rl_get_keymap</A>
3391 <LI><A HREF="readline.html#IDX114">rl_get_keymap_by_name</A>
3392 <LI><A HREF="readline.html#IDX115">rl_get_keymap_name</A>
3393 <LI><A HREF="readline.html#IDX148">rl_getc</A>
3394 <LI><A HREF="readline.html#IDX103">rl_getc_function</A>
3395 <LI><A HREF="readline.html#IDX187">rl_ignore_completion_duplicates</A>
3396 <LI><A HREF="readline.html#IDX191">rl_ignore_some_completions_function</A>
3397 <LI><A HREF="readline.html#IDX190">rl_inhibit_completion</A>
3398 <LI><A HREF="readline.html#IDX151">rl_initialize</A>
3399 <LI><A HREF="readline.html#IDX170">rl_insert_completions</A>
3400 <LI><A HREF="readline.html#IDX143">rl_insert_text</A>
3401 <LI><A HREF="readline.html#IDX99">rl_instream</A>
3402 <LI><A HREF="readline.html#IDX127">rl_invoking_keyseqs</A>
3403 <LI><A HREF="readline.html#IDX128">rl_invoking_keyseqs_in_map</A>
3404 <LI><A HREF="readline.html#IDX146">rl_kill_text</A>
3405 <LI><A HREF="readline.html#IDX96">rl_library_version</A>
3406 <LI><A HREF="readline.html#IDX89">rl_line_buffer</A>
3407 <LI><A HREF="readline.html#IDX130">rl_list_funmap_names</A>
3408 <LI><A HREF="readline.html#IDX108">rl_make_bare_keymap</A>
3409 <LI><A HREF="readline.html#IDX110">rl_make_keymap</A>
3410 <LI><A HREF="readline.html#IDX92">rl_mark</A>
3411 <LI><A HREF="readline.html#IDX141">rl_message</A>
3412 <LI><A HREF="readline.html#IDX136">rl_modifying</A>
3413 <LI><A HREF="readline.html#IDX125">rl_named_function</A>
3414 <LI><A HREF="readline.html#IDX139">rl_on_new_line</A>
3415 <LI><A HREF="readline.html#IDX100">rl_outstream</A>
3416 <LI><A HREF="readline.html#IDX123">rl_parse_and_bind</A>
3417 <LI><A HREF="readline.html#IDX94">rl_pending_input</A>
3418 <LI><A HREF="readline.html#IDX90">rl_point</A>
3419 <LI><A HREF="readline.html#IDX169">rl_possible_completions</A>
3420 <LI><A HREF="readline.html#IDX95">rl_prompt</A>
3421 <LI><A HREF="readline.html#IDX124">rl_read_init_file</A>
3422 <LI><A HREF="readline.html#IDX147">rl_read_key</A>
3423 <LI><A HREF="readline.html#IDX98">rl_readline_name</A>
3424 <LI><A HREF="readline.html#IDX137">rl_redisplay</A>
3425 <LI><A HREF="readline.html#IDX104">rl_redisplay_function</A>
3426 <LI><A HREF="readline.html#IDX140">rl_reset_line_state</A>
3427 <LI><A HREF="readline.html#IDX152">rl_reset_terminal</A>
3428 <LI><A HREF="readline.html#IDX113">rl_set_keymap</A>
3429 <LI><A HREF="readline.html#IDX185">rl_special_prefixes</A>
3430 <LI><A HREF="readline.html#IDX101">rl_startup_hook</A>
3431 <LI><A HREF="readline.html#IDX149">rl_stuff_char</A>
3432 <LI><A HREF="readline.html#IDX97">rl_terminal_name</A>
3433 <LI><A HREF="readline.html#IDX121">rl_unbind_command_in_map</A>
3434 <LI><A HREF="readline.html#IDX120">rl_unbind_function_in_map</A>
3435 <LI><A HREF="readline.html#IDX118">rl_unbind_key</A>
3436 <LI><A HREF="readline.html#IDX119">rl_unbind_key_in_map</A>
3437 </DIR>
3438 <H2>s</H2>
3439 <DIR>
3440 <LI><A HREF="readline.html#IDX43">self-insert (a, b, A, 1, !, ...)</A>
3441 <LI><A HREF="readline.html#IDX79">set-mark (C-@)</A>
3442 <LI><A HREF="readline.html#IDX16">show-all-if-ambiguous</A>
3443 <LI><A HREF="readline.html#IDX69">start-kbd-macro (C-x ()</A>
3444 </DIR>
3445 <H2>t</H2>
3446 <DIR>
3447 <LI><A HREF="readline.html#IDX42">tab-insert (M-TAB)</A>
3448 <LI><A HREF="readline.html#IDX78">tilde-expand (M-~)</A>
3449 <LI><A HREF="readline.html#IDX160">to_lower</A>
3450 <LI><A HREF="readline.html#IDX159">to_upper</A>
3451 <LI><A HREF="readline.html#IDX44">transpose-chars (C-t)</A>
3452 <LI><A HREF="readline.html#IDX45">transpose-words (M-t)</A>
3453 </DIR>
3454 <H2>u</H2>
3455 <DIR>
3456 <LI><A HREF="readline.html#IDX76">undo (C-_, C-x C-u)</A>
3457 <LI><A HREF="readline.html#IDX64">universal-argument ()</A>
3458 <LI><A HREF="readline.html#IDX51">unix-line-discard (C-u)</A>
3459 <LI><A HREF="readline.html#IDX55">unix-word-rubout (C-w)</A>
3460 <LI><A HREF="readline.html#IDX46">upcase-word (M-u)</A>
3461 <LI><A HREF="readline.html#IDX156">uppercase_p</A>
3462 <LI><A HREF="readline.html#IDX173">username_completion_function</A>
3463 </DIR>
3464 <H2>v</H2>
3465 <DIR>
3466 <LI><A HREF="readline.html#IDX17">visible-stats</A>
3467 </DIR>
3468 <H2>y</H2>
3469 <DIR>
3470 <LI><A HREF="readline.html#IDX61">yank (C-y)</A>
3471 <LI><A HREF="readline.html#IDX38">yank-last-arg (M-., M-_)</A>
3472 <LI><A HREF="readline.html#IDX37">yank-nth-arg (M-C-y)</A>
3473 <LI><A HREF="readline.html#IDX62">yank-pop (M-y)</A>
3474 </DIR>
3475
3476 </P>
3477 <P><HR><P>
3478 This document was generated on 2 April 1998 using the
3479 <A HREF="http://wwwcn.cern.ch/dci/texi2html/">texi2html</A>
3480 translator version 1.51.</P>
3481 </BODY>
3482 </HTML>