diff options
| -rw-r--r-- | doc/emacs/mini.texi | 424 |
1 files changed, 207 insertions, 217 deletions
diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 8510fea9b94..905c026577e 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi | |||
| @@ -7,57 +7,42 @@ | |||
| 7 | @cindex minibuffer | 7 | @cindex minibuffer |
| 8 | 8 | ||
| 9 | The @dfn{minibuffer} is where Emacs commands read complicated | 9 | The @dfn{minibuffer} is where Emacs commands read complicated |
| 10 | arguments (anything more a single number). We call it the | 10 | arguments, such as file names, buffer names, Emacs command names, or |
| 11 | ``minibuffer'' because it's a special-purpose buffer with a small | 11 | Lisp expressions. We call it the ``minibuffer'' because it's a |
| 12 | amount of screen space. Minibuffer arguments can be file names, | 12 | special-purpose buffer with a small amount of screen space. You can |
| 13 | buffer names, Lisp function names, Emacs command names, Lisp | 13 | use the usual Emacs editing commands in the minibuffer to edit the |
| 14 | expressions, and many other things---whatever the command wants to | 14 | argument text. |
| 15 | read. You can use the usual Emacs editing commands in the minibuffer | ||
| 16 | to edit the argument text. | ||
| 17 | 15 | ||
| 18 | @cindex prompt | 16 | @cindex prompt |
| 19 | When the minibuffer is in use, it appears in the echo area, with a | 17 | When the minibuffer is in use, it appears in the echo area, with a |
| 20 | cursor. The minibuffer display starts with a @dfn{prompt} in a | 18 | cursor. The minibuffer display starts with a @dfn{prompt} in a |
| 21 | distinct color; it says what kind of input is expected and how it will | 19 | distinct color, usually ending with a colon. The prompt states what |
| 22 | be used. Often the prompt is derived from the name of the command | 20 | kind of input is expected, and how it will be used. |
| 23 | that is reading the argument. The prompt normally ends with a colon. | 21 | |
| 22 | The simplest way to enter a minibuffer argument is to type the text, | ||
| 23 | then @key{RET} to submit the argument and exit the minibuffer. You | ||
| 24 | can cancel the minibuffer, and the command that wants the argument, by | ||
| 25 | typing @kbd{C-g}. | ||
| 24 | 26 | ||
| 25 | @cindex default argument | 27 | @cindex default argument |
| 26 | Sometimes a @dfn{default argument} appears in the prompt, inside | 28 | Sometimes, a @dfn{default argument} appears in the prompt, inside |
| 27 | parentheses before the colon. The default will be used as the | 29 | parentheses before the colon. The default will be used as the |
| 28 | argument value if you just type @key{RET}. For example, commands that | 30 | argument value if you just type @key{RET}. For example, commands that |
| 29 | read buffer names show a buffer name as the default. You can type | 31 | read buffer names usually show a buffer name as the default; you can |
| 30 | @key{RET} to operate on that default buffer. | 32 | type @key{RET} to operate on that default buffer. |
| 31 | |||
| 32 | The simplest way to enter a minibuffer argument is to type the text, | ||
| 33 | then @key{RET} to exit the minibuffer. You can cancel the minibuffer, | ||
| 34 | and the command that wants the argument, by typing @kbd{C-g}. | ||
| 35 | 33 | ||
| 36 | Since the minibuffer appears in the echo area, it can conflict with | 34 | Since the minibuffer appears in the echo area, it can conflict with |
| 37 | other uses of the echo area. Here is how Emacs handles such | 35 | other uses of the echo area. If an error occurs while the minibuffer |
| 38 | conflicts: | 36 | is active, the error message hides the minibuffer for a few seconds, |
| 39 | 37 | or until you type something; then the minibuffer comes back. If a | |
| 40 | @itemize @bullet | 38 | command such as @kbd{C-x =} needs to display a message in the echo |
| 41 | @item | 39 | area, the message hides the minibuffer for a few seconds, or until you |
| 42 | An error occurs while the minibuffer is active. | 40 | type something; then the minibuffer comes back. While the minibuffer |
| 43 | 41 | is in use, keystrokes do not echo. | |
| 44 | The error message hides the minibuffer for a few seconds, or until you | ||
| 45 | type something. Then the minibuffer comes back. | ||
| 46 | |||
| 47 | @item | ||
| 48 | A command such as @kbd{C-x =} needs to display a message in the echo | ||
| 49 | area. | ||
| 50 | |||
| 51 | The message hides the minibuffer for a few seconds, or until you type | ||
| 52 | something. Then the minibuffer comes back. | ||
| 53 | |||
| 54 | @item | ||
| 55 | Keystrokes don't echo while the minibuffer is in use. | ||
| 56 | @end itemize | ||
| 57 | 42 | ||
| 58 | @menu | 43 | @menu |
| 59 | * File: Minibuffer File. Entering file names with the minibuffer. | 44 | * Minibuffer File:: Entering file names with the minibuffer. |
| 60 | * Edit: Minibuffer Edit. How to edit in the minibuffer. | 45 | * Minibuffer Edit:: How to edit in the minibuffer. |
| 61 | * Completion:: An abbreviation facility for minibuffer input. | 46 | * Completion:: An abbreviation facility for minibuffer input. |
| 62 | * Minibuffer History:: Reusing recent minibuffer arguments. | 47 | * Minibuffer History:: Reusing recent minibuffer arguments. |
| 63 | * Repetition:: Re-executing commands that used the minibuffer. | 48 | * Repetition:: Re-executing commands that used the minibuffer. |
| @@ -66,33 +51,31 @@ Keystrokes don't echo while the minibuffer is in use. | |||
| 66 | @node Minibuffer File | 51 | @node Minibuffer File |
| 67 | @section Minibuffers for File Names | 52 | @section Minibuffers for File Names |
| 68 | 53 | ||
| 69 | When you use the minibuffer to enter a file name, it starts out with | 54 | Commands such as @kbd{C-x C-f} (@code{find-file}) use the minibuffer |
| 70 | some initial text---the @dfn{default directory}, ending in a slash. | 55 | to read a file name argument (@pxref{Basic Files}). When the |
| 71 | The file you specify will be in this directory unless you alter or | 56 | minibuffer is used to read a file name, it typically starts out with |
| 72 | replace it. | 57 | some initial text---the @dfn{default directory}, which ends in a |
| 73 | 58 | slash. For example, it may start out like this: | |
| 74 | @c Separate paragraph to clean up ugly page break--rms | ||
| 75 | @need 1500 | ||
| 76 | For example, if the minibuffer starts out with these contents: | ||
| 77 | 59 | ||
| 78 | @example | 60 | @example |
| 79 | Find File: /u2/emacs/src/ | 61 | Find File: /u2/emacs/src/ |
| 80 | @end example | 62 | @end example |
| 81 | 63 | ||
| 82 | @noindent | 64 | @noindent |
| 83 | (where @samp{Find File:@: } is the prompt), and you type | 65 | Here, @samp{Find File:@: } is the prompt and @samp{/u2/emacs/src/} is |
| 84 | @kbd{buffer.c} as input, that specifies the file | 66 | the default directory. If you now type @kbd{buffer.c} as input, that |
| 85 | @file{/u2/emacs/src/buffer.c}. You can specify the parent directory | 67 | specifies the file @file{/u2/emacs/src/buffer.c}. |
| 86 | by adding @file{..}; thus, if you type @kbd{../lisp/simple.el}, you | 68 | |
| 87 | will get @file{/u2/emacs/lisp/simple.el}. Alternatively, you can use | 69 | You can specify the parent directory by adding @file{..}: for |
| 88 | @kbd{M-@key{DEL}} to kill the directory names you don't want | 70 | example, @file{/u2/emacs/src/../lisp/simple.el} is equivalent to |
| 89 | (@pxref{Words}). | 71 | @file{/u2/emacs/lisp/simple.el}. Alternatively, you can use |
| 90 | 72 | @kbd{M-@key{DEL}} to kill directory names backwards (@pxref{Words}). | |
| 91 | You can kill the entire default with @kbd{C-a C-k}, but there's no | 73 | |
| 92 | need to do that. It's easier to ignore the default, and enter an | 74 | To specify a file in a completely different directory, you can kill |
| 93 | absolute file name starting with a slash or a tilde after the default | 75 | the entire default with @kbd{C-a C-k} (@pxref{Minibuffer Edit}). |
| 94 | directory. For example, to specify @file{/etc/termcap}, just type | 76 | Alternatively, you can ignore the default, and enter an absolute file |
| 95 | that name: | 77 | name starting with a slash or a tilde after the default directory. |
| 78 | For example, you can specify @file{/etc/termcap} as follows: | ||
| 96 | 79 | ||
| 97 | @example | 80 | @example |
| 98 | Find File: /u2/emacs/src//etc/termcap | 81 | Find File: /u2/emacs/src//etc/termcap |
| @@ -103,59 +86,74 @@ Find File: /u2/emacs/src//etc/termcap | |||
| 103 | @cindex double slash in file name | 86 | @cindex double slash in file name |
| 104 | @cindex slashes repeated in file name | 87 | @cindex slashes repeated in file name |
| 105 | @findex file-name-shadow-mode | 88 | @findex file-name-shadow-mode |
| 106 | GNU Emacs interprets a double slash (which is not normally useful in | 89 | Emacs interprets a double slash as ``ignore everything before the |
| 107 | file names) as, ``ignore everything before the second slash in the | 90 | second slash in the pair.'' In the example above, |
| 108 | pair.'' In the example above. @samp{/u2/emacs/src/} is ignored, so | 91 | @samp{/u2/emacs/src/} is ignored, so the argument you supplied is |
| 109 | you get @file{/etc/termcap}. The ignored part of the file name is | 92 | @file{/etc/termcap}. Similarly, Emacs interprets a tilde (@samp{~}) |
| 110 | dimmed if the terminal allows it; to disable this dimming, turn off | 93 | as your home directory, ignoring everything before the tilde. |
| 111 | File Name Shadow mode (a minor mode) with the command | 94 | |
| 112 | @kbd{M-x file-name-shadow-mode}. | 95 | The ignored part of the file name is dimmed if the terminal allows |
| 113 | 96 | it. To disable this dimming, turn off File Name Shadow mode, a minor | |
| 114 | If the variable @code{insert-default-directory} is @code{nil}, the | 97 | mode, with the command @kbd{M-x file-name-shadow-mode}. |
| 115 | default directory is never inserted in the minibuffer---so the | 98 | |
| 116 | minibuffer starts out empty. Nonetheless, relative file name | 99 | To prevent Emacs from inserting the default directory when reading |
| 117 | arguments are still interpreted based on the same default directory. | 100 | file names, change the variable @code{insert-default-directory} to |
| 101 | @code{nil}. In that case, the minibuffer starts out empty. | ||
| 102 | Nonetheless, relative file name arguments are still interpreted based | ||
| 103 | on the same default directory. | ||
| 118 | 104 | ||
| 119 | @node Minibuffer Edit | 105 | @node Minibuffer Edit |
| 120 | @section Editing in the Minibuffer | 106 | @section Editing in the Minibuffer |
| 121 | 107 | ||
| 122 | The minibuffer is an Emacs buffer (albeit a peculiar one), and the | 108 | The minibuffer is an Emacs buffer, albeit a peculiar one, and the |
| 123 | usual Emacs commands are available for editing the argument text. | 109 | usual Emacs commands are available for editing the argument text. |
| 110 | (The prompt, however, is @dfn{read-only}, and cannot be changed.) | ||
| 124 | 111 | ||
| 125 | Since @key{RET} in the minibuffer is defined to exit the minibuffer, | 112 | Since @key{RET} in the minibuffer is defined to exit the minibuffer, |
| 126 | you can't use it to insert a newline in the minibuffer. To do that, | 113 | you can't use it to insert a newline in the minibuffer. To do that, |
| 127 | type @kbd{C-o} or @kbd{C-q C-j}. (The newline character is really the | 114 | type @kbd{C-o} or @kbd{C-q C-j}. (The newline character is really the |
| 128 | @acronym{ASCII} character control-J.) | 115 | @acronym{ASCII} character control-J.) |
| 129 | 116 | ||
| 130 | The minibuffer has its own window, which normally has space in the | 117 | Inside a minibuffer, the keys @kbd{@key{TAB}}, @kbd{@key{SPC}}, and |
| 131 | frame at all times, but it only acts like an Emacs window when the | 118 | @kbd{@key{?}} are often bound to commands that perform |
| 132 | minibuffer is active. When active, this window is much like any other | 119 | @dfn{completion}. @xref{Completion}. You can use @kbd{C-q} |
| 133 | Emacs window; for instance, you can switch to another window (with | 120 | (@code{quoted-insert}) to insert a @key{TAB}, @key{SPC}, or @key{?} |
| 134 | @kbd{C-x o}), edit text there, then return to the minibuffer window to | 121 | character. For example, @kbd{C-q @key{TAB}} inserts a @key{TAB} |
| 135 | finish the argument. You can even kill text in another window, return | 122 | character. @xref{Inserting Text}. |
| 136 | to the minibuffer window, and then yank the text into the argument. | 123 | |
| 137 | @xref{Windows}. | 124 | For convenience, @kbd{C-a} (@code{move-beginning-of-line}) in a |
| 125 | minibuffer moves point to the beginning of the argument text, not the | ||
| 126 | beginning of the prompt. For example, this allows you to erase the | ||
| 127 | entire argument with @kbd{C-a C-k}. | ||
| 138 | 128 | ||
| 139 | @cindex height of minibuffer | 129 | @cindex height of minibuffer |
| 140 | @cindex size of minibuffer | 130 | @cindex size of minibuffer |
| 141 | @cindex growing minibuffer | 131 | @cindex growing minibuffer |
| 142 | @cindex resizing minibuffer | 132 | @cindex resizing minibuffer |
| 143 | There are some restrictions on the minibuffer window, however: you | 133 | When the minibuffer is active, the echo area is treated much like an |
| 144 | cannot kill it, or split it, or switch buffers in it---the minibuffer | 134 | ordinary Emacs window. For instance, you can switch to another window |
| 145 | and its window are permanently attached. | 135 | (with @kbd{C-x o}), edit text there, then return to the minibuffer |
| 136 | window to finish the argument. You can even kill text in another | ||
| 137 | window, return to the minibuffer window, and yank the text into the | ||
| 138 | argument. There are some restrictions on the minibuffer window, | ||
| 139 | however: for instance, you cannot split it. @xref{Windows}. | ||
| 146 | 140 | ||
| 147 | @vindex resize-mini-windows | 141 | @vindex resize-mini-windows |
| 148 | The minibuffer window expands vertically as necessary to hold the | 142 | Normally, the minibuffer window occupies a single screen line. |
| 149 | text that you put in the minibuffer. If @code{resize-mini-windows} is | 143 | However, if you add two or more lines' worth of text into the |
| 150 | @code{t}, the window always resizes as needed by its contents. If its | 144 | minibuffer, it expands automatically to accomodate the text. The |
| 151 | value is the symbol @code{grow-only} (the default), the window grows | 145 | variable @code{resize-mini-windows} controls the resizing of the |
| 152 | automatically as needed, but shrinks (back to the normal size) only | 146 | minibuffer. The default value is @code{grow-only}, which means the |
| 153 | when the minibuffer becomes inactive. If its value is @code{nil}, you | 147 | behavior we have just described. If the value is @code{t}, the |
| 154 | have to adjust the height yourself. | 148 | minibuffer window will also shrink automatically if you remove some |
| 149 | lines of text from the minibuffer, down to a minimum of one screen | ||
| 150 | line. If the value is @code{nil}, the minibuffer window never changes | ||
| 151 | size automatically, but you can use the usual window-resizing commands | ||
| 152 | on it (@pxref{Windows}). | ||
| 155 | 153 | ||
| 156 | @vindex max-mini-window-height | 154 | @vindex max-mini-window-height |
| 157 | The variable @code{max-mini-window-height} controls the maximum | 155 | The variable @code{max-mini-window-height} controls the maximum |
| 158 | height for resizing the minibuffer window: a floating-point number | 156 | height for resizing the minibuffer window. A floating-point number |
| 159 | specifies a fraction of the frame's height; an integer specifies the | 157 | specifies a fraction of the frame's height; an integer specifies the |
| 160 | maximum number of lines; @code{nil} means do not resize the minibuffer | 158 | maximum number of lines; @code{nil} means do not resize the minibuffer |
| 161 | window automatically. The default value is 0.25. | 159 | window automatically. The default value is 0.25. |
| @@ -168,47 +166,40 @@ completions. @xref{Other Window}. | |||
| 168 | 166 | ||
| 169 | @vindex enable-recursive-minibuffers | 167 | @vindex enable-recursive-minibuffers |
| 170 | Emacs normally disallows most commands that use the minibuffer while | 168 | Emacs normally disallows most commands that use the minibuffer while |
| 171 | the minibuffer is active. (Entering the minibuffer from the | 169 | the minibuffer is active. To allow such commands in the minibuffer, |
| 172 | minibuffer can be confusing.) To allow such commands in the | 170 | set the variable @code{enable-recursive-minibuffers} to @code{t}. |
| 173 | minibuffer, set the variable @code{enable-recursive-minibuffers} to | ||
| 174 | @code{t}. | ||
| 175 | 171 | ||
| 176 | @node Completion | 172 | @node Completion |
| 177 | @section Completion | 173 | @section Completion |
| 178 | @c This node is referenced in the tutorial. When renaming or deleting | 174 | @c This node is referenced in the tutorial. When renaming or deleting |
| 179 | @c it, the tutorial needs to be adjusted. | 175 | @c it, the tutorial needs to be adjusted. |
| 180 | @cindex completion | 176 | @cindex completion |
| 181 | 177 | ||
| 182 | Some arguments allow @dfn{completion} to enter their value. This | 178 | Sometimes, you can use a feature called @dfn{completion} to help you |
| 183 | means that after you type part of the argument, Emacs can fill in the | 179 | enter arguments. This means that after you type part of the argument, |
| 184 | rest, or some of it, based on what you have typed so far. | 180 | Emacs can fill in the rest, or some of it, based on what you have |
| 185 | 181 | typed so far. | |
| 186 | When completion is available, certain keys---@key{TAB}, @key{RET}, | 182 | |
| 187 | and @key{SPC}---are rebound to complete the text in the minibuffer | 183 | When completion is available, certain keys (usually @key{TAB}, |
| 188 | before point into a longer string chosen from a set of @dfn{completion | 184 | @key{RET}, and @key{SPC}) are rebound to complete the text in the |
| 189 | alternatives} provided by the command that requested the argument. | 185 | minibuffer into a longer string chosen from a set of @dfn{completion |
| 190 | (@key{SPC} does not do completion in reading file names, because it is | 186 | alternatives}. The set of completion alternatives depends on the |
| 191 | common to use spaces in file names on some systems.) @kbd{?} displays | 187 | command that requested the argument, and on what you have typed so |
| 192 | a list of the possible completions at any time. | 188 | far. In addition, you can usually type @kbd{?} to display a list of |
| 189 | possible completions. | ||
| 193 | 190 | ||
| 194 | For example, @kbd{M-x} uses the minibuffer to read the name of a | 191 | For example, @kbd{M-x} uses the minibuffer to read the name of a |
| 195 | command, so it provides a list of all Emacs command names for | 192 | command, so completion works by matching the minibuffer text against |
| 196 | completion candidates. The completion keys match the minibuffer text | 193 | the names of existing Emacs commands. So, to run the command |
| 197 | against these candidates, find any additional name characters implied | 194 | @code{insert-buffer}, you can type @kbd{M-x ins @key{SPC} b @key{RET}} |
| 198 | by the text already present in the minibuffer, and add those | 195 | instead of the full @kbd{M-x insert-buffer @key{RET}}. |
| 199 | characters. This makes it possible to type @kbd{M-x ins @key{SPC} b | ||
| 200 | @key{RET}} instead of @kbd{M-x insert-buffer @key{RET}}, for example. | ||
| 201 | 196 | ||
| 202 | Case is significant in completion when it is significant in the | 197 | Case is significant in completion when it is significant in the |
| 203 | argument you are entering (buffer names, file names, command names, | 198 | argument you are entering, such as command names. Thus, |
| 204 | for instance). Thus, @samp{fo} does not complete to @samp{Foo}. | 199 | @samp{insert-buffer} is not a valid completion for @samp{IN}. |
| 205 | Completion ignores case distinctions for certain arguments in which | 200 | Completion ignores case distinctions for certain arguments in which |
| 206 | case does not matter. | 201 | case does not matter. |
| 207 | 202 | ||
| 208 | Completion acts only on the text before point. If there is text in | ||
| 209 | the minibuffer after point---i.e., if you move point backward after | ||
| 210 | typing some text into the minibuffer---it remains unchanged. | ||
| 211 | |||
| 212 | @menu | 203 | @menu |
| 213 | * Example: Completion Example. Examples of using completion. | 204 | * Example: Completion Example. Examples of using completion. |
| 214 | * Commands: Completion Commands. A list of completion commands. | 205 | * Commands: Completion Commands. A list of completion commands. |
| @@ -220,22 +211,24 @@ typing some text into the minibuffer---it remains unchanged. | |||
| 220 | @subsection Completion Example | 211 | @subsection Completion Example |
| 221 | 212 | ||
| 222 | @kindex TAB @r{(completion)} | 213 | @kindex TAB @r{(completion)} |
| 223 | A concrete example may help here. If you type @kbd{M-x au | 214 | A concrete example may help here. If you type @kbd{M-x a u |
| 224 | @key{TAB}}, the @key{TAB} looks for alternatives (in this case, | 215 | @key{TAB}}, the @key{TAB} looks for alternatives (in this case, |
| 225 | command names) that start with @samp{au}. There are several, | 216 | command names) that start with @samp{au}. There are several, |
| 226 | including @code{auto-fill-mode} and @code{auto-save-mode}, but they | 217 | including @code{auto-fill-mode} and @code{autoconf-mode}, but they all |
| 227 | all begin with @code{auto-}, so the @samp{au} in the minibuffer | 218 | begin with @code{auto}, so the @samp{au} in the minibuffer completes |
| 228 | completes to @samp{auto-}. | 219 | to @samp{auto}. |
| 229 | 220 | ||
| 230 | If you type @key{TAB} again immediately, it cannot determine the | 221 | If you type @key{TAB} again immediately, it cannot determine the |
| 231 | next character; it could be any of @samp{cfilrs}. So it does not add | 222 | next character; it could be @samp{-}, @samp{a}, or @samp{c}. So it |
| 232 | any characters; instead, @key{TAB} displays a list of all possible | 223 | does not add any characters; instead, @key{TAB} displays a list of all |
| 233 | completions in another window. | 224 | possible completions in another window. |
| 234 | 225 | ||
| 235 | Now type @kbd{f @key{TAB}}. This @key{TAB} sees @samp{auto-f}. The | 226 | Next, type @kbd{- f}. The minibuffer now contains @samp{auto-f}, |
| 236 | only command name starting with that is @code{auto-fill-mode}, so | 227 | and the only command name that starts with this is |
| 237 | completion fills in the rest of that. You have been able to enter | 228 | @code{auto-fill-mode}. If you now type @key{TAB}, completion fills in |
| 238 | @samp{auto-fill-mode} by typing just @kbd{au @key{TAB} f @key{TAB}}. | 229 | the rest of the argument @samp{auto-fill-mode} into the minibuffer. |
| 230 | You have been able to enter @samp{auto-fill-mode} by typing just | ||
| 231 | @kbd{a u @key{TAB} - f @key{TAB}}. | ||
| 239 | 232 | ||
| 240 | @node Completion Commands | 233 | @node Completion Commands |
| 241 | @subsection Completion Commands | 234 | @subsection Completion Commands |
| @@ -246,7 +239,8 @@ when completion is allowed. | |||
| 246 | @table @kbd | 239 | @table @kbd |
| 247 | @item @key{TAB} | 240 | @item @key{TAB} |
| 248 | @findex minibuffer-complete | 241 | @findex minibuffer-complete |
| 249 | Complete the text before point in the minibuffer as much as possible | 242 | Complete the text before point in the minibuffer as much as possible; |
| 243 | if unable to complete, display a list of possible completions | ||
| 250 | (@code{minibuffer-complete}). | 244 | (@code{minibuffer-complete}). |
| 251 | @item @key{SPC} | 245 | @item @key{SPC} |
| 252 | Complete up to one word from the minibuffer text before point | 246 | Complete up to one word from the minibuffer text before point |
| @@ -255,13 +249,12 @@ available when entering a file name, since file names often include | |||
| 255 | spaces. | 249 | spaces. |
| 256 | @item @key{RET} | 250 | @item @key{RET} |
| 257 | Submit the text in the minibuffer as the argument, possibly completing | 251 | Submit the text in the minibuffer as the argument, possibly completing |
| 258 | first as described | 252 | first as described in the next |
| 259 | @iftex | 253 | @iftex |
| 260 | in the next subsection (@code{minibuffer-complete-and-exit}). | 254 | subsection (@code{minibuffer-complete-and-exit}). |
| 261 | @end iftex | 255 | @end iftex |
| 262 | @ifnottex | 256 | @ifnottex |
| 263 | in the next node (@code{minibuffer-complete-and-exit}). @xref{Strict | 257 | node (@code{minibuffer-complete-and-exit}). @xref{Strict Completion}. |
| 264 | Completion}. | ||
| 265 | @end ifnottex | 258 | @end ifnottex |
| 266 | @item ? | 259 | @item ? |
| 267 | Display a list of possible completions of the text before point | 260 | Display a list of possible completions of the text before point |
| @@ -270,13 +263,12 @@ Display a list of possible completions of the text before point | |||
| 270 | 263 | ||
| 271 | @kindex SPC | 264 | @kindex SPC |
| 272 | @findex minibuffer-complete-word | 265 | @findex minibuffer-complete-word |
| 273 | @key{SPC} completes like @key{TAB}, but only up to the next hyphen | 266 | @key{SPC} (@code{minibuffer-complete-word}) completes like |
| 274 | or space. If you have @samp{auto-f} in the minibuffer and type | 267 | @key{TAB}, but only up to the next hyphen or space. If you have |
| 275 | @key{SPC}, it finds that the completion is @samp{auto-fill-mode}, but | 268 | @samp{auto-f} in the minibuffer and type @key{SPC}, it finds that the |
| 276 | it only inserts @samp{ill-}, giving @samp{auto-fill-}. Another | 269 | completion is @samp{auto-fill-mode}, but it only inserts @samp{ill-}, |
| 277 | @key{SPC} at this point completes all the way to | 270 | giving @samp{auto-fill-}. Another @key{SPC} at this point completes |
| 278 | @samp{auto-fill-mode}. The command that implements this behavior is | 271 | all the way to @samp{auto-fill-mode}. |
| 279 | called @code{minibuffer-complete-word}. | ||
| 280 | 272 | ||
| 281 | When you display a list of possible completions, you can choose | 273 | When you display a list of possible completions, you can choose |
| 282 | one from it: | 274 | one from it: |
| @@ -286,34 +278,34 @@ one from it: | |||
| 286 | @item Mouse-1 | 278 | @item Mouse-1 |
| 287 | @itemx Mouse-2 | 279 | @itemx Mouse-2 |
| 288 | Clicking mouse button 1 or 2 on a completion possibility chooses that | 280 | Clicking mouse button 1 or 2 on a completion possibility chooses that |
| 289 | completion (@code{mouse-choose-completion}). You must click in the | 281 | completion (@code{mouse-choose-completion}). |
| 290 | list of completions, not in the minibuffer. | ||
| 291 | 282 | ||
| 292 | @findex switch-to-completions | 283 | @findex switch-to-completions |
| 293 | @item @key{PRIOR} | 284 | @item M-v |
| 294 | @itemx M-v | 285 | @itemx @key{PageUp} |
| 295 | Typing @key{PRIOR} or @key{PAGE-UP}, or @kbd{M-v}, while in the | 286 | @itemx @key{PRIOR} |
| 296 | minibuffer, selects the window showing the completion list buffer | 287 | Typing @kbd{M-v}, while in the minibuffer, selects the window showing |
| 297 | (@code{switch-to-completions}). This paves the way for using the | 288 | the completion list buffer (@code{switch-to-completions}). This paves |
| 298 | commands below. (Selecting that window in other ways has the same | 289 | the way for using the commands below. Typing @key{PageUp} or |
| 299 | effect.) | 290 | @key{PRIOR} does the same, as does selecting that window in other |
| 291 | ways. | ||
| 300 | 292 | ||
| 301 | @findex choose-completion | 293 | @findex choose-completion |
| 302 | @item @key{RET} | 294 | @item @key{RET} |
| 303 | Typing @key{RET} @emph{in the completion list buffer} chooses the | 295 | Typing @key{RET}, while in the completion list buffer, chooses the |
| 304 | completion that point is in or next to (@code{choose-completion}). To | 296 | completion that point is in or next to (@code{choose-completion}). To |
| 305 | use this command, you must first switch to the completion list window. | 297 | use this command, you must first switch to the completion list window. |
| 306 | 298 | ||
| 307 | @findex next-completion | 299 | @findex next-completion |
| 308 | @item @key{RIGHT} | 300 | @item @key{Right} |
| 309 | Typing the right-arrow key @key{RIGHT} @emph{in the completion list | 301 | Typing the right-arrow key @key{Right}, while in the completion list |
| 310 | buffer} moves point to the following completion possibility | 302 | buffer, moves point to the following completion possibility |
| 311 | (@code{next-completion}). | 303 | (@code{next-completion}). |
| 312 | 304 | ||
| 313 | @findex previous-completion | 305 | @findex previous-completion |
| 314 | @item @key{LEFT} | 306 | @item @key{Left} |
| 315 | Typing the left-arrow key @key{LEFT} @emph{in the completion list | 307 | Typing the left-arrow key @key{Left}, while in the completion list |
| 316 | buffer} moves point to the previous completion possibility | 308 | buffer, moves point to the previous completion possibility |
| 317 | (@code{previous-completion}). | 309 | (@code{previous-completion}). |
| 318 | @end table | 310 | @end table |
| 319 | 311 | ||
| @@ -357,29 +349,34 @@ the list with @kbd{C-M-v} (@pxref{Other Window}). | |||
| 357 | @node Completion Options | 349 | @node Completion Options |
| 358 | @subsection Completion Options | 350 | @subsection Completion Options |
| 359 | 351 | ||
| 352 | @vindex completion-auto-help | ||
| 353 | If @code{completion-auto-help} is set to @code{nil}, the completion | ||
| 354 | commands never display the completion list buffer; you must type | ||
| 355 | @kbd{?} to display the list. If the value is @code{lazy}, Emacs only | ||
| 356 | shows the completion list buffer on the second attempt to complete. | ||
| 357 | In other words, if there is nothing to complete, the first @key{TAB} | ||
| 358 | echoes @samp{Next char not unique}; the second @key{TAB} does the | ||
| 359 | completion list buffer buffer. | ||
| 360 | |||
| 360 | @vindex completion-ignored-extensions | 361 | @vindex completion-ignored-extensions |
| 361 | @cindex ignored file names, in completion | 362 | @cindex ignored file names, in completion |
| 362 | When completing file names, certain file names are usually ignored. | 363 | When completing file names, certain file names are usually ignored. |
| 363 | The variable @code{completion-ignored-extensions} contains a list of | 364 | The variable @code{completion-ignored-extensions} contains a list of |
| 364 | strings; a file name ending in any of those strings is ignored as a | 365 | strings; a file name ending in any of those strings is ignored as a |
| 365 | completion candidate. The standard value of this variable has several | 366 | completion candidate. The standard value of this variable has several |
| 366 | elements including @code{".o"}, @code{".elc"}, @code{".dvi"} and | 367 | elements including @code{".o"}, @code{".elc"}, and @code{"~"}. For |
| 367 | @code{"~"}. The effect is that, for example, @samp{foo} can complete | 368 | example, if a directory contains @samp{foo.c} and @samp{foo.elc}, |
| 368 | to @samp{foo.c} even though @samp{foo.o} exists as well. However, if | 369 | @samp{foo} completes to @samp{foo.c}. However, if @emph{all} possible |
| 369 | @emph{all} the possible completions end in ``ignored'' strings, then | 370 | completions end in ``ignored'' strings, they are not ignored: in the |
| 370 | they are not ignored. Displaying a list of possible completions | 371 | previous example, @samp{foo.e} completes to @samp{foo.elc}. |
| 371 | disregards @code{completion-ignored-extensions}; it shows them all. | 372 | Displaying a list of possible completions disregards |
| 373 | @code{completion-ignored-extensions}; it shows them all. | ||
| 372 | 374 | ||
| 373 | If an element of @code{completion-ignored-extensions} ends in a | 375 | If an element of @code{completion-ignored-extensions} ends in a |
| 374 | slash (@file{/}), it's a subdirectory name; then that directory and | 376 | slash (@file{/}), it's a subdirectory name; that directory and its |
| 375 | its contents are ignored. Elements of | 377 | contents are ignored. Elements of |
| 376 | @code{completion-ignored-extensions} which do not end in a slash are | 378 | @code{completion-ignored-extensions} that do not end in a slash are |
| 377 | ordinary file names, and do not apply to names of directories. | 379 | ordinary file names. |
| 378 | |||
| 379 | @vindex completion-auto-help | ||
| 380 | If @code{completion-auto-help} is set to @code{nil}, the completion | ||
| 381 | commands never display a list of possibilities; you must type @kbd{?} | ||
| 382 | to display the list. | ||
| 383 | 380 | ||
| 384 | @cindex Partial Completion mode | 381 | @cindex Partial Completion mode |
| 385 | @vindex partial-completion-mode | 382 | @vindex partial-completion-mode |
| @@ -390,7 +387,7 @@ it can complete the command name abbreviation @code{p-b} into | |||
| 390 | @code{print-buffer} if no other command starts with two words whose | 387 | @code{print-buffer} if no other command starts with two words whose |
| 391 | initials are @samp{p} and @samp{b}. | 388 | initials are @samp{p} and @samp{b}. |
| 392 | 389 | ||
| 393 | To enable this mode, use @kbd{M-x partial-completion-mode}, or | 390 | To enable this mode, use @kbd{M-x partial-completion-mode} or |
| 394 | customize the variable @code{partial-completion-mode}. This mode | 391 | customize the variable @code{partial-completion-mode}. This mode |
| 395 | binds special partial completion commands to @key{TAB}, @key{SPC}, | 392 | binds special partial completion commands to @key{TAB}, @key{SPC}, |
| 396 | @key{RET}, and @kbd{?} in the minibuffer. The usual completion | 393 | @key{RET}, and @kbd{?} in the minibuffer. The usual completion |
| @@ -423,19 +420,18 @@ icomplete-mode}. | |||
| 423 | @cindex minibuffer history | 420 | @cindex minibuffer history |
| 424 | @cindex history of minibuffer input | 421 | @cindex history of minibuffer input |
| 425 | 422 | ||
| 426 | Every argument that you enter with the minibuffer is saved on a | 423 | Every argument that you enter with the minibuffer is saved in a |
| 427 | @dfn{minibuffer history list} so you can easily use it again later. | 424 | @dfn{minibuffer history list} so you can easily use it again later. |
| 428 | Special commands fetch the text of an earlier argument into the | 425 | You can use the following arguments to quickly fetch an earlier |
| 429 | minibuffer, replacing the old minibuffer contents. You can think of | 426 | argument into the minibuffer: |
| 430 | them as moving through the history of previous arguments. | ||
| 431 | 427 | ||
| 432 | @table @kbd | 428 | @table @kbd |
| 433 | @item @key{UP} | 429 | @item M-p |
| 434 | @itemx M-p | 430 | @itemx @key{Up} |
| 435 | Move to the previous item in the minibuffer history, an earlier argument | 431 | Move to the previous item in the minibuffer history, an earlier |
| 436 | (@code{previous-history-element}). | 432 | argument (@code{previous-history-element}). |
| 437 | @item @key{DOWN} | 433 | @item M-n |
| 438 | @itemx M-n | 434 | @itemx @key{Down} |
| 439 | Move to the next item in the minibuffer history | 435 | Move to the next item in the minibuffer history |
| 440 | (@code{next-history-element}). | 436 | (@code{next-history-element}). |
| 441 | @item M-r @var{regexp} @key{RET} | 437 | @item M-r @var{regexp} @key{RET} |
| @@ -450,24 +446,27 @@ Move to a later item in the minibuffer history that matches | |||
| 450 | @kindex M-n @r{(minibuffer history)} | 446 | @kindex M-n @r{(minibuffer history)} |
| 451 | @findex next-history-element | 447 | @findex next-history-element |
| 452 | @findex previous-history-element | 448 | @findex previous-history-element |
| 453 | To move through the minibuffer history list one item at a time, use | 449 | While in the minibuffer, typing @kbd{M-p} or @key{Up} |
| 454 | @kbd{M-p} or up-arrow (@code{previous-history-element}) to fetch the | 450 | (@code{previous-history-element}) moves up through the minibuffer |
| 455 | next earlier minibuffer input, and use @kbd{M-n} or down-arrow | 451 | history list, one item at a time. Each @kbd{M-p} fetches an earlier |
| 456 | (@code{next-history-element}) to fetch the next later input. These | 452 | item from the history list into the minibuffer, replacing its existing |
| 457 | commands don't move the cursor, they pull different saved strings into | 453 | contents. Similarly, typing @kbd{M-n} or @key{Down} |
| 458 | the minibuffer. But you can think of them as ``moving'' through the | 454 | (@code{next-history-element}) moves back down the history list, |
| 459 | history list. | 455 | fetching later entries into the minibuffer. You can think of these |
| 460 | 456 | commands as ``backwards'' and ``forwards'' through the history list. | |
| 461 | The input that you fetch from the history entirely replaces the | 457 | |
| 462 | contents of the minibuffer. To use it again unchanged, just type | 458 | If you type @kbd{M-n} in the minibuffer when there are no later |
| 463 | @key{RET}. You can also edit the text before you reuse it; this does | 459 | entries in the minibuffer history (e.g., if you haven't previously |
| 464 | not change the history element that you ``moved'' to, but your new | 460 | typed @kbd{M-p}), Emacs tries fetching from a list of default |
| 465 | argument does go at the end of the history list in its own right. | 461 | argument: values that you are likely to enter. You can think of this |
| 466 | 462 | as moving through the ``future list'' instead of the ``history list''. | |
| 467 | For many minibuffer arguments there is a ``default'' value, or | 463 | |
| 468 | a list of default values. You can insert the default value into the | 464 | The input that @kbd{M-p} or @kbd{M-n} fetches into the minibuffer |
| 469 | minibuffer as text by using @kbd{M-n} one or more times. You can | 465 | entirely replaces the existing contents of the minibuffer, so you can |
| 470 | think of this as moving ``into the future'' in the history. | 466 | simply type @key{RET} to use it as an argument. You can also edit the |
| 467 | text before you reuse it; this does not change the history element | ||
| 468 | that you ``moved'' to, but your new argument does go at the end of the | ||
| 469 | history list in its own right. | ||
| 471 | 470 | ||
| 472 | @findex previous-matching-history-element | 471 | @findex previous-matching-history-element |
| 473 | @findex next-matching-history-element | 472 | @findex next-matching-history-element |
| @@ -478,21 +477,11 @@ history; they search for history elements that match a regular | |||
| 478 | expression. @kbd{M-r} (@code{previous-matching-history-element}) | 477 | expression. @kbd{M-r} (@code{previous-matching-history-element}) |
| 479 | searches older elements in the history, while @kbd{M-s} | 478 | searches older elements in the history, while @kbd{M-s} |
| 480 | (@code{next-matching-history-element}) searches newer elements. These | 479 | (@code{next-matching-history-element}) searches newer elements. These |
| 481 | commands are unusual; they use the minibuffer to read the regular | 480 | commands are unusual: they use the minibuffer to read the regular |
| 482 | expression even though they are invoked from the minibuffer. As with | 481 | expression even though they are invoked from the minibuffer. As with |
| 483 | incremental searching, an upper-case letter in the regular expression | 482 | incremental searching, an upper-case letter in the regular expression |
| 484 | makes the search case-sensitive (@pxref{Search Case}). | 483 | makes the search case-sensitive (@pxref{Search Case}). |
| 485 | 484 | ||
| 486 | @ignore | ||
| 487 | We may change the precise way these commands read their arguments. | ||
| 488 | Perhaps they will search for a match for the string given so far in the | ||
| 489 | minibuffer; perhaps they will search for a literal match rather than a | ||
| 490 | regular expression match; perhaps they will only accept matches at the | ||
| 491 | beginning of a history element; perhaps they will read the string to | ||
| 492 | search for incrementally like @kbd{C-s}. To find out what interface is | ||
| 493 | actually available, type @kbd{C-h f previous-matching-history-element}. | ||
| 494 | @end ignore | ||
| 495 | |||
| 496 | All uses of the minibuffer record your input on a history list, but | 485 | All uses of the minibuffer record your input on a history list, but |
| 497 | there are separate history lists for different kinds of arguments. | 486 | there are separate history lists for different kinds of arguments. |
| 498 | For example, there is a list for file names, used by all the commands | 487 | For example, there is a list for file names, used by all the commands |
| @@ -510,12 +499,13 @@ one used by @kbd{M-x} for command names, and one used by | |||
| 510 | The variable @code{history-length} specifies the maximum length of a | 499 | The variable @code{history-length} specifies the maximum length of a |
| 511 | minibuffer history list; adding a new element deletes the oldest | 500 | minibuffer history list; adding a new element deletes the oldest |
| 512 | element if the list gets too long. If the value of | 501 | element if the list gets too long. If the value of |
| 513 | @code{history-length} is @code{t}, though, there is no maximum length. | 502 | @code{history-length} is @code{t}, there is no maximum length. |
| 514 | 503 | ||
| 515 | @vindex history-delete-duplicates | 504 | @vindex history-delete-duplicates |
| 516 | The variable @code{history-delete-duplicates} specifies whether to | 505 | The variable @code{history-delete-duplicates} specifies whether to |
| 517 | delete duplicates in history. If it is @code{t}, adding a new element | 506 | delete duplicates in history. If it is non-@code{nil}, adding a new |
| 518 | deletes from the list all other elements that are equal to it. | 507 | element deletes from the list all other elements that are equal to it. |
| 508 | The default is @code{nil}. | ||
| 519 | 509 | ||
| 520 | @node Repetition | 510 | @node Repetition |
| 521 | @section Repeating Minibuffer Commands | 511 | @section Repeating Minibuffer Commands |