annotate man/mini.texi @ 28675:a4328cafed66

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Thu, 20 Apr 2000 23:50:19 +0000
parents 6f6d3c803dde
children e05819f22426
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1 @c This is part of the Emacs manual.
28129
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 2000
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
3 @c Free Software Foundation, Inc.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4 @c See file emacs.texi for copying conditions.
Dave Love <fx@gnu.org>
parents:
diff changeset
5 @node Minibuffer, M-x, Basic, Top
Dave Love <fx@gnu.org>
parents:
diff changeset
6 @chapter The Minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
7 @cindex minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
8
Dave Love <fx@gnu.org>
parents:
diff changeset
9 The @dfn{minibuffer} is the facility used by Emacs commands to read
Dave Love <fx@gnu.org>
parents:
diff changeset
10 arguments more complicated than a single number. Minibuffer arguments
Dave Love <fx@gnu.org>
parents:
diff changeset
11 can be file names, buffer names, Lisp function names, Emacs command
Dave Love <fx@gnu.org>
parents:
diff changeset
12 names, Lisp expressions, and many other things, depending on the command
Dave Love <fx@gnu.org>
parents:
diff changeset
13 reading the argument. You can use the usual Emacs editing commands in
Dave Love <fx@gnu.org>
parents:
diff changeset
14 the minibuffer to edit the argument text.
Dave Love <fx@gnu.org>
parents:
diff changeset
15
Dave Love <fx@gnu.org>
parents:
diff changeset
16 @cindex prompt
Dave Love <fx@gnu.org>
parents:
diff changeset
17 When the minibuffer is in use, it appears in the echo area, and the
Dave Love <fx@gnu.org>
parents:
diff changeset
18 terminal's cursor moves there. The beginning of the minibuffer line
Dave Love <fx@gnu.org>
parents:
diff changeset
19 displays a @dfn{prompt} which says what kind of input you should supply and
Dave Love <fx@gnu.org>
parents:
diff changeset
20 how it will be used. Often this prompt is derived from the name of the
Dave Love <fx@gnu.org>
parents:
diff changeset
21 command that the argument is for. The prompt normally ends with a colon.
Dave Love <fx@gnu.org>
parents:
diff changeset
22
Dave Love <fx@gnu.org>
parents:
diff changeset
23 @cindex default argument
Dave Love <fx@gnu.org>
parents:
diff changeset
24 Sometimes a @dfn{default argument} appears in parentheses after the
Dave Love <fx@gnu.org>
parents:
diff changeset
25 colon; it too is part of the prompt. The default will be used as the
Dave Love <fx@gnu.org>
parents:
diff changeset
26 argument value if you enter an empty argument (for example, just type
Dave Love <fx@gnu.org>
parents:
diff changeset
27 @key{RET}). For example, commands that read buffer names always show a
Dave Love <fx@gnu.org>
parents:
diff changeset
28 default, which is the name of the buffer that will be used if you type
Dave Love <fx@gnu.org>
parents:
diff changeset
29 just @key{RET}.
Dave Love <fx@gnu.org>
parents:
diff changeset
30
Dave Love <fx@gnu.org>
parents:
diff changeset
31 The simplest way to enter a minibuffer argument is to type the text
Dave Love <fx@gnu.org>
parents:
diff changeset
32 you want, terminated by @key{RET} which exits the minibuffer. You can
Dave Love <fx@gnu.org>
parents:
diff changeset
33 cancel the command that wants the argument, and get out of the
Dave Love <fx@gnu.org>
parents:
diff changeset
34 minibuffer, by typing @kbd{C-g}.
Dave Love <fx@gnu.org>
parents:
diff changeset
35
Dave Love <fx@gnu.org>
parents:
diff changeset
36 Since the minibuffer uses the screen space of the echo area, it can
Dave Love <fx@gnu.org>
parents:
diff changeset
37 conflict with other ways Emacs customarily uses the echo area. Here is how
Dave Love <fx@gnu.org>
parents:
diff changeset
38 Emacs handles such conflicts:
Dave Love <fx@gnu.org>
parents:
diff changeset
39
Dave Love <fx@gnu.org>
parents:
diff changeset
40 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
41 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
42 If a command gets an error while you are in the minibuffer, this does
Dave Love <fx@gnu.org>
parents:
diff changeset
43 not cancel the minibuffer. However, the echo area is needed for the
Dave Love <fx@gnu.org>
parents:
diff changeset
44 error message and therefore the minibuffer itself is hidden for a
Dave Love <fx@gnu.org>
parents:
diff changeset
45 while. It comes back after a few seconds, or as soon as you type
Dave Love <fx@gnu.org>
parents:
diff changeset
46 anything.
Dave Love <fx@gnu.org>
parents:
diff changeset
47
Dave Love <fx@gnu.org>
parents:
diff changeset
48 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
49 If in the minibuffer you use a command whose purpose is to print a
Dave Love <fx@gnu.org>
parents:
diff changeset
50 message in the echo area, such as @kbd{C-x =}, the message is printed
Dave Love <fx@gnu.org>
parents:
diff changeset
51 normally, and the minibuffer is hidden for a while. It comes back
Dave Love <fx@gnu.org>
parents:
diff changeset
52 after a few seconds, or as soon as you type anything.
Dave Love <fx@gnu.org>
parents:
diff changeset
53
Dave Love <fx@gnu.org>
parents:
diff changeset
54 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
55 Echoing of keystrokes does not take place while the minibuffer is in
Dave Love <fx@gnu.org>
parents:
diff changeset
56 use.
Dave Love <fx@gnu.org>
parents:
diff changeset
57 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
58
Dave Love <fx@gnu.org>
parents:
diff changeset
59 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
60 * File: Minibuffer File. Entering file names with the minibuffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
61 * Edit: Minibuffer Edit. How to edit in the minibuffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
62 * Completion:: An abbreviation facility for minibuffer input.
Dave Love <fx@gnu.org>
parents:
diff changeset
63 * Minibuffer History:: Reusing recent minibuffer arguments.
Dave Love <fx@gnu.org>
parents:
diff changeset
64 * Repetition:: Re-executing commands that used the minibuffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
65 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
66
Dave Love <fx@gnu.org>
parents:
diff changeset
67 @node Minibuffer File
Dave Love <fx@gnu.org>
parents:
diff changeset
68 @section Minibuffers for File Names
Dave Love <fx@gnu.org>
parents:
diff changeset
69
Dave Love <fx@gnu.org>
parents:
diff changeset
70 Sometimes the minibuffer starts out with text in it. For example, when
Dave Love <fx@gnu.org>
parents:
diff changeset
71 you are supposed to give a file name, the minibuffer starts out containing
Dave Love <fx@gnu.org>
parents:
diff changeset
72 the @dfn{default directory}, which ends with a slash. This is to inform
Dave Love <fx@gnu.org>
parents:
diff changeset
73 you which directory the file will be found in if you do not specify a
Dave Love <fx@gnu.org>
parents:
diff changeset
74 directory.
Dave Love <fx@gnu.org>
parents:
diff changeset
75
Dave Love <fx@gnu.org>
parents:
diff changeset
76 @c Separate paragraph to clean up ugly pagebreak--rms
Dave Love <fx@gnu.org>
parents:
diff changeset
77 @need 1500
Dave Love <fx@gnu.org>
parents:
diff changeset
78 For example, the minibuffer might start out with these contents:
Dave Love <fx@gnu.org>
parents:
diff changeset
79
Dave Love <fx@gnu.org>
parents:
diff changeset
80 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
81 Find File: /u2/emacs/src/
Dave Love <fx@gnu.org>
parents:
diff changeset
82 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
83
Dave Love <fx@gnu.org>
parents:
diff changeset
84 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
85 where @samp{Find File:@: } is the prompt. Typing @kbd{buffer.c}
Dave Love <fx@gnu.org>
parents:
diff changeset
86 specifies the file @file{/u2/emacs/src/buffer.c}. To find files in
Dave Love <fx@gnu.org>
parents:
diff changeset
87 nearby directories, use @kbd{..}; thus, if you type
Dave Love <fx@gnu.org>
parents:
diff changeset
88 @kbd{../lisp/simple.el}, you will get the file named
Dave Love <fx@gnu.org>
parents:
diff changeset
89 @file{/u2/emacs/lisp/simple.el}. Alternatively, you can kill with
Dave Love <fx@gnu.org>
parents:
diff changeset
90 @kbd{M-@key{DEL}} the directory names you don't want (@pxref{Words}).
Dave Love <fx@gnu.org>
parents:
diff changeset
91
Dave Love <fx@gnu.org>
parents:
diff changeset
92 If you don't want any of the default, you can kill it with @kbd{C-a
Dave Love <fx@gnu.org>
parents:
diff changeset
93 C-k}. But you don't need to kill the default; you can simply ignore it.
Dave Love <fx@gnu.org>
parents:
diff changeset
94 Insert an absolute file name, one starting with a slash or a tilde,
Dave Love <fx@gnu.org>
parents:
diff changeset
95 after the default directory. For example, to specify the file
Dave Love <fx@gnu.org>
parents:
diff changeset
96 @file{/etc/termcap}, just insert that name, giving these minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
97 contents:
Dave Love <fx@gnu.org>
parents:
diff changeset
98
Dave Love <fx@gnu.org>
parents:
diff changeset
99 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
100 Find File: /u2/emacs/src//etc/termcap
Dave Love <fx@gnu.org>
parents:
diff changeset
101 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
102
Dave Love <fx@gnu.org>
parents:
diff changeset
103 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
104 @cindex // in file name
Dave Love <fx@gnu.org>
parents:
diff changeset
105 @cindex double slash in file name
Dave Love <fx@gnu.org>
parents:
diff changeset
106 @cindex slashes repeated in file name
Dave Love <fx@gnu.org>
parents:
diff changeset
107 GNU Emacs gives a special meaning to a double slash (which is not
Dave Love <fx@gnu.org>
parents:
diff changeset
108 normally a useful thing to write): it means, ``ignore everything before
Dave Love <fx@gnu.org>
parents:
diff changeset
109 the second slash in the pair.'' Thus, @samp{/u2/emacs/src/} is ignored
Dave Love <fx@gnu.org>
parents:
diff changeset
110 in the example above, and you get the file @file{/etc/termcap}.
Dave Love <fx@gnu.org>
parents:
diff changeset
111
Dave Love <fx@gnu.org>
parents:
diff changeset
112 If you set @code{insert-default-directory} to @code{nil}, the default
Dave Love <fx@gnu.org>
parents:
diff changeset
113 directory is not inserted in the minibuffer. This way, the minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
114 starts out empty. But the name you type, if relative, is still
Dave Love <fx@gnu.org>
parents:
diff changeset
115 interpreted with respect to the same default directory.
Dave Love <fx@gnu.org>
parents:
diff changeset
116
Dave Love <fx@gnu.org>
parents:
diff changeset
117 @node Minibuffer Edit
Dave Love <fx@gnu.org>
parents:
diff changeset
118 @section Editing in the Minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
119
Dave Love <fx@gnu.org>
parents:
diff changeset
120 The minibuffer is an Emacs buffer (albeit a peculiar one), and the usual
Dave Love <fx@gnu.org>
parents:
diff changeset
121 Emacs commands are available for editing the text of an argument you are
Dave Love <fx@gnu.org>
parents:
diff changeset
122 entering.
Dave Love <fx@gnu.org>
parents:
diff changeset
123
Dave Love <fx@gnu.org>
parents:
diff changeset
124 Since @key{RET} in the minibuffer is defined to exit the minibuffer,
Dave Love <fx@gnu.org>
parents:
diff changeset
125 you can't use it to insert a newline in the minibuffer. To do that,
Dave Love <fx@gnu.org>
parents:
diff changeset
126 type @kbd{C-o} or @kbd{C-q C-j}. (Recall that a newline is really the
Dave Love <fx@gnu.org>
parents:
diff changeset
127 character control-J.)
Dave Love <fx@gnu.org>
parents:
diff changeset
128
Dave Love <fx@gnu.org>
parents:
diff changeset
129 The minibuffer has its own window which always has space on the screen
Dave Love <fx@gnu.org>
parents:
diff changeset
130 but acts as if it were not there when the minibuffer is not in use. When
Dave Love <fx@gnu.org>
parents:
diff changeset
131 the minibuffer is in use, its window is just like the others; you can
Dave Love <fx@gnu.org>
parents:
diff changeset
132 switch to another window with @kbd{C-x o}, edit text in other windows and
Dave Love <fx@gnu.org>
parents:
diff changeset
133 perhaps even visit more files, before returning to the minibuffer to submit
Dave Love <fx@gnu.org>
parents:
diff changeset
134 the argument. You can kill text in another window, return to the
Dave Love <fx@gnu.org>
parents:
diff changeset
135 minibuffer window, and then yank the text to use it in the argument.
Dave Love <fx@gnu.org>
parents:
diff changeset
136 @xref{Windows}.
Dave Love <fx@gnu.org>
parents:
diff changeset
137
Dave Love <fx@gnu.org>
parents:
diff changeset
138 @cindex height of minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
139 @cindex size of minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
140 @cindex growing minibuffer
27216
99ca9ac9c31a Minibuffer resizing now automatic.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
141 @cindex resizing minibuffer
99ca9ac9c31a Minibuffer resizing now automatic.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
142 @vindex max-mini-window-height
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
143 There are some restrictions on the use of the minibuffer window,
Dave Love <fx@gnu.org>
parents:
diff changeset
144 however. You cannot switch buffers in it---the minibuffer and its
Dave Love <fx@gnu.org>
parents:
diff changeset
145 window are permanently attached. Also, you cannot split or kill the
Dave Love <fx@gnu.org>
parents:
diff changeset
146 minibuffer window. But you can make it taller in the normal fashion
27216
99ca9ac9c31a Minibuffer resizing now automatic.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
147 with @kbd{C-x ^}. The minibuffer window expands vertically as necessary
99ca9ac9c31a Minibuffer resizing now automatic.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
148 to hold the text that you put in the minibuffer. Customize the variable
99ca9ac9c31a Minibuffer resizing now automatic.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
149 @code{max-mini-window-height} to control the maximum height for resizing
99ca9ac9c31a Minibuffer resizing now automatic.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
150 the minibuffer window.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
151
Dave Love <fx@gnu.org>
parents:
diff changeset
152 @vindex minibuffer-scroll-overlap
Dave Love <fx@gnu.org>
parents:
diff changeset
153 Scrolling works specially in the minibuffer window. When the
Dave Love <fx@gnu.org>
parents:
diff changeset
154 minibuffer is just one line high, and it contains a long line of text
Dave Love <fx@gnu.org>
parents:
diff changeset
155 that won't fit on the screen, scrolling automatically maintains an
Dave Love <fx@gnu.org>
parents:
diff changeset
156 overlap of a certain number of characters from one continuation line to
Dave Love <fx@gnu.org>
parents:
diff changeset
157 the next. The variable @code{minibuffer-scroll-overlap} specifies how
Dave Love <fx@gnu.org>
parents:
diff changeset
158 many characters of overlap; the default is 20.
Dave Love <fx@gnu.org>
parents:
diff changeset
159
Dave Love <fx@gnu.org>
parents:
diff changeset
160 If while in the minibuffer you issue a command that displays help text
Dave Love <fx@gnu.org>
parents:
diff changeset
161 of any sort in another window, you can use the @kbd{C-M-v} command while
Dave Love <fx@gnu.org>
parents:
diff changeset
162 in the minibuffer to scroll the help text. This lasts until you exit
Dave Love <fx@gnu.org>
parents:
diff changeset
163 the minibuffer. This feature is especially useful if a completing
Dave Love <fx@gnu.org>
parents:
diff changeset
164 minibuffer gives you a list of possible completions. @xref{Other Window}.
Dave Love <fx@gnu.org>
parents:
diff changeset
165
Dave Love <fx@gnu.org>
parents:
diff changeset
166 @vindex enable-recursive-minibuffers
Dave Love <fx@gnu.org>
parents:
diff changeset
167 Emacs normally disallows most commands that use the minibuffer while
Dave Love <fx@gnu.org>
parents:
diff changeset
168 the minibuffer is active. This rule is to prevent recursive minibuffers
Dave Love <fx@gnu.org>
parents:
diff changeset
169 from confusing novice users. If you want to be able to use such
Dave Love <fx@gnu.org>
parents:
diff changeset
170 commands in the minibuffer, set the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
171 @code{enable-recursive-minibuffers} to a non-@code{nil} value.
Dave Love <fx@gnu.org>
parents:
diff changeset
172
Dave Love <fx@gnu.org>
parents:
diff changeset
173 @node Completion
Dave Love <fx@gnu.org>
parents:
diff changeset
174 @section Completion
Dave Love <fx@gnu.org>
parents:
diff changeset
175 @cindex completion
Dave Love <fx@gnu.org>
parents:
diff changeset
176
Dave Love <fx@gnu.org>
parents:
diff changeset
177 For certain kinds of arguments, you can use @dfn{completion} to enter
Dave Love <fx@gnu.org>
parents:
diff changeset
178 the argument value. Completion means that you type part of the
Dave Love <fx@gnu.org>
parents:
diff changeset
179 argument, then Emacs visibly fills in the rest, or as much as
Dave Love <fx@gnu.org>
parents:
diff changeset
180 can be determined from the part you have typed.
Dave Love <fx@gnu.org>
parents:
diff changeset
181
Dave Love <fx@gnu.org>
parents:
diff changeset
182 When completion is available, certain keys---@key{TAB}, @key{RET}, and
Dave Love <fx@gnu.org>
parents:
diff changeset
183 @key{SPC}---are rebound to complete the text present in the minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
184 into a longer string that it stands for, by matching it against a set of
Dave Love <fx@gnu.org>
parents:
diff changeset
185 @dfn{completion alternatives} provided by the command reading the
Dave Love <fx@gnu.org>
parents:
diff changeset
186 argument. @kbd{?} is defined to display a list of possible completions
Dave Love <fx@gnu.org>
parents:
diff changeset
187 of what you have inserted.
Dave Love <fx@gnu.org>
parents:
diff changeset
188
Dave Love <fx@gnu.org>
parents:
diff changeset
189 For example, when @kbd{M-x} uses the minibuffer to read the name of a
Dave Love <fx@gnu.org>
parents:
diff changeset
190 command, it provides a list of all available Emacs command names to
Dave Love <fx@gnu.org>
parents:
diff changeset
191 complete against. The completion keys match the text in the minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
192 against all the command names, find any additional name characters
Dave Love <fx@gnu.org>
parents:
diff changeset
193 implied by the ones already present in the minibuffer, and add those
Dave Love <fx@gnu.org>
parents:
diff changeset
194 characters to the ones you have given. This is what makes it possible
Dave Love <fx@gnu.org>
parents:
diff changeset
195 to type @kbd{M-x ins @key{SPC} b @key{RET}} instead of @kbd{M-x
Dave Love <fx@gnu.org>
parents:
diff changeset
196 insert-buffer @key{RET}} (for example).
Dave Love <fx@gnu.org>
parents:
diff changeset
197
Dave Love <fx@gnu.org>
parents:
diff changeset
198 Case is normally significant in completion, because it is significant
Dave Love <fx@gnu.org>
parents:
diff changeset
199 in most of the names that you can complete (buffer names, file names and
Dave Love <fx@gnu.org>
parents:
diff changeset
200 command names). Thus, @samp{fo} does not complete to @samp{Foo}.
Dave Love <fx@gnu.org>
parents:
diff changeset
201 Completion does ignore case distinctions for certain arguments in which
Dave Love <fx@gnu.org>
parents:
diff changeset
202 case does not matter.
Dave Love <fx@gnu.org>
parents:
diff changeset
203
Dave Love <fx@gnu.org>
parents:
diff changeset
204 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
205 * Example: Completion Example.
Dave Love <fx@gnu.org>
parents:
diff changeset
206 * Commands: Completion Commands.
Dave Love <fx@gnu.org>
parents:
diff changeset
207 * Strict Completion::
Dave Love <fx@gnu.org>
parents:
diff changeset
208 * Options: Completion Options.
Dave Love <fx@gnu.org>
parents:
diff changeset
209 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
210
Dave Love <fx@gnu.org>
parents:
diff changeset
211 @node Completion Example
Dave Love <fx@gnu.org>
parents:
diff changeset
212 @subsection Completion Example
Dave Love <fx@gnu.org>
parents:
diff changeset
213
Dave Love <fx@gnu.org>
parents:
diff changeset
214 @kindex TAB @r{(completion)}
Dave Love <fx@gnu.org>
parents:
diff changeset
215 @findex minibuffer-complete
Dave Love <fx@gnu.org>
parents:
diff changeset
216 A concrete example may help here. If you type @kbd{M-x au @key{TAB}},
Dave Love <fx@gnu.org>
parents:
diff changeset
217 the @key{TAB} looks for alternatives (in this case, command names) that
Dave Love <fx@gnu.org>
parents:
diff changeset
218 start with @samp{au}. There are several, including
Dave Love <fx@gnu.org>
parents:
diff changeset
219 @code{auto-fill-mode} and @code{auto-save-mode}---but they are all the
Dave Love <fx@gnu.org>
parents:
diff changeset
220 same as far as @code{auto-}, so the @samp{au} in the minibuffer changes
Dave Love <fx@gnu.org>
parents:
diff changeset
221 to @samp{auto-}.@refill
Dave Love <fx@gnu.org>
parents:
diff changeset
222
Dave Love <fx@gnu.org>
parents:
diff changeset
223 If you type @key{TAB} again immediately, there are multiple
Dave Love <fx@gnu.org>
parents:
diff changeset
224 possibilities for the very next character---it could be any of
Dave Love <fx@gnu.org>
parents:
diff changeset
225 @samp{cfilrs}---so no more characters are added; instead, @key{TAB}
Dave Love <fx@gnu.org>
parents:
diff changeset
226 displays a list of all possible completions in another window.
Dave Love <fx@gnu.org>
parents:
diff changeset
227
Dave Love <fx@gnu.org>
parents:
diff changeset
228 If you go on to type @kbd{f @key{TAB}}, this @key{TAB} sees
Dave Love <fx@gnu.org>
parents:
diff changeset
229 @samp{auto-f}. The only command name starting this way is
Dave Love <fx@gnu.org>
parents:
diff changeset
230 @code{auto-fill-mode}, so completion fills in the rest of that. You now
Dave Love <fx@gnu.org>
parents:
diff changeset
231 have @samp{auto-fill-mode} in the minibuffer after typing just @kbd{au
Dave Love <fx@gnu.org>
parents:
diff changeset
232 @key{TAB} f @key{TAB}}. Note that @key{TAB} has this effect because in
Dave Love <fx@gnu.org>
parents:
diff changeset
233 the minibuffer it is bound to the command @code{minibuffer-complete}
Dave Love <fx@gnu.org>
parents:
diff changeset
234 when completion is available.
Dave Love <fx@gnu.org>
parents:
diff changeset
235
Dave Love <fx@gnu.org>
parents:
diff changeset
236 @node Completion Commands
Dave Love <fx@gnu.org>
parents:
diff changeset
237 @subsection Completion Commands
Dave Love <fx@gnu.org>
parents:
diff changeset
238
Dave Love <fx@gnu.org>
parents:
diff changeset
239 Here is a list of the completion commands defined in the minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
240 when completion is available.
Dave Love <fx@gnu.org>
parents:
diff changeset
241
Dave Love <fx@gnu.org>
parents:
diff changeset
242 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
243 @item @key{TAB}
Dave Love <fx@gnu.org>
parents:
diff changeset
244 Complete the text in the minibuffer as much as possible
Dave Love <fx@gnu.org>
parents:
diff changeset
245 (@code{minibuffer-complete}).
Dave Love <fx@gnu.org>
parents:
diff changeset
246 @item @key{SPC}
Dave Love <fx@gnu.org>
parents:
diff changeset
247 Complete the minibuffer text, but don't go beyond one word
Dave Love <fx@gnu.org>
parents:
diff changeset
248 (@code{minibuffer-complete-word}).
Dave Love <fx@gnu.org>
parents:
diff changeset
249 @item @key{RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
250 Submit the text in the minibuffer as the argument, possibly completing
Dave Love <fx@gnu.org>
parents:
diff changeset
251 first as described below (@code{minibuffer-complete-and-exit}).
Dave Love <fx@gnu.org>
parents:
diff changeset
252 @item ?
Dave Love <fx@gnu.org>
parents:
diff changeset
253 Print a list of all possible completions of the text in the minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
254 (@code{minibuffer-list-completions}).
Dave Love <fx@gnu.org>
parents:
diff changeset
255 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
256
Dave Love <fx@gnu.org>
parents:
diff changeset
257 @kindex SPC
Dave Love <fx@gnu.org>
parents:
diff changeset
258 @findex minibuffer-complete-word
Dave Love <fx@gnu.org>
parents:
diff changeset
259 @key{SPC} completes much like @key{TAB}, but never goes beyond the
Dave Love <fx@gnu.org>
parents:
diff changeset
260 next hyphen or space. If you have @samp{auto-f} in the minibuffer and
Dave Love <fx@gnu.org>
parents:
diff changeset
261 type @key{SPC}, it finds that the completion is @samp{auto-fill-mode},
Dave Love <fx@gnu.org>
parents:
diff changeset
262 but it stops completing after @samp{fill-}. This gives
Dave Love <fx@gnu.org>
parents:
diff changeset
263 @samp{auto-fill-}. Another @key{SPC} at this point completes all the
Dave Love <fx@gnu.org>
parents:
diff changeset
264 way to @samp{auto-fill-mode}. @key{SPC} in the minibuffer when
Dave Love <fx@gnu.org>
parents:
diff changeset
265 completion is available runs the command
Dave Love <fx@gnu.org>
parents:
diff changeset
266 @code{minibuffer-complete-word}.
Dave Love <fx@gnu.org>
parents:
diff changeset
267
Dave Love <fx@gnu.org>
parents:
diff changeset
268 Here are some commands you can use to choose a completion from a
Dave Love <fx@gnu.org>
parents:
diff changeset
269 window that displays a list of completions:
Dave Love <fx@gnu.org>
parents:
diff changeset
270
Dave Love <fx@gnu.org>
parents:
diff changeset
271 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
272 @findex mouse-choose-completion
Dave Love <fx@gnu.org>
parents:
diff changeset
273 @item Mouse-2
Dave Love <fx@gnu.org>
parents:
diff changeset
274 Clicking mouse button 2 on a completion in the list of possible
Dave Love <fx@gnu.org>
parents:
diff changeset
275 completions chooses that completion (@code{mouse-choose-completion}).
Dave Love <fx@gnu.org>
parents:
diff changeset
276 You normally use this command while point is in the minibuffer; but you
Dave Love <fx@gnu.org>
parents:
diff changeset
277 must click in the list of completions, not in the minibuffer itself.
Dave Love <fx@gnu.org>
parents:
diff changeset
278
Dave Love <fx@gnu.org>
parents:
diff changeset
279 @findex switch-to-completions
Dave Love <fx@gnu.org>
parents:
diff changeset
280 @item @key{PRIOR}
Dave Love <fx@gnu.org>
parents:
diff changeset
281 @itemx M-v
Dave Love <fx@gnu.org>
parents:
diff changeset
282 Typing @key{PRIOR} or @key{PAGE-UP}, or @kbd{M-v}, while in the
Dave Love <fx@gnu.org>
parents:
diff changeset
283 minibuffer, selects the window showing the completion list buffer
Dave Love <fx@gnu.org>
parents:
diff changeset
284 (@code{switch-to-completions}). This paves the way for using the
Dave Love <fx@gnu.org>
parents:
diff changeset
285 commands below. (Selecting that window in the usual ways has the same
Dave Love <fx@gnu.org>
parents:
diff changeset
286 effect, but this way is more convenient.)
Dave Love <fx@gnu.org>
parents:
diff changeset
287
Dave Love <fx@gnu.org>
parents:
diff changeset
288 @findex choose-completion
Dave Love <fx@gnu.org>
parents:
diff changeset
289 @item @key{RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
290 Typing @key{RET} @emph{in the completion list buffer} chooses the
Dave Love <fx@gnu.org>
parents:
diff changeset
291 completion that point is in or next to (@code{choose-completion}). To
Dave Love <fx@gnu.org>
parents:
diff changeset
292 use this command, you must first switch windows to the window that shows
Dave Love <fx@gnu.org>
parents:
diff changeset
293 the list of completions.
Dave Love <fx@gnu.org>
parents:
diff changeset
294
Dave Love <fx@gnu.org>
parents:
diff changeset
295 @findex next-completion
Dave Love <fx@gnu.org>
parents:
diff changeset
296 @item @key{RIGHT}
Dave Love <fx@gnu.org>
parents:
diff changeset
297 Typing the right-arrow key @key{RIGHT} @emph{in the completion list
Dave Love <fx@gnu.org>
parents:
diff changeset
298 buffer} moves point to the following completion (@code{next-completion}).
Dave Love <fx@gnu.org>
parents:
diff changeset
299
Dave Love <fx@gnu.org>
parents:
diff changeset
300 @findex previous-completion
Dave Love <fx@gnu.org>
parents:
diff changeset
301 @item @key{LEFT}
Dave Love <fx@gnu.org>
parents:
diff changeset
302 Typing the left-arrow key @key{LEFT} @emph{in the completion list
Dave Love <fx@gnu.org>
parents:
diff changeset
303 buffer} moves point toward the beginning of the buffer, to the previous
Dave Love <fx@gnu.org>
parents:
diff changeset
304 completion (@code{previous-completion}).
Dave Love <fx@gnu.org>
parents:
diff changeset
305 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
306
Dave Love <fx@gnu.org>
parents:
diff changeset
307 @node Strict Completion
Dave Love <fx@gnu.org>
parents:
diff changeset
308 @subsection Strict Completion
Dave Love <fx@gnu.org>
parents:
diff changeset
309
Dave Love <fx@gnu.org>
parents:
diff changeset
310 There are three different ways that @key{RET} can work in completing
Dave Love <fx@gnu.org>
parents:
diff changeset
311 minibuffers, depending on how the argument will be used.
Dave Love <fx@gnu.org>
parents:
diff changeset
312
Dave Love <fx@gnu.org>
parents:
diff changeset
313 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
314 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
315 @dfn{Strict} completion is used when it is meaningless to give any
Dave Love <fx@gnu.org>
parents:
diff changeset
316 argument except one of the known alternatives. For example, when
Dave Love <fx@gnu.org>
parents:
diff changeset
317 @kbd{C-x k} reads the name of a buffer to kill, it is meaningless to
Dave Love <fx@gnu.org>
parents:
diff changeset
318 give anything but the name of an existing buffer. In strict
Dave Love <fx@gnu.org>
parents:
diff changeset
319 completion, @key{RET} refuses to exit if the text in the minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
320 does not complete to an exact match.
Dave Love <fx@gnu.org>
parents:
diff changeset
321
Dave Love <fx@gnu.org>
parents:
diff changeset
322 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
323 @dfn{Cautious} completion is similar to strict completion, except that
Dave Love <fx@gnu.org>
parents:
diff changeset
324 @key{RET} exits only if the text was an exact match already, not
Dave Love <fx@gnu.org>
parents:
diff changeset
325 needing completion. If the text is not an exact match, @key{RET} does
Dave Love <fx@gnu.org>
parents:
diff changeset
326 not exit, but it does complete the text. If it completes to an exact
Dave Love <fx@gnu.org>
parents:
diff changeset
327 match, a second @key{RET} will exit.
Dave Love <fx@gnu.org>
parents:
diff changeset
328
Dave Love <fx@gnu.org>
parents:
diff changeset
329 Cautious completion is used for reading file names for files that must
Dave Love <fx@gnu.org>
parents:
diff changeset
330 already exist.
Dave Love <fx@gnu.org>
parents:
diff changeset
331
Dave Love <fx@gnu.org>
parents:
diff changeset
332 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
333 @dfn{Permissive} completion is used when any string whatever is
Dave Love <fx@gnu.org>
parents:
diff changeset
334 meaningful, and the list of completion alternatives is just a guide.
Dave Love <fx@gnu.org>
parents:
diff changeset
335 For example, when @kbd{C-x C-f} reads the name of a file to visit, any
Dave Love <fx@gnu.org>
parents:
diff changeset
336 file name is allowed, in case you want to create a file. In
Dave Love <fx@gnu.org>
parents:
diff changeset
337 permissive completion, @key{RET} takes the text in the minibuffer
Dave Love <fx@gnu.org>
parents:
diff changeset
338 exactly as given, without completing it.
Dave Love <fx@gnu.org>
parents:
diff changeset
339 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
340
Dave Love <fx@gnu.org>
parents:
diff changeset
341 The completion commands display a list of all possible completions in
Dave Love <fx@gnu.org>
parents:
diff changeset
342 a window whenever there is more than one possibility for the very next
Dave Love <fx@gnu.org>
parents:
diff changeset
343 character. Also, typing @kbd{?} explicitly requests such a list. If
Dave Love <fx@gnu.org>
parents:
diff changeset
344 the list of completions is long, you can scroll it with @kbd{C-M-v}
Dave Love <fx@gnu.org>
parents:
diff changeset
345 (@pxref{Other Window}).
Dave Love <fx@gnu.org>
parents:
diff changeset
346
Dave Love <fx@gnu.org>
parents:
diff changeset
347 @node Completion Options
Dave Love <fx@gnu.org>
parents:
diff changeset
348 @subsection Completion Options
Dave Love <fx@gnu.org>
parents:
diff changeset
349
Dave Love <fx@gnu.org>
parents:
diff changeset
350 @vindex completion-ignored-extensions
Dave Love <fx@gnu.org>
parents:
diff changeset
351 When completion is done on file names, certain file names are usually
Dave Love <fx@gnu.org>
parents:
diff changeset
352 ignored. The variable @code{completion-ignored-extensions} contains a
Dave Love <fx@gnu.org>
parents:
diff changeset
353 list of strings; a file whose name ends in any of those strings is
Dave Love <fx@gnu.org>
parents:
diff changeset
354 ignored as a possible completion. The standard value of this variable
Dave Love <fx@gnu.org>
parents:
diff changeset
355 has several elements including @code{".o"}, @code{".elc"}, @code{".dvi"}
Dave Love <fx@gnu.org>
parents:
diff changeset
356 and @code{"~"}. The effect is that, for example, @samp{foo} can
Dave Love <fx@gnu.org>
parents:
diff changeset
357 complete to @samp{foo.c} even though @samp{foo.o} exists as well.
Dave Love <fx@gnu.org>
parents:
diff changeset
358 However, if @emph{all} the possible completions end in ``ignored''
Dave Love <fx@gnu.org>
parents:
diff changeset
359 strings, then they are not ignored. Ignored extensions do not apply to
Dave Love <fx@gnu.org>
parents:
diff changeset
360 lists of completions---those always mention all possible completions.
Dave Love <fx@gnu.org>
parents:
diff changeset
361
Dave Love <fx@gnu.org>
parents:
diff changeset
362 @vindex completion-auto-help
Dave Love <fx@gnu.org>
parents:
diff changeset
363 Normally, a completion command that finds the next character is undetermined
Dave Love <fx@gnu.org>
parents:
diff changeset
364 automatically displays a list of all possible completions. If the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
365 @code{completion-auto-help} is set to @code{nil}, this does not happen,
Dave Love <fx@gnu.org>
parents:
diff changeset
366 and you must type @kbd{?} to display the possible completions.
Dave Love <fx@gnu.org>
parents:
diff changeset
367
Dave Love <fx@gnu.org>
parents:
diff changeset
368 @pindex complete
28129
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
369 @cindex Partial Completion mode
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
370 @vindex partial-completion-mode
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
371 @findex partial-completion-mode
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
372 @vindex PC-include-file-path
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
373 @vindex PC-disable-includes
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
374 The @code{complete} library implements a more powerful kind of
Dave Love <fx@gnu.org>
parents:
diff changeset
375 completion that can complete multiple words at a time. For example, it
Dave Love <fx@gnu.org>
parents:
diff changeset
376 can complete the command name abbreviation @code{p-b} into
Dave Love <fx@gnu.org>
parents:
diff changeset
377 @code{print-buffer}, because no other command starts with two words
28129
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
378 whose initials are @samp{p} and @samp{b}. To enable this, use the
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
379 command @kbd{M-x partial-completion-mode} or customize the option
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
380 @code{partial-completion-mode}. Unless the option
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
381 @code{PC-disable-includes} is @code{t}, Partial Completion mode also
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
382 extends @kbd{M-x find-file} so that the @samp{<@dots{}>} sequence is
28670
6f6d3c803dde Directory partial completion.
Dave Love <fx@gnu.org>
parents: 28129
diff changeset
383 interpreted as a file on the path @code{PC-include-file-path} and
6f6d3c803dde Directory partial completion.
Dave Love <fx@gnu.org>
parents: 28129
diff changeset
384 partial completion of file names is possible. Partial completion of
6f6d3c803dde Directory partial completion.
Dave Love <fx@gnu.org>
parents: 28129
diff changeset
385 directories in file names requires @samp{*}s to indicate the
6f6d3c803dde Directory partial completion.
Dave Love <fx@gnu.org>
parents: 28129
diff changeset
386 completions: @file{/u*/b*/f*} might expand to @file{/usr/bin/foo}. When
6f6d3c803dde Directory partial completion.
Dave Love <fx@gnu.org>
parents: 28129
diff changeset
387 Partial Completion mode is active, the Meta versions of the @kbd{TAB},
6f6d3c803dde Directory partial completion.
Dave Love <fx@gnu.org>
parents: 28129
diff changeset
388 @kbd{SPC}, @kbd{RET} and @kbd{?} keys act as those keys do by default
6f6d3c803dde Directory partial completion.
Dave Love <fx@gnu.org>
parents: 28129
diff changeset
389 for completion.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
390
Dave Love <fx@gnu.org>
parents:
diff changeset
391 @cindex Icomplete mode
28129
25e19c5c91f8 More on partial completion.
Dave Love <fx@gnu.org>
parents: 27216
diff changeset
392 @findex icomplete-mode
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
393 Icomplete mode presents a constantly-updated display that tells you
Dave Love <fx@gnu.org>
parents:
diff changeset
394 what completions are available for the text you've entered so far. The
Dave Love <fx@gnu.org>
parents:
diff changeset
395 command to enable or disable this minor mode is @kbd{M-x
Dave Love <fx@gnu.org>
parents:
diff changeset
396 icomplete-mode}.
Dave Love <fx@gnu.org>
parents:
diff changeset
397
Dave Love <fx@gnu.org>
parents:
diff changeset
398 @node Minibuffer History
Dave Love <fx@gnu.org>
parents:
diff changeset
399 @section Minibuffer History
Dave Love <fx@gnu.org>
parents:
diff changeset
400 @cindex minibuffer history
Dave Love <fx@gnu.org>
parents:
diff changeset
401 @cindex history of minibuffer input
Dave Love <fx@gnu.org>
parents:
diff changeset
402
Dave Love <fx@gnu.org>
parents:
diff changeset
403 Every argument that you enter with the minibuffer is saved on a
Dave Love <fx@gnu.org>
parents:
diff changeset
404 @dfn{minibuffer history list} so that you can use it again later in
Dave Love <fx@gnu.org>
parents:
diff changeset
405 another argument. Special commands load the text of an earlier argument
Dave Love <fx@gnu.org>
parents:
diff changeset
406 in the minibuffer. They discard the old minibuffer contents, so you can
Dave Love <fx@gnu.org>
parents:
diff changeset
407 think of them as moving through the history of previous arguments.
Dave Love <fx@gnu.org>
parents:
diff changeset
408
Dave Love <fx@gnu.org>
parents:
diff changeset
409 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
410 @item @key{UP}
Dave Love <fx@gnu.org>
parents:
diff changeset
411 @itemx M-p
Dave Love <fx@gnu.org>
parents:
diff changeset
412 Move to the next earlier argument string saved in the minibuffer history
Dave Love <fx@gnu.org>
parents:
diff changeset
413 (@code{previous-history-element}).
Dave Love <fx@gnu.org>
parents:
diff changeset
414 @item @key{DOWN}
Dave Love <fx@gnu.org>
parents:
diff changeset
415 @itemx M-n
Dave Love <fx@gnu.org>
parents:
diff changeset
416 Move to the next later argument string saved in the minibuffer history
Dave Love <fx@gnu.org>
parents:
diff changeset
417 (@code{next-history-element}).
Dave Love <fx@gnu.org>
parents:
diff changeset
418 @item M-r @var{regexp} @key{RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
419 Move to an earlier saved argument in the minibuffer history that has a
Dave Love <fx@gnu.org>
parents:
diff changeset
420 match for @var{regexp} (@code{previous-matching-history-element}).
Dave Love <fx@gnu.org>
parents:
diff changeset
421 @item M-s @var{regexp} @key{RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
422 Move to a later saved argument in the minibuffer history that has a
Dave Love <fx@gnu.org>
parents:
diff changeset
423 match for @var{regexp} (@code{next-matching-history-element}).
Dave Love <fx@gnu.org>
parents:
diff changeset
424 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
425
Dave Love <fx@gnu.org>
parents:
diff changeset
426 @kindex M-p @r{(minibuffer history)}
Dave Love <fx@gnu.org>
parents:
diff changeset
427 @kindex M-n @r{(minibuffer history)}
Dave Love <fx@gnu.org>
parents:
diff changeset
428 @findex next-history-element
Dave Love <fx@gnu.org>
parents:
diff changeset
429 @findex previous-history-element
Dave Love <fx@gnu.org>
parents:
diff changeset
430 The simplest way to reuse the saved arguments in the history list is
Dave Love <fx@gnu.org>
parents:
diff changeset
431 to move through the history list one element at a time. While in the
Dave Love <fx@gnu.org>
parents:
diff changeset
432 minibuffer, use @kbd{M-p} or up-arrow (@code{previous-history-element})
Dave Love <fx@gnu.org>
parents:
diff changeset
433 to ``move to'' the next earlier minibuffer input, and use @kbd{M-n} or
Dave Love <fx@gnu.org>
parents:
diff changeset
434 down-arrow (@code{next-history-element}) to ``move to'' the next later
Dave Love <fx@gnu.org>
parents:
diff changeset
435 input.
Dave Love <fx@gnu.org>
parents:
diff changeset
436
Dave Love <fx@gnu.org>
parents:
diff changeset
437 The previous input that you fetch from the history entirely replaces
Dave Love <fx@gnu.org>
parents:
diff changeset
438 the contents of the minibuffer. To use it as the argument, exit the
Dave Love <fx@gnu.org>
parents:
diff changeset
439 minibuffer as usual with @key{RET}. You can also edit the text before
Dave Love <fx@gnu.org>
parents:
diff changeset
440 you reuse it; this does not change the history element that you
Dave Love <fx@gnu.org>
parents:
diff changeset
441 ``moved'' to, but your new argument does go at the end of the history
Dave Love <fx@gnu.org>
parents:
diff changeset
442 list in its own right.
Dave Love <fx@gnu.org>
parents:
diff changeset
443
Dave Love <fx@gnu.org>
parents:
diff changeset
444 For many minibuffer arguments there is a ``default'' value. In some
Dave Love <fx@gnu.org>
parents:
diff changeset
445 cases, the minibuffer history commands know the default value. Then you
Dave Love <fx@gnu.org>
parents:
diff changeset
446 can insert the default value into the minibuffer as text by using
Dave Love <fx@gnu.org>
parents:
diff changeset
447 @kbd{M-n} to move ``into the future'' in the history. Eventually we
Dave Love <fx@gnu.org>
parents:
diff changeset
448 hope to make this feature available whenever the minibuffer has a
Dave Love <fx@gnu.org>
parents:
diff changeset
449 default value.
Dave Love <fx@gnu.org>
parents:
diff changeset
450
Dave Love <fx@gnu.org>
parents:
diff changeset
451 @findex previous-matching-history-element
Dave Love <fx@gnu.org>
parents:
diff changeset
452 @findex next-matching-history-element
Dave Love <fx@gnu.org>
parents:
diff changeset
453 @kindex M-r @r{(minibuffer history)}
Dave Love <fx@gnu.org>
parents:
diff changeset
454 @kindex M-s @r{(minibuffer history)}
Dave Love <fx@gnu.org>
parents:
diff changeset
455 There are also commands to search forward or backward through the
Dave Love <fx@gnu.org>
parents:
diff changeset
456 history; they search for history elements that match a regular
Dave Love <fx@gnu.org>
parents:
diff changeset
457 expression that you specify with the minibuffer. @kbd{M-r}
Dave Love <fx@gnu.org>
parents:
diff changeset
458 (@code{previous-matching-history-element}) searches older elements in
Dave Love <fx@gnu.org>
parents:
diff changeset
459 the history, while @kbd{M-s} (@code{next-matching-history-element})
Dave Love <fx@gnu.org>
parents:
diff changeset
460 searches newer elements. By special dispensation, these commands can
Dave Love <fx@gnu.org>
parents:
diff changeset
461 use the minibuffer to read their arguments even though you are already
Dave Love <fx@gnu.org>
parents:
diff changeset
462 in the minibuffer when you issue them. As with incremental searching,
Dave Love <fx@gnu.org>
parents:
diff changeset
463 an uppercase letter in the regular expression makes the search
Dave Love <fx@gnu.org>
parents:
diff changeset
464 case-sensitive (@pxref{Search Case}).
Dave Love <fx@gnu.org>
parents:
diff changeset
465
Dave Love <fx@gnu.org>
parents:
diff changeset
466 @ignore
Dave Love <fx@gnu.org>
parents:
diff changeset
467 We may change the precise way these commands read their arguments.
Dave Love <fx@gnu.org>
parents:
diff changeset
468 Perhaps they will search for a match for the string given so far in the
Dave Love <fx@gnu.org>
parents:
diff changeset
469 minibuffer; perhaps they will search for a literal match rather than a
Dave Love <fx@gnu.org>
parents:
diff changeset
470 regular expression match; perhaps they will only accept matches at the
Dave Love <fx@gnu.org>
parents:
diff changeset
471 beginning of a history element; perhaps they will read the string to
Dave Love <fx@gnu.org>
parents:
diff changeset
472 search for incrementally like @kbd{C-s}. To find out what interface is
Dave Love <fx@gnu.org>
parents:
diff changeset
473 actually available, type @kbd{C-h f previous-matching-history-element}.
Dave Love <fx@gnu.org>
parents:
diff changeset
474 @end ignore
Dave Love <fx@gnu.org>
parents:
diff changeset
475
Dave Love <fx@gnu.org>
parents:
diff changeset
476 All uses of the minibuffer record your input on a history list, but
Dave Love <fx@gnu.org>
parents:
diff changeset
477 there are separate history lists for different kinds of arguments. For
Dave Love <fx@gnu.org>
parents:
diff changeset
478 example, there is a list for file names, used by all the commands that
Dave Love <fx@gnu.org>
parents:
diff changeset
479 read file names. (As a special feature, this history list records
Dave Love <fx@gnu.org>
parents:
diff changeset
480 the absolute file name, no more and no less, even if that is not how
Dave Love <fx@gnu.org>
parents:
diff changeset
481 you entered the file name.)
Dave Love <fx@gnu.org>
parents:
diff changeset
482
Dave Love <fx@gnu.org>
parents:
diff changeset
483 There are several other very specific history lists, including one for
Dave Love <fx@gnu.org>
parents:
diff changeset
484 command names read by @kbd{M-x}, one for buffer names, one for arguments
Dave Love <fx@gnu.org>
parents:
diff changeset
485 of commands like @code{query-replace}, and one for compilation commands
Dave Love <fx@gnu.org>
parents:
diff changeset
486 read by @code{compile}. Finally, there is one ``miscellaneous'' history
Dave Love <fx@gnu.org>
parents:
diff changeset
487 list that most minibuffer arguments use.
Dave Love <fx@gnu.org>
parents:
diff changeset
488
Dave Love <fx@gnu.org>
parents:
diff changeset
489 @vindex history-length
Dave Love <fx@gnu.org>
parents:
diff changeset
490 The variable @code{history-length} specifies the maximum length of a
Dave Love <fx@gnu.org>
parents:
diff changeset
491 minibuffer history list; once a list gets that long, the oldest element
Dave Love <fx@gnu.org>
parents:
diff changeset
492 is deleted each time an element is added. If the value of
Dave Love <fx@gnu.org>
parents:
diff changeset
493 @code{history-length} is @code{t}, though, there is no maximum length
Dave Love <fx@gnu.org>
parents:
diff changeset
494 and elements are never deleted.
Dave Love <fx@gnu.org>
parents:
diff changeset
495
Dave Love <fx@gnu.org>
parents:
diff changeset
496 @node Repetition
Dave Love <fx@gnu.org>
parents:
diff changeset
497 @section Repeating Minibuffer Commands
Dave Love <fx@gnu.org>
parents:
diff changeset
498 @cindex command history
Dave Love <fx@gnu.org>
parents:
diff changeset
499 @cindex history of commands
Dave Love <fx@gnu.org>
parents:
diff changeset
500
Dave Love <fx@gnu.org>
parents:
diff changeset
501 Every command that uses the minibuffer at least once is recorded on a
Dave Love <fx@gnu.org>
parents:
diff changeset
502 special history list, together with the values of its arguments, so that
Dave Love <fx@gnu.org>
parents:
diff changeset
503 you can repeat the entire command. In particular, every use of
Dave Love <fx@gnu.org>
parents:
diff changeset
504 @kbd{M-x} is recorded there, since @kbd{M-x} uses the minibuffer to read
Dave Love <fx@gnu.org>
parents:
diff changeset
505 the command name.
Dave Love <fx@gnu.org>
parents:
diff changeset
506
Dave Love <fx@gnu.org>
parents:
diff changeset
507 @findex list-command-history
Dave Love <fx@gnu.org>
parents:
diff changeset
508 @c widecommands
Dave Love <fx@gnu.org>
parents:
diff changeset
509 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
510 @item C-x @key{ESC} @key{ESC}
Dave Love <fx@gnu.org>
parents:
diff changeset
511 Re-execute a recent minibuffer command (@code{repeat-complex-command}).
Dave Love <fx@gnu.org>
parents:
diff changeset
512 @item M-x list-command-history
Dave Love <fx@gnu.org>
parents:
diff changeset
513 Display the entire command history, showing all the commands
Dave Love <fx@gnu.org>
parents:
diff changeset
514 @kbd{C-x @key{ESC} @key{ESC}} can repeat, most recent first.
Dave Love <fx@gnu.org>
parents:
diff changeset
515 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
516
Dave Love <fx@gnu.org>
parents:
diff changeset
517 @kindex C-x ESC ESC
Dave Love <fx@gnu.org>
parents:
diff changeset
518 @findex repeat-complex-command
Dave Love <fx@gnu.org>
parents:
diff changeset
519 @kbd{C-x @key{ESC} @key{ESC}} is used to re-execute a recent
Dave Love <fx@gnu.org>
parents:
diff changeset
520 minibuffer-using command. With no argument, it repeats the last such
Dave Love <fx@gnu.org>
parents:
diff changeset
521 command. A numeric argument specifies which command to repeat; one
Dave Love <fx@gnu.org>
parents:
diff changeset
522 means the last one, and larger numbers specify earlier ones.
Dave Love <fx@gnu.org>
parents:
diff changeset
523
Dave Love <fx@gnu.org>
parents:
diff changeset
524 @kbd{C-x @key{ESC} @key{ESC}} works by turning the previous command
Dave Love <fx@gnu.org>
parents:
diff changeset
525 into a Lisp expression and then entering a minibuffer initialized with
Dave Love <fx@gnu.org>
parents:
diff changeset
526 the text for that expression. If you type just @key{RET}, the command
Dave Love <fx@gnu.org>
parents:
diff changeset
527 is repeated as before. You can also change the command by editing the
Dave Love <fx@gnu.org>
parents:
diff changeset
528 Lisp expression. Whatever expression you finally submit is what will be
Dave Love <fx@gnu.org>
parents:
diff changeset
529 executed. The repeated command is added to the front of the command
Dave Love <fx@gnu.org>
parents:
diff changeset
530 history unless it is identical to the most recently executed command
Dave Love <fx@gnu.org>
parents:
diff changeset
531 already there.
Dave Love <fx@gnu.org>
parents:
diff changeset
532
Dave Love <fx@gnu.org>
parents:
diff changeset
533 Even if you don't understand Lisp syntax, it will probably be obvious
Dave Love <fx@gnu.org>
parents:
diff changeset
534 which command is displayed for repetition. If you do not change the
Dave Love <fx@gnu.org>
parents:
diff changeset
535 text, it will repeat exactly as before.
Dave Love <fx@gnu.org>
parents:
diff changeset
536
Dave Love <fx@gnu.org>
parents:
diff changeset
537 Once inside the minibuffer for @kbd{C-x @key{ESC} @key{ESC}}, you can
Dave Love <fx@gnu.org>
parents:
diff changeset
538 use the minibuffer history commands (@kbd{M-p}, @kbd{M-n}, @kbd{M-r},
Dave Love <fx@gnu.org>
parents:
diff changeset
539 @kbd{M-s}; @pxref{Minibuffer History}) to move through the history list
Dave Love <fx@gnu.org>
parents:
diff changeset
540 of saved entire commands. After finding the desired previous command,
Dave Love <fx@gnu.org>
parents:
diff changeset
541 you can edit its expression as usual and then resubmit it by typing
Dave Love <fx@gnu.org>
parents:
diff changeset
542 @key{RET} as usual.
Dave Love <fx@gnu.org>
parents:
diff changeset
543
Dave Love <fx@gnu.org>
parents:
diff changeset
544 @vindex command-history
Dave Love <fx@gnu.org>
parents:
diff changeset
545 The list of previous minibuffer-using commands is stored as a Lisp
Dave Love <fx@gnu.org>
parents:
diff changeset
546 list in the variable @code{command-history}. Each element is a Lisp
Dave Love <fx@gnu.org>
parents:
diff changeset
547 expression which describes one command and its arguments. Lisp programs
Dave Love <fx@gnu.org>
parents:
diff changeset
548 can re-execute a command by calling @code{eval} with the
Dave Love <fx@gnu.org>
parents:
diff changeset
549 @code{command-history} element.