| 1 |
This is ../info/emacs, produced by makeinfo version 4.3 from emacs.texi. |
|---|
| 2 |
|
|---|
| 3 |
This is the Fourteenth edition of the `GNU Emacs Manual', updated |
|---|
| 4 |
for Emacs version 21.3. |
|---|
| 5 |
|
|---|
| 6 |
INFO-DIR-SECTION Emacs |
|---|
| 7 |
START-INFO-DIR-ENTRY |
|---|
| 8 |
* Emacs: (emacs). The extensible self-documenting text editor. |
|---|
| 9 |
END-INFO-DIR-ENTRY |
|---|
| 10 |
|
|---|
| 11 |
Published by the Free Software Foundation 59 Temple Place, Suite 330 |
|---|
| 12 |
Boston, MA 02111-1307 USA |
|---|
| 13 |
|
|---|
| 14 |
Copyright (C) |
|---|
| 15 |
1985,1986,1987,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002 |
|---|
| 16 |
Free Software Foundation, Inc. |
|---|
| 17 |
|
|---|
| 18 |
Permission is granted to copy, distribute and/or modify this document |
|---|
| 19 |
under the terms of the GNU Free Documentation License, Version 1.1 or |
|---|
| 20 |
any later version published by the Free Software Foundation; with the |
|---|
| 21 |
Invariant Sections being "The GNU Manifesto", "Distribution" and "GNU |
|---|
| 22 |
GENERAL PUBLIC LICENSE", with the Front-Cover texts being "A GNU |
|---|
| 23 |
Manual," and with the Back-Cover Texts as in (a) below. A copy of the |
|---|
| 24 |
license is included in the section entitled "GNU Free Documentation |
|---|
| 25 |
License." |
|---|
| 26 |
|
|---|
| 27 |
(a) The FSF's Back-Cover Text is: "You have freedom to copy and |
|---|
| 28 |
modify this GNU Manual, like GNU software. Copies published by the Free |
|---|
| 29 |
Software Foundation raise funds for GNU development." |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
File: emacs, Node: Position Info, Next: Arguments, Prev: Continuation Lines, Up: Basic |
|---|
| 33 |
|
|---|
| 34 |
Cursor Position Information |
|---|
| 35 |
=========================== |
|---|
| 36 |
|
|---|
| 37 |
Here are commands to get information about the size and position of |
|---|
| 38 |
parts of the buffer, and to count lines. |
|---|
| 39 |
|
|---|
| 40 |
`M-x what-page' |
|---|
| 41 |
Display the page number of point, and the line number within the |
|---|
| 42 |
page. |
|---|
| 43 |
|
|---|
| 44 |
`M-x what-line' |
|---|
| 45 |
Display the line number of point in the buffer. |
|---|
| 46 |
|
|---|
| 47 |
`M-x line-number-mode' |
|---|
| 48 |
`M-x column-number-mode' |
|---|
| 49 |
Toggle automatic display of current line number or column number. |
|---|
| 50 |
*Note Optional Mode Line::. |
|---|
| 51 |
|
|---|
| 52 |
`M-=' |
|---|
| 53 |
Display the number of lines in the current region |
|---|
| 54 |
(`count-lines-region'). *Note Mark::, for information about the |
|---|
| 55 |
region. |
|---|
| 56 |
|
|---|
| 57 |
`C-x =' |
|---|
| 58 |
Display the character code of character after point, character |
|---|
| 59 |
position of point, and column of point (`what-cursor-position'). |
|---|
| 60 |
|
|---|
| 61 |
`M-x hl-line-mode' |
|---|
| 62 |
Enable or disable highlighting of the current line. *Note Cursor |
|---|
| 63 |
Display::. |
|---|
| 64 |
|
|---|
| 65 |
There are two commands for working with line numbers. `M-x |
|---|
| 66 |
what-line' computes the current line number and displays it in the echo |
|---|
| 67 |
area. To go to a given line by number, use `M-x goto-line'; it prompts |
|---|
| 68 |
you for the number. These line numbers count from one at the beginning |
|---|
| 69 |
of the buffer. |
|---|
| 70 |
|
|---|
| 71 |
You can also see the current line number in the mode line; see *Note |
|---|
| 72 |
Mode Line::. If you narrow the buffer, then the line number in the |
|---|
| 73 |
mode line is relative to the accessible portion (*note Narrowing::). |
|---|
| 74 |
By contrast, `what-line' shows both the line number relative to the |
|---|
| 75 |
narrowed region and the line number relative to the whole buffer. |
|---|
| 76 |
|
|---|
| 77 |
`M-x what-page' counts pages from the beginning of the file, and |
|---|
| 78 |
counts lines within the page, showing both numbers in the echo area. |
|---|
| 79 |
*Note Pages::. |
|---|
| 80 |
|
|---|
| 81 |
While on this subject, we might as well mention `M-=' |
|---|
| 82 |
(`count-lines-region'), which displays the number of lines in the |
|---|
| 83 |
region (*note Mark::). *Note Pages::, for the command `C-x l' which |
|---|
| 84 |
counts the lines in the current page. |
|---|
| 85 |
|
|---|
| 86 |
The command `C-x =' (`what-cursor-position') can be used to find out |
|---|
| 87 |
the column that the cursor is in, and other miscellaneous information |
|---|
| 88 |
about point. It displays a line in the echo area that looks like this: |
|---|
| 89 |
|
|---|
| 90 |
Char: c (0143, 99, 0x63) point=21044 of 26883(78%) column 53 |
|---|
| 91 |
|
|---|
| 92 |
(In fact, this is the output produced when point is before the `column' |
|---|
| 93 |
in the example.) |
|---|
| 94 |
|
|---|
| 95 |
The four values after `Char:' describe the character that follows |
|---|
| 96 |
point, first by showing it and then by giving its character code in |
|---|
| 97 |
octal, decimal and hex. For a non-ASCII multibyte character, these are |
|---|
| 98 |
followed by `ext' and the character's representation, in hex, in the |
|---|
| 99 |
buffer's coding system, if that coding system encodes the character |
|---|
| 100 |
safely and with a single byte (*note Coding Systems::). If the |
|---|
| 101 |
character's encoding is longer than one byte, Emacs shows `ext ...'. |
|---|
| 102 |
|
|---|
| 103 |
`point=' is followed by the position of point expressed as a |
|---|
| 104 |
character count. The front of the buffer counts as position 1, one |
|---|
| 105 |
character later as 2, and so on. The next, larger, number is the total |
|---|
| 106 |
number of characters in the buffer. Afterward in parentheses comes the |
|---|
| 107 |
position expressed as a percentage of the total size. |
|---|
| 108 |
|
|---|
| 109 |
`column' is followed by the horizontal position of point, in columns |
|---|
| 110 |
from the left edge of the window. |
|---|
| 111 |
|
|---|
| 112 |
If the buffer has been narrowed, making some of the text at the |
|---|
| 113 |
beginning and the end temporarily inaccessible, `C-x =' displays |
|---|
| 114 |
additional text describing the currently accessible range. For |
|---|
| 115 |
example, it might display this: |
|---|
| 116 |
|
|---|
| 117 |
Char: C (0103, 67, 0x43) point=252 of 889(28%) <231 - 599> column 0 |
|---|
| 118 |
|
|---|
| 119 |
where the two extra numbers give the smallest and largest character |
|---|
| 120 |
position that point is allowed to assume. The characters between those |
|---|
| 121 |
two positions are the accessible ones. *Note Narrowing::. |
|---|
| 122 |
|
|---|
| 123 |
If point is at the end of the buffer (or the end of the accessible |
|---|
| 124 |
part), the `C-x =' output does not describe a character after point. |
|---|
| 125 |
The output might look like this: |
|---|
| 126 |
|
|---|
| 127 |
point=26957 of 26956(100%) column 0 |
|---|
| 128 |
|
|---|
| 129 |
`C-u C-x =' displays additional information about a character, in |
|---|
| 130 |
place of the buffer coordinates and column: the character set name and |
|---|
| 131 |
the codes that identify the character within that character set; ASCII |
|---|
| 132 |
characters are identified as belonging to the `ASCII' character set. |
|---|
| 133 |
In addition, the full character encoding, even if it takes more than a |
|---|
| 134 |
single byte, is shown after `ext'. Here's an example for a Latin-1 |
|---|
| 135 |
character A with a grave accent in a buffer whose coding system is |
|---|
| 136 |
iso-2022-7bit(1): |
|---|
| 137 |
|
|---|
| 138 |
Char: A` (04300, 2240, 0x8c0, ext ESC , A @) (latin-iso8859-1 64) |
|---|
| 139 |
|
|---|
| 140 |
In addition, `C-u C-x =' shows the font used to display the character |
|---|
| 141 |
(if the terminal supports more than one font). |
|---|
| 142 |
|
|---|
| 143 |
---------- Footnotes ---------- |
|---|
| 144 |
|
|---|
| 145 |
(1) On terminals that support Latin-1 characters, the character |
|---|
| 146 |
shown after `Char:' is displayed as the actual glyph of A with grave |
|---|
| 147 |
accent. |
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
File: emacs, Node: Arguments, Next: Repeating, Prev: Position Info, Up: Basic |
|---|
| 151 |
|
|---|
| 152 |
Numeric Arguments |
|---|
| 153 |
================= |
|---|
| 154 |
|
|---|
| 155 |
In mathematics and computer usage, the word "argument" means "data |
|---|
| 156 |
provided to a function or operation." You can give any Emacs command a |
|---|
| 157 |
"numeric argument" (also called a "prefix argument"). Some commands |
|---|
| 158 |
interpret the argument as a repetition count. For example, `C-f' with |
|---|
| 159 |
an argument of ten moves forward ten characters instead of one. With |
|---|
| 160 |
these commands, no argument is equivalent to an argument of one. |
|---|
| 161 |
Negative arguments tell most such commands to move or act in the |
|---|
| 162 |
opposite direction. |
|---|
| 163 |
|
|---|
| 164 |
If your terminal keyboard has a <META> key, the easiest way to |
|---|
| 165 |
specify a numeric argument is to type digits and/or a minus sign while |
|---|
| 166 |
holding down the <META> key. For example, |
|---|
| 167 |
|
|---|
| 168 |
M-5 C-n |
|---|
| 169 |
|
|---|
| 170 |
would move down five lines. The characters `Meta-1', `Meta-2', and so |
|---|
| 171 |
on, as well as `Meta--', do this because they are keys bound to |
|---|
| 172 |
commands (`digit-argument' and `negative-argument') that are defined to |
|---|
| 173 |
contribute to an argument for the next command. `Meta--' without |
|---|
| 174 |
digits normally means -1. Digits and `-' modified with Control, or |
|---|
| 175 |
Control and Meta, also specify numeric arguments. |
|---|
| 176 |
|
|---|
| 177 |
Another way of specifying an argument is to use the `C-u' |
|---|
| 178 |
(`universal-argument') command followed by the digits of the argument. |
|---|
| 179 |
With `C-u', you can type the argument digits without holding down |
|---|
| 180 |
modifier keys; `C-u' works on all terminals. To type a negative |
|---|
| 181 |
argument, type a minus sign after `C-u'. Just a minus sign without |
|---|
| 182 |
digits normally means -1. |
|---|
| 183 |
|
|---|
| 184 |
`C-u' followed by a character which is neither a digit nor a minus |
|---|
| 185 |
sign has the special meaning of "multiply by four." It multiplies the |
|---|
| 186 |
argument for the next command by four. `C-u' twice multiplies it by |
|---|
| 187 |
sixteen. Thus, `C-u C-u C-f' moves forward sixteen characters. This |
|---|
| 188 |
is a good way to move forward "fast," since it moves about 1/5 of a line |
|---|
| 189 |
in the usual size screen. Other useful combinations are `C-u C-n', |
|---|
| 190 |
`C-u C-u C-n' (move down a good fraction of a screen), `C-u C-u C-o' |
|---|
| 191 |
(make "a lot" of blank lines), and `C-u C-k' (kill four lines). |
|---|
| 192 |
|
|---|
| 193 |
Some commands care only about whether there is an argument, and not |
|---|
| 194 |
about its value. For example, the command `M-q' (`fill-paragraph') with |
|---|
| 195 |
no argument fills text; with an argument, it justifies the text as well. |
|---|
| 196 |
(*Note Filling::, for more information on `M-q'.) Plain `C-u' is a |
|---|
| 197 |
handy way of providing an argument for such commands. |
|---|
| 198 |
|
|---|
| 199 |
Some commands use the value of the argument as a repeat count, but do |
|---|
| 200 |
something peculiar when there is no argument. For example, the command |
|---|
| 201 |
`C-k' (`kill-line') with argument N kills N lines, including their |
|---|
| 202 |
terminating newlines. But `C-k' with no argument is special: it kills |
|---|
| 203 |
the text up to the next newline, or, if point is right at the end of |
|---|
| 204 |
the line, it kills the newline itself. Thus, two `C-k' commands with |
|---|
| 205 |
no arguments can kill a nonblank line, just like `C-k' with an argument |
|---|
| 206 |
of one. (*Note Killing::, for more information on `C-k'.) |
|---|
| 207 |
|
|---|
| 208 |
A few commands treat a plain `C-u' differently from an ordinary |
|---|
| 209 |
argument. A few others may treat an argument of just a minus sign |
|---|
| 210 |
differently from an argument of -1. These unusual cases are described |
|---|
| 211 |
when they come up; they are always for reasons of convenience of use of |
|---|
| 212 |
the individual command. |
|---|
| 213 |
|
|---|
| 214 |
You can use a numeric argument to insert multiple copies of a |
|---|
| 215 |
character. This is straightforward unless the character is a digit; for |
|---|
| 216 |
example, `C-u 6 4 a' inserts 64 copies of the character `a'. But this |
|---|
| 217 |
does not work for inserting digits; `C-u 6 4 1' specifies an argument |
|---|
| 218 |
of 641, rather than inserting anything. To separate the digit to |
|---|
| 219 |
insert from the argument, type another `C-u'; for example, `C-u 6 4 C-u |
|---|
| 220 |
1' does insert 64 copies of the character `1'. |
|---|
| 221 |
|
|---|
| 222 |
We use the term "prefix argument" as well as "numeric argument" to |
|---|
| 223 |
emphasize that you type the argument before the command, and to |
|---|
| 224 |
distinguish these arguments from minibuffer arguments that come after |
|---|
| 225 |
the command. |
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
File: emacs, Node: Repeating, Prev: Arguments, Up: Basic |
|---|
| 229 |
|
|---|
| 230 |
Repeating a Command |
|---|
| 231 |
=================== |
|---|
| 232 |
|
|---|
| 233 |
Many simple commands, such as those invoked with a single key or |
|---|
| 234 |
with `M-x COMMAND-NAME <RET>', can be repeated by invoking them with a |
|---|
| 235 |
numeric argument that serves as a repeat count (*note Arguments::). |
|---|
| 236 |
However, if the command you want to repeat prompts for some input, or |
|---|
| 237 |
uses a numeric argument in another way, repetition using a numeric |
|---|
| 238 |
argument might be problematical. |
|---|
| 239 |
|
|---|
| 240 |
The command `C-x z' (`repeat') provides another way to repeat an |
|---|
| 241 |
Emacs command many times. This command repeats the previous Emacs |
|---|
| 242 |
command, whatever that was. Repeating a command uses the same arguments |
|---|
| 243 |
that were used before; it does not read new arguments each time. |
|---|
| 244 |
|
|---|
| 245 |
To repeat the command more than once, type additional `z''s: each |
|---|
| 246 |
`z' repeats the command one more time. Repetition ends when you type a |
|---|
| 247 |
character other than `z', or press a mouse button. |
|---|
| 248 |
|
|---|
| 249 |
For example, suppose you type `C-u 2 0 C-d' to delete 20 characters. |
|---|
| 250 |
You can repeat that command (including its argument) three additional |
|---|
| 251 |
times, to delete a total of 80 characters, by typing `C-x z z z'. The |
|---|
| 252 |
first `C-x z' repeats the command once, and each subsequent `z' repeats |
|---|
| 253 |
it once again. |
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
File: emacs, Node: Minibuffer, Next: M-x, Prev: Basic, Up: Top |
|---|
| 257 |
|
|---|
| 258 |
The Minibuffer |
|---|
| 259 |
************** |
|---|
| 260 |
|
|---|
| 261 |
The "minibuffer" is the facility used by Emacs commands to read |
|---|
| 262 |
arguments more complicated than a single number. Minibuffer arguments |
|---|
| 263 |
can be file names, buffer names, Lisp function names, Emacs command |
|---|
| 264 |
names, Lisp expressions, and many other things, depending on the command |
|---|
| 265 |
reading the argument. You can use the usual Emacs editing commands in |
|---|
| 266 |
the minibuffer to edit the argument text. |
|---|
| 267 |
|
|---|
| 268 |
When the minibuffer is in use, it appears in the echo area, and the |
|---|
| 269 |
terminal's cursor moves there. The beginning of the minibuffer line |
|---|
| 270 |
displays a "prompt" which says what kind of input you should supply and |
|---|
| 271 |
how it will be used. Often this prompt is derived from the name of the |
|---|
| 272 |
command that the argument is for. The prompt normally ends with a |
|---|
| 273 |
colon. |
|---|
| 274 |
|
|---|
| 275 |
Sometimes a "default argument" appears in parentheses after the |
|---|
| 276 |
colon; it too is part of the prompt. The default will be used as the |
|---|
| 277 |
argument value if you enter an empty argument (that is, just type |
|---|
| 278 |
<RET>). For example, commands that read buffer names always show a |
|---|
| 279 |
default, which is the name of the buffer that will be used if you type |
|---|
| 280 |
just <RET>. |
|---|
| 281 |
|
|---|
| 282 |
The simplest way to enter a minibuffer argument is to type the text |
|---|
| 283 |
you want, terminated by <RET> which exits the minibuffer. You can |
|---|
| 284 |
cancel the command that wants the argument, and get out of the |
|---|
| 285 |
minibuffer, by typing `C-g'. |
|---|
| 286 |
|
|---|
| 287 |
Since the minibuffer uses the screen space of the echo area, it can |
|---|
| 288 |
conflict with other ways Emacs customarily uses the echo area. Here is |
|---|
| 289 |
how Emacs handles such conflicts: |
|---|
| 290 |
|
|---|
| 291 |
* If a command gets an error while you are in the minibuffer, this |
|---|
| 292 |
does not cancel the minibuffer. However, the echo area is needed |
|---|
| 293 |
for the error message and therefore the minibuffer itself is |
|---|
| 294 |
hidden for a while. It comes back after a few seconds, or as soon |
|---|
| 295 |
as you type anything. |
|---|
| 296 |
|
|---|
| 297 |
* If in the minibuffer you use a command whose purpose is to display |
|---|
| 298 |
a message in the echo area, such as `C-x =', the message hides the |
|---|
| 299 |
minibuffer for a while. The minibuffer contents come back after a |
|---|
| 300 |
few seconds, or as soon as you type anything. |
|---|
| 301 |
|
|---|
| 302 |
* Echoing of keystrokes does not take place while the minibuffer is |
|---|
| 303 |
in use. |
|---|
| 304 |
|
|---|
| 305 |
* Menu: |
|---|
| 306 |
|
|---|
| 307 |
* File: Minibuffer File. Entering file names with the minibuffer. |
|---|
| 308 |
* Edit: Minibuffer Edit. How to edit in the minibuffer. |
|---|
| 309 |
* Completion:: An abbreviation facility for minibuffer input. |
|---|
| 310 |
* Minibuffer History:: Reusing recent minibuffer arguments. |
|---|
| 311 |
* Repetition:: Re-executing commands that used the minibuffer. |
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
File: emacs, Node: Minibuffer File, Next: Minibuffer Edit, Up: Minibuffer |
|---|
| 315 |
|
|---|
| 316 |
Minibuffers for File Names |
|---|
| 317 |
========================== |
|---|
| 318 |
|
|---|
| 319 |
Sometimes the minibuffer starts out with text in it. For example, |
|---|
| 320 |
when you are supposed to give a file name, the minibuffer starts out |
|---|
| 321 |
containing the "default directory", which ends with a slash. This is |
|---|
| 322 |
to inform you which directory the file will be found in if you do not |
|---|
| 323 |
specify a directory. |
|---|
| 324 |
|
|---|
| 325 |
For example, the minibuffer might start out with these contents: |
|---|
| 326 |
|
|---|
| 327 |
Find File: /u2/emacs/src/ |
|---|
| 328 |
|
|---|
| 329 |
where `Find File: ' is the prompt. Typing `buffer.c' specifies the |
|---|
| 330 |
file `/u2/emacs/src/buffer.c'. To find files in nearby directories, |
|---|
| 331 |
use `..'; thus, if you type `../lisp/simple.el', you will get the file |
|---|
| 332 |
named `/u2/emacs/lisp/simple.el'. Alternatively, you can kill with |
|---|
| 333 |
`M-<DEL>' the directory names you don't want (*note Words::). |
|---|
| 334 |
|
|---|
| 335 |
If you don't want any of the default, you can kill it with `C-a |
|---|
| 336 |
C-k'. But you don't need to kill the default; you can simply ignore it. |
|---|
| 337 |
Insert an absolute file name, one starting with a slash or a tilde, |
|---|
| 338 |
after the default directory. For example, to specify the file |
|---|
| 339 |
`/etc/termcap', just insert that name, giving these minibuffer contents: |
|---|
| 340 |
|
|---|
| 341 |
Find File: /u2/emacs/src//etc/termcap |
|---|
| 342 |
|
|---|
| 343 |
GNU Emacs gives a special meaning to a double slash (which is not |
|---|
| 344 |
normally a useful thing to write): it means, "ignore everything before |
|---|
| 345 |
the second slash in the pair." Thus, `/u2/emacs/src/' is ignored in |
|---|
| 346 |
the example above, and you get the file `/etc/termcap'. |
|---|
| 347 |
|
|---|
| 348 |
If you set `insert-default-directory' to `nil', the default |
|---|
| 349 |
directory is not inserted in the minibuffer. This way, the minibuffer |
|---|
| 350 |
starts out empty. But the name you type, if relative, is still |
|---|
| 351 |
interpreted with respect to the same default directory. |
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
File: emacs, Node: Minibuffer Edit, Next: Completion, Prev: Minibuffer File, Up: Minibuffer |
|---|
| 355 |
|
|---|
| 356 |
Editing in the Minibuffer |
|---|
| 357 |
========================= |
|---|
| 358 |
|
|---|
| 359 |
The minibuffer is an Emacs buffer (albeit a peculiar one), and the |
|---|
| 360 |
usual Emacs commands are available for editing the text of an argument |
|---|
| 361 |
you are entering. |
|---|
| 362 |
|
|---|
| 363 |
Since <RET> in the minibuffer is defined to exit the minibuffer, you |
|---|
| 364 |
can't use it to insert a newline in the minibuffer. To do that, type |
|---|
| 365 |
`C-o' or `C-q C-j'. (Recall that a newline is really the character |
|---|
| 366 |
control-J.) |
|---|
| 367 |
|
|---|
| 368 |
The minibuffer has its own window which always has space on the |
|---|
| 369 |
screen but acts as if it were not there when the minibuffer is not in |
|---|
| 370 |
use. When the minibuffer is in use, its window is just like the |
|---|
| 371 |
others; you can switch to another window with `C-x o', edit text in |
|---|
| 372 |
other windows and perhaps even visit more files, before returning to |
|---|
| 373 |
the minibuffer to submit the argument. You can kill text in another |
|---|
| 374 |
window, return to the minibuffer window, and then yank the text to use |
|---|
| 375 |
it in the argument. *Note Windows::. |
|---|
| 376 |
|
|---|
| 377 |
There are some restrictions on the use of the minibuffer window, |
|---|
| 378 |
however. You cannot switch buffers in it--the minibuffer and its |
|---|
| 379 |
window are permanently attached. Also, you cannot split or kill the |
|---|
| 380 |
minibuffer window. But you can make it taller in the normal fashion |
|---|
| 381 |
with `C-x ^'. |
|---|
| 382 |
|
|---|
| 383 |
The minibuffer window expands vertically as necessary to hold the |
|---|
| 384 |
text that you put in the minibuffer, if `resize-mini-windows' is |
|---|
| 385 |
non-`nil'. If `resize-mini-windows' is `t', the window is always |
|---|
| 386 |
resized to fit the size of the text it displays. If |
|---|
| 387 |
`resize-mini-windows' is the symbol `grow-only', the window grows when |
|---|
| 388 |
the size of displayed text increases, but shrinks (back to the normal |
|---|
| 389 |
size) only when the minibuffer becomes inactive. |
|---|
| 390 |
|
|---|
| 391 |
The variable `max-mini-window-height' controls the maximum height |
|---|
| 392 |
for resizing the minibuffer window: a floating-point number specifies a |
|---|
| 393 |
fraction of the frame's height; an integer specifies the maximum number |
|---|
| 394 |
of lines; `nil' means do not resize the minibuffer window |
|---|
| 395 |
automatically. The default value is 0.25. |
|---|
| 396 |
|
|---|
| 397 |
If while in the minibuffer you issue a command that displays help |
|---|
| 398 |
text of any sort in another window, you can use the `C-M-v' command |
|---|
| 399 |
while in the minibuffer to scroll the help text. This lasts until you |
|---|
| 400 |
exit the minibuffer. This feature is especially useful when you display |
|---|
| 401 |
a buffer listing possible completions. *Note Other Window::. |
|---|
| 402 |
|
|---|
| 403 |
Emacs normally disallows most commands that use the minibuffer while |
|---|
| 404 |
the minibuffer is active. This rule is to prevent recursive minibuffers |
|---|
| 405 |
from confusing novice users. If you want to be able to use such |
|---|
| 406 |
commands in the minibuffer, set the variable |
|---|
| 407 |
`enable-recursive-minibuffers' to a non-`nil' value. |
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 |
File: emacs, Node: Completion, Next: Minibuffer History, Prev: Minibuffer Edit, Up: Minibuffer |
|---|
| 411 |
|
|---|
| 412 |
Completion |
|---|
| 413 |
========== |
|---|
| 414 |
|
|---|
| 415 |
For certain kinds of arguments, you can use "completion" to enter |
|---|
| 416 |
the argument value. Completion means that you type part of the |
|---|
| 417 |
argument, then Emacs visibly fills in the rest, or as much as can be |
|---|
| 418 |
determined from the part you have typed. |
|---|
| 419 |
|
|---|
| 420 |
When completion is available, certain keys--<TAB>, <RET>, and |
|---|
| 421 |
<SPC>--are rebound to complete the text present in the minibuffer into |
|---|
| 422 |
a longer string that it stands for, by matching it against a set of |
|---|
| 423 |
"completion alternatives" provided by the command reading the argument. |
|---|
| 424 |
`?' is defined to display a list of possible completions of what you |
|---|
| 425 |
have inserted. |
|---|
| 426 |
|
|---|
| 427 |
For example, when `M-x' uses the minibuffer to read the name of a |
|---|
| 428 |
command, it provides a list of all available Emacs command names to |
|---|
| 429 |
complete against. The completion keys match the text in the minibuffer |
|---|
| 430 |
against all the command names, find any additional name characters |
|---|
| 431 |
implied by the ones already present in the minibuffer, and add those |
|---|
| 432 |
characters to the ones you have given. This is what makes it possible |
|---|
| 433 |
to type `M-x ins <SPC> b <RET>' instead of `M-x insert-buffer <RET>' |
|---|
| 434 |
(for example). |
|---|
| 435 |
|
|---|
| 436 |
Case is normally significant in completion, because it is significant |
|---|
| 437 |
in most of the names that you can complete (buffer names, file names and |
|---|
| 438 |
command names). Thus, `fo' does not complete to `Foo'. Completion |
|---|
| 439 |
does ignore case distinctions for certain arguments in which case does |
|---|
| 440 |
not matter. |
|---|
| 441 |
|
|---|
| 442 |
* Menu: |
|---|
| 443 |
|
|---|
| 444 |
* Example: Completion Example. |
|---|
| 445 |
* Commands: Completion Commands. |
|---|
| 446 |
* Strict Completion:: |
|---|
| 447 |
* Options: Completion Options. |
|---|
| 448 |
|
|---|
| 449 |
|
|---|
| 450 |
File: emacs, Node: Completion Example, Next: Completion Commands, Up: Completion |
|---|
| 451 |
|
|---|
| 452 |
Completion Example |
|---|
| 453 |
------------------ |
|---|
| 454 |
|
|---|
| 455 |
A concrete example may help here. If you type `M-x au <TAB>', the |
|---|
| 456 |
<TAB> looks for alternatives (in this case, command names) that start |
|---|
| 457 |
with `au'. There are several, including `auto-fill-mode' and |
|---|
| 458 |
`auto-save-mode'--but they are all the same as far as `auto-', so the |
|---|
| 459 |
`au' in the minibuffer changes to `auto-'. |
|---|
| 460 |
|
|---|
| 461 |
If you type <TAB> again immediately, there are multiple |
|---|
| 462 |
possibilities for the very next character--it could be any of |
|---|
| 463 |
`cfilrs'--so no more characters are added; instead, <TAB> displays a |
|---|
| 464 |
list of all possible completions in another window. |
|---|
| 465 |
|
|---|
| 466 |
If you go on to type `f <TAB>', this <TAB> sees `auto-f'. The only |
|---|
| 467 |
command name starting this way is `auto-fill-mode', so completion fills |
|---|
| 468 |
in the rest of that. You now have `auto-fill-mode' in the minibuffer |
|---|
| 469 |
after typing just `au <TAB> f <TAB>'. Note that <TAB> has this effect |
|---|
| 470 |
because in the minibuffer it is bound to the command |
|---|
| 471 |
`minibuffer-complete' when completion is available. |
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
File: emacs, Node: Completion Commands, Next: Strict Completion, Prev: Completion Example, Up: Completion |
|---|
| 475 |
|
|---|
| 476 |
Completion Commands |
|---|
| 477 |
------------------- |
|---|
| 478 |
|
|---|
| 479 |
Here is a list of the completion commands defined in the minibuffer |
|---|
| 480 |
when completion is available. |
|---|
| 481 |
|
|---|
| 482 |
`<TAB>' |
|---|
| 483 |
Complete the text in the minibuffer as much as possible |
|---|
| 484 |
(`minibuffer-complete'). |
|---|
| 485 |
|
|---|
| 486 |
`<SPC>' |
|---|
| 487 |
Complete the minibuffer text, but don't go beyond one word |
|---|
| 488 |
(`minibuffer-complete-word'). |
|---|
| 489 |
|
|---|
| 490 |
`<RET>' |
|---|
| 491 |
Submit the text in the minibuffer as the argument, possibly |
|---|
| 492 |
completing first as described below |
|---|
| 493 |
(`minibuffer-complete-and-exit'). |
|---|
| 494 |
|
|---|
| 495 |
`?' |
|---|
| 496 |
Display a list of all possible completions of the text in the |
|---|
| 497 |
minibuffer (`minibuffer-list-completions'). |
|---|
| 498 |
|
|---|
| 499 |
<SPC> completes much like <TAB>, but never goes beyond the next |
|---|
| 500 |
hyphen or space. If you have `auto-f' in the minibuffer and type |
|---|
| 501 |
<SPC>, it finds that the completion is `auto-fill-mode', but it stops |
|---|
| 502 |
completing after `fill-'. This gives `auto-fill-'. Another <SPC> at |
|---|
| 503 |
this point completes all the way to `auto-fill-mode'. The command that |
|---|
| 504 |
implements this behavior is called `minibuffer-complete-word'. |
|---|
| 505 |
|
|---|
| 506 |
Here are some commands you can use to choose a completion from a |
|---|
| 507 |
window that displays a list of completions: |
|---|
| 508 |
|
|---|
| 509 |
`Mouse-2' |
|---|
| 510 |
Clicking mouse button 2 on a completion in the list of possible |
|---|
| 511 |
completions chooses that completion (`mouse-choose-completion'). |
|---|
| 512 |
You normally use this command while point is in the minibuffer, |
|---|
| 513 |
but you must click in the list of completions, not in the |
|---|
| 514 |
minibuffer itself. |
|---|
| 515 |
|
|---|
| 516 |
`<PRIOR>' |
|---|
| 517 |
`M-v' |
|---|
| 518 |
Typing <PRIOR> or <PAGE-UP>, or `M-v', while in the minibuffer, |
|---|
| 519 |
selects the window showing the completion list buffer |
|---|
| 520 |
(`switch-to-completions'). This paves the way for using the |
|---|
| 521 |
commands below. (Selecting that window in the usual ways has the |
|---|
| 522 |
same effect, but this way is more convenient.) |
|---|
| 523 |
|
|---|
| 524 |
`<RET>' |
|---|
| 525 |
Typing <RET> _in the completion list buffer_ chooses the |
|---|
| 526 |
completion that point is in or next to (`choose-completion'). To |
|---|
| 527 |
use this command, you must first switch windows to the window that |
|---|
| 528 |
shows the list of completions. |
|---|
| 529 |
|
|---|
| 530 |
`<RIGHT>' |
|---|
| 531 |
Typing the right-arrow key <RIGHT> _in the completion list buffer_ |
|---|
| 532 |
moves point to the following completion (`next-completion'). |
|---|
| 533 |
|
|---|
| 534 |
`<LEFT>' |
|---|
| 535 |
Typing the left-arrow key <LEFT> _in the completion list buffer_ |
|---|
| 536 |
moves point toward the beginning of the buffer, to the previous |
|---|
| 537 |
completion (`previous-completion'). |
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
File: emacs, Node: Strict Completion, Next: Completion Options, Prev: Completion Commands, Up: Completion |
|---|
| 541 |
|
|---|
| 542 |
Strict Completion |
|---|
| 543 |
----------------- |
|---|
| 544 |
|
|---|
| 545 |
There are three different ways that <RET> can work in completing |
|---|
| 546 |
minibuffers, depending on how the argument will be used. |
|---|
| 547 |
|
|---|
| 548 |
* "Strict" completion is used when it is meaningless to give any |
|---|
| 549 |
argument except one of the known alternatives. For example, when |
|---|
| 550 |
`C-x k' reads the name of a buffer to kill, it is meaningless to |
|---|
| 551 |
give anything but the name of an existing buffer. In strict |
|---|
| 552 |
completion, <RET> refuses to exit if the text in the minibuffer |
|---|
| 553 |
does not complete to an exact match. |
|---|
| 554 |
|
|---|
| 555 |
* "Cautious" completion is similar to strict completion, except that |
|---|
| 556 |
<RET> exits only if the text was an exact match already, not |
|---|
| 557 |
needing completion. If the text is not an exact match, <RET> does |
|---|
| 558 |
not exit, but it does complete the text. If it completes to an |
|---|
| 559 |
exact match, a second <RET> will exit. |
|---|
| 560 |
|
|---|
| 561 |
Cautious completion is used for reading file names for files that |
|---|
| 562 |
must already exist. |
|---|
| 563 |
|
|---|
| 564 |
* "Permissive" completion is used when any string whatever is |
|---|
| 565 |
meaningful, and the list of completion alternatives is just a |
|---|
| 566 |
guide. For example, when `C-x C-f' reads the name of a file to |
|---|
| 567 |
visit, any file name is allowed, in case you want to create a |
|---|
| 568 |
file. In permissive completion, <RET> takes the text in the |
|---|
| 569 |
minibuffer exactly as given, without completing it. |
|---|
| 570 |
|
|---|
| 571 |
The completion commands display a list of all possible completions in |
|---|
| 572 |
a window whenever there is more than one possibility for the very next |
|---|
| 573 |
character. Also, typing `?' explicitly requests such a list. If the |
|---|
| 574 |
list of completions is long, you can scroll it with `C-M-v' (*note |
|---|
| 575 |
Other Window::). |
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 |
File: emacs, Node: Completion Options, Prev: Strict Completion, Up: Completion |
|---|
| 579 |
|
|---|
| 580 |
Completion Options |
|---|
| 581 |
------------------ |
|---|
| 582 |
|
|---|
| 583 |
When completion is done on file names, certain file names are usually |
|---|
| 584 |
ignored. The variable `completion-ignored-extensions' contains a list |
|---|
| 585 |
of strings; a file whose name ends in any of those strings is ignored |
|---|
| 586 |
as a possible completion. The standard value of this variable has |
|---|
| 587 |
several elements including `".o"', `".elc"', `".dvi"' and `"~"'. The |
|---|
| 588 |
effect is that, for example, `foo' can complete to `foo.c' even though |
|---|
| 589 |
`foo.o' exists as well. However, if _all_ the possible completions end |
|---|
| 590 |
in "ignored" strings, then they are not ignored. Ignored extensions do |
|---|
| 591 |
not apply to lists of completions--those always mention all possible |
|---|
| 592 |
completions. |
|---|
| 593 |
|
|---|
| 594 |
Normally, a completion command that cannot determine even one |
|---|
| 595 |
additional character automatically displays a list of all possible |
|---|
| 596 |
completions. If the variable `completion-auto-help' is set to `nil', |
|---|
| 597 |
this automatic display is disabled, so you must type `?' to display the |
|---|
| 598 |
list of completions. |
|---|
| 599 |
|
|---|
| 600 |
Partial Completion mode implements a more powerful kind of |
|---|
| 601 |
completion that can complete multiple words in parallel. For example, |
|---|
| 602 |
it can complete the command name abbreviation `p-b' into |
|---|
| 603 |
`print-buffer', because no other command starts with two words whose |
|---|
| 604 |
initials are `p' and `b'. |
|---|
| 605 |
|
|---|
| 606 |
Partial completion of directories in file names uses `*' to indicate |
|---|
| 607 |
the places for completion; thus, `/u*/b*/f*' might complete to |
|---|
| 608 |
`/usr/bin/foo'. |
|---|
| 609 |
|
|---|
| 610 |
To enable this mode, use the command `M-x partial-completion-mode', |
|---|
| 611 |
or customize the option `partial-completion-mode'. This binds the |
|---|
| 612 |
partial completion commands to <TAB>, <SPC>, <RET>, and `?'. The usual |
|---|
| 613 |
completion commands are available on `M-<TAB>', `M-<SPC>', `M-<RET>' |
|---|
| 614 |
and `M-?'. |
|---|
| 615 |
|
|---|
| 616 |
Another feature of Partial Completion mode is to extend `find-file' |
|---|
| 617 |
so that the `<INCLUDE>' stands for the file named INCLUDE in some |
|---|
| 618 |
directory in the path `PC-include-file-path'. If you set |
|---|
| 619 |
`PC-disable-includes' to non-`nil', this feature is disabled. |
|---|
| 620 |
|
|---|
| 621 |
Icomplete mode presents a constantly-updated display that tells you |
|---|
| 622 |
what completions are available for the text you've entered so far. The |
|---|
| 623 |
command to enable or disable this minor mode is `M-x icomplete-mode'. |
|---|
| 624 |
|
|---|
| 625 |
|
|---|
| 626 |
File: emacs, Node: Minibuffer History, Next: Repetition, Prev: Completion, Up: Minibuffer |
|---|
| 627 |
|
|---|
| 628 |
Minibuffer History |
|---|
| 629 |
================== |
|---|
| 630 |
|
|---|
| 631 |
Every argument that you enter with the minibuffer is saved on a |
|---|
| 632 |
"minibuffer history list" so that you can use it again later in another |
|---|
| 633 |
argument. Special commands load the text of an earlier argument in the |
|---|
| 634 |
minibuffer. They discard the old minibuffer contents, so you can think |
|---|
| 635 |
of them as moving through the history of previous arguments. |
|---|
| 636 |
|
|---|
| 637 |
`<UP>' |
|---|
| 638 |
`M-p' |
|---|
| 639 |
Move to the next earlier argument string saved in the minibuffer |
|---|
| 640 |
history (`previous-history-element'). |
|---|
| 641 |
|
|---|
| 642 |
`<DOWN>' |
|---|
| 643 |
`M-n' |
|---|
| 644 |
Move to the next later argument string saved in the minibuffer |
|---|
| 645 |
history (`next-history-element'). |
|---|
| 646 |
|
|---|
| 647 |
`M-r REGEXP <RET>' |
|---|
| 648 |
Move to an earlier saved argument in the minibuffer history that |
|---|
| 649 |
has a match for REGEXP (`previous-matching-history-element'). |
|---|
| 650 |
|
|---|
| 651 |
`M-s REGEXP <RET>' |
|---|
| 652 |
Move to a later saved argument in the minibuffer history that has a |
|---|
| 653 |
match for REGEXP (`next-matching-history-element'). |
|---|
| 654 |
|
|---|
| 655 |
The simplest way to reuse the saved arguments in the history list is |
|---|
| 656 |
to move through the history list one element at a time. While in the |
|---|
| 657 |
minibuffer, use `M-p' or up-arrow (`previous-history-element') to "move |
|---|
| 658 |
to" the next earlier minibuffer input, and use `M-n' or down-arrow |
|---|
| 659 |
(`next-history-element') to "move to" the next later input. |
|---|
| 660 |
|
|---|
| 661 |
The previous input that you fetch from the history entirely replaces |
|---|
| 662 |
the contents of the minibuffer. To use it as the argument, exit the |
|---|
| 663 |
minibuffer as usual with <RET>. You can also edit the text before you |
|---|
| 664 |
reuse it; this does not change the history element that you "moved" to, |
|---|
| 665 |
but your new argument does go at the end of the history list in its own |
|---|
| 666 |
right. |
|---|
| 667 |
|
|---|
| 668 |
For many minibuffer arguments there is a "default" value. In some |
|---|
| 669 |
cases, the minibuffer history commands know the default value. Then you |
|---|
| 670 |
can insert the default value into the minibuffer as text by using `M-n' |
|---|
| 671 |
to move "into the future" in the history. Eventually we hope to make |
|---|
| 672 |
this feature available whenever the minibuffer has a default value. |
|---|
| 673 |
|
|---|
| 674 |
There are also commands to search forward or backward through the |
|---|
| 675 |
history; they search for history elements that match a regular |
|---|
| 676 |
expression that you specify with the minibuffer. `M-r' |
|---|
| 677 |
(`previous-matching-history-element') searches older elements in the |
|---|
| 678 |
history, while `M-s' (`next-matching-history-element') searches newer |
|---|
| 679 |
elements. By special dispensation, these commands can use the |
|---|
| 680 |
minibuffer to read their arguments even though you are already in the |
|---|
| 681 |
minibuffer when you issue them. As with incremental searching, an |
|---|
| 682 |
upper-case letter in the regular expression makes the search |
|---|
| 683 |
case-sensitive (*note Search Case::). |
|---|
| 684 |
|
|---|
| 685 |
All uses of the minibuffer record your input on a history list, but |
|---|
| 686 |
there are separate history lists for different kinds of arguments. For |
|---|
| 687 |
example, there is a list for file names, used by all the commands that |
|---|
| 688 |
read file names. (As a special feature, this history list records the |
|---|
| 689 |
absolute file name, no more and no less, even if that is not how you |
|---|
| 690 |
entered the file name.) |
|---|
| 691 |
|
|---|
| 692 |
There are several other very specific history lists, including one |
|---|
| 693 |
for command names read by `M-x', one for buffer names, one for arguments |
|---|
| 694 |
of commands like `query-replace', and one for compilation commands read |
|---|
| 695 |
by `compile'. Finally, there is one "miscellaneous" history list that |
|---|
| 696 |
most minibuffer arguments use. |
|---|
| 697 |
|
|---|
| 698 |
The variable `history-length' specifies the maximum length of a |
|---|
| 699 |
minibuffer history list; once a list gets that long, the oldest element |
|---|
| 700 |
is deleted each time an element is added. If the value of |
|---|
| 701 |
`history-length' is `t', though, there is no maximum length and |
|---|
| 702 |
elements are never deleted. |
|---|
| 703 |
|
|---|
| 704 |
|
|---|
| 705 |
File: emacs, Node: Repetition, Prev: Minibuffer History, Up: Minibuffer |
|---|
| 706 |
|
|---|
| 707 |
Repeating Minibuffer Commands |
|---|
| 708 |
============================= |
|---|
| 709 |
|
|---|
| 710 |
Every command that uses the minibuffer at least once is recorded on a |
|---|
| 711 |
special history list, together with the values of its arguments, so that |
|---|
| 712 |
you can repeat the entire command. In particular, every use of `M-x' |
|---|
| 713 |
is recorded there, since `M-x' uses the minibuffer to read the command |
|---|
| 714 |
name. |
|---|
| 715 |
|
|---|
| 716 |
`C-x <ESC> <ESC>' |
|---|
| 717 |
Re-execute a recent minibuffer command (`repeat-complex-command'). |
|---|
| 718 |
|
|---|
| 719 |
`M-x list-command-history' |
|---|
| 720 |
Display the entire command history, showing all the commands `C-x |
|---|
| 721 |
<ESC> <ESC>' can repeat, most recent first. |
|---|
| 722 |
|
|---|
| 723 |
`C-x <ESC> <ESC>' is used to re-execute a recent minibuffer-using |
|---|
| 724 |
command. With no argument, it repeats the last such command. A |
|---|
| 725 |
numeric argument specifies which command to repeat; one means the last |
|---|
| 726 |
one, and larger numbers specify earlier ones. |
|---|
| 727 |
|
|---|
| 728 |
`C-x <ESC> <ESC>' works by turning the previous command into a Lisp |
|---|
| 729 |
expression and then entering a minibuffer initialized with the text for |
|---|
| 730 |
that expression. If you type just <RET>, the command is repeated as |
|---|
| 731 |
before. You can also change the command by editing the Lisp |
|---|
| 732 |
expression. Whatever expression you finally submit is what will be |
|---|
| 733 |
executed. The repeated command is added to the front of the command |
|---|
| 734 |
history unless it is identical to the most recently executed command |
|---|
| 735 |
already there. |
|---|
| 736 |
|
|---|
| 737 |
Even if you don't understand Lisp syntax, it will probably be obvious |
|---|
| 738 |
which command is displayed for repetition. If you do not change the |
|---|
| 739 |
text, it will repeat exactly as before. |
|---|
| 740 |
|
|---|
| 741 |
Once inside the minibuffer for `C-x <ESC> <ESC>', you can use the |
|---|
| 742 |
minibuffer history commands (`M-p', `M-n', `M-r', `M-s'; *note |
|---|
| 743 |
Minibuffer History::) to move through the history list of saved entire |
|---|
| 744 |
commands. After finding the desired previous command, you can edit its |
|---|
| 745 |
expression as usual and then resubmit it by typing <RET> as usual. |
|---|
| 746 |
|
|---|
| 747 |
The list of previous minibuffer-using commands is stored as a Lisp |
|---|
| 748 |
list in the variable `command-history'. Each element is a Lisp |
|---|
| 749 |
expression which describes one command and its arguments. Lisp programs |
|---|
| 750 |
can re-execute a command by calling `eval' with the `command-history' |
|---|
| 751 |
element. |
|---|
| 752 |
|
|---|
| 753 |
|
|---|
| 754 |
File: emacs, Node: M-x, Next: Help, Prev: Minibuffer, Up: Top |
|---|
| 755 |
|
|---|
| 756 |
Running Commands by Name |
|---|
| 757 |
************************ |
|---|
| 758 |
|
|---|
| 759 |
Every Emacs command has a name that you can use to run it. Commands |
|---|
| 760 |
that are used often, or that must be quick to type, are also bound to |
|---|
| 761 |
keys--short sequences of characters--for convenient use. You can run |
|---|
| 762 |
them by name if you don't remember the keys. Other Emacs commands that |
|---|
| 763 |
do not need to be quick are not bound to keys; the only way to run them |
|---|
| 764 |
is by name. *Note Key Bindings::, for the description of how to bind |
|---|
| 765 |
commands to keys. |
|---|
| 766 |
|
|---|
| 767 |
By convention, a command name consists of one or more words, |
|---|
| 768 |
separated by hyphens; for example, `auto-fill-mode' or `manual-entry'. |
|---|
| 769 |
The use of English words makes the command name easier to remember than |
|---|
| 770 |
a key made up of obscure characters, even though it is more characters |
|---|
| 771 |
to type. |
|---|
| 772 |
|
|---|
| 773 |
The way to run a command by name is to start with `M-x', type the |
|---|
| 774 |
command name, and finish it with <RET>. `M-x' uses the minibuffer to |
|---|
| 775 |
read the command name. <RET> exits the minibuffer and runs the |
|---|
| 776 |
command. The string `M-x' appears at the beginning of the minibuffer |
|---|
| 777 |
as a "prompt" to remind you to enter the name of a command to be run. |
|---|
| 778 |
*Note Minibuffer::, for full information on the features of the |
|---|
| 779 |
minibuffer. |
|---|
| 780 |
|
|---|
| 781 |
You can use completion to enter the command name. For example, you |
|---|
| 782 |
can invoke the command `forward-char' by name by typing either |
|---|
| 783 |
|
|---|
| 784 |
M-x forward-char <RET> |
|---|
| 785 |
|
|---|
| 786 |
or |
|---|
| 787 |
|
|---|
| 788 |
M-x forw <TAB> c <RET> |
|---|
| 789 |
|
|---|
| 790 |
Note that `forward-char' is the same command that you invoke with the |
|---|
| 791 |
key `C-f'. You can run any Emacs command by name using `M-x', whether |
|---|
| 792 |
or not any keys are bound to it. |
|---|
| 793 |
|
|---|
| 794 |
If you type `C-g' while the command name is being read, you cancel |
|---|
| 795 |
the `M-x' command and get out of the minibuffer, ending up at top level. |
|---|
| 796 |
|
|---|
| 797 |
To pass a numeric argument to the command you are invoking with |
|---|
| 798 |
`M-x', specify the numeric argument before the `M-x'. `M-x' passes the |
|---|
| 799 |
argument along to the command it runs. The argument value appears in |
|---|
| 800 |
the prompt while the command name is being read. |
|---|
| 801 |
|
|---|
| 802 |
If the command you type has a key binding of its own, Emacs mentions |
|---|
| 803 |
this in the echo area, two seconds after the command finishes (if you |
|---|
| 804 |
don't type anything else first). For example, if you type `M-x |
|---|
| 805 |
forward-word', the message says that you can run the same command more |
|---|
| 806 |
easily by typing `M-f'. You can turn off these messages by setting |
|---|
| 807 |
`suggest-key-bindings' to `nil'. |
|---|
| 808 |
|
|---|
| 809 |
Normally, when describing in this manual a command that is run by |
|---|
| 810 |
name, we omit the <RET> that is needed to terminate the name. Thus we |
|---|
| 811 |
might speak of `M-x auto-fill-mode' rather than `M-x auto-fill-mode |
|---|
| 812 |
<RET>'. We mention the <RET> only when there is a need to emphasize |
|---|
| 813 |
its presence, such as when we show the command together with following |
|---|
| 814 |
arguments. |
|---|
| 815 |
|
|---|
| 816 |
`M-x' works by running the command `execute-extended-command', which |
|---|
| 817 |
is responsible for reading the name of another command and invoking it. |
|---|
| 818 |
|
|---|
| 819 |
|
|---|
| 820 |
File: emacs, Node: Help, Next: Mark, Prev: M-x, Up: Top |
|---|
| 821 |
|
|---|
| 822 |
Help |
|---|
| 823 |
**** |
|---|
| 824 |
|
|---|
| 825 |
Emacs provides extensive help features accessible through a single |
|---|
| 826 |
character, `C-h'. `C-h' is a prefix key that is used for commands that |
|---|
| 827 |
display documentation. The characters that you can type after `C-h' |
|---|
| 828 |
are called "help options". One help option is `C-h'; that is how you |
|---|
| 829 |
ask for help about using `C-h'. To cancel, type `C-g'. The function |
|---|
| 830 |
key <F1> is equivalent to `C-h'. |
|---|
| 831 |
|
|---|
| 832 |
`C-h C-h' (`help-for-help') displays a list of the possible help |
|---|
| 833 |
options, each with a brief description. Before you type a help option, |
|---|
| 834 |
you can use <SPC> or <DEL> to scroll through the list. |
|---|
| 835 |
|
|---|
| 836 |
`C-h' or <F1> means "help" in various other contexts as well. For |
|---|
| 837 |
example, in the middle of `query-replace', it describes the options |
|---|
| 838 |
available for how to operate on the current match. After a prefix key, |
|---|
| 839 |
it displays a list of the alternatives that can follow the prefix key. |
|---|
| 840 |
(A few prefix keys don't support `C-h', because they define other |
|---|
| 841 |
meanings for it, but they all support <F1>.) |
|---|
| 842 |
|
|---|
| 843 |
Most help buffers use a special major mode, Help mode, which lets you |
|---|
| 844 |
scroll conveniently with <SPC> and <DEL>. It also offers hyperlinks to |
|---|
| 845 |
further help regarding cross-referenced names, Info nodes, |
|---|
| 846 |
customization buffers and the like. *Note Help Mode::. |
|---|
| 847 |
|
|---|
| 848 |
If you are looking for a certain feature, but don't know where |
|---|
| 849 |
exactly it is documented, and aren't sure of the name of a related |
|---|
| 850 |
command or option, we recommend trying these methods. Usually it is |
|---|
| 851 |
best to start with an apropos command, then try searching the manual |
|---|
| 852 |
index, then finally look in the FAQ and the package keywords. |
|---|
| 853 |
|
|---|
| 854 |
`C-h a TOPIC <RET>' |
|---|
| 855 |
This searches for commands whose names match TOPIC, which should |
|---|
| 856 |
be a regular expression (*note Regexps::). Browse the buffer that |
|---|
| 857 |
this command displays to find what you are looking for. *Note |
|---|
| 858 |
Apropos::. |
|---|
| 859 |
|
|---|
| 860 |
`M-x apropos <RET> TOPIC <RET>' |
|---|
| 861 |
This works like `C-h a', but it also searches for user options and |
|---|
| 862 |
other variables, in case the feature you are looking for is |
|---|
| 863 |
controlled by an option, not a command. *Note Apropos::. |
|---|
| 864 |
|
|---|
| 865 |
`M-x apropos-documentation <RET> TOPIC <RET>' |
|---|
| 866 |
This searches the _documentation strings_ (the built-in short |
|---|
| 867 |
descriptions) of all variables and functions (not their names) for |
|---|
| 868 |
a match for TOPIC, a regular expression. *Note Apropos::. |
|---|
| 869 |
|
|---|
| 870 |
`C-h i d m emacs <RET> i TOPIC <RET>' |
|---|
| 871 |
This looks up TOPIC in the indices of the Emacs on-line manual. |
|---|
| 872 |
If there are several matches, Emacs displays the first one. You |
|---|
| 873 |
can then press <,> to move to other matches, until you find what |
|---|
| 874 |
you are looking for. |
|---|
| 875 |
|
|---|
| 876 |
`C-h i d m emacs <RET> s TOPIC <RET>' |
|---|
| 877 |
Similar, but searches for TOPIC (which can be a regular |
|---|
| 878 |
expression) in the _text_ of the manual rather than in its indices. |
|---|
| 879 |
|
|---|
| 880 |
`C-h F' |
|---|
| 881 |
This brings up the Emacs FAQ, where you can use the usual search |
|---|
| 882 |
commands (*note Search::) to find the information. |
|---|
| 883 |
|
|---|
| 884 |
`C-h p' |
|---|
| 885 |
Finally, you can try looking up a suitable package using keywords |
|---|
| 886 |
pertinent to the feature you need. *Note Library Keywords::. |
|---|
| 887 |
|
|---|
| 888 |
To find the documentation of a key sequence or a menu item, type |
|---|
| 889 |
`C-h C-k' and then type that key sequence or select the menu item. |
|---|
| 890 |
This looks up the description of the command invoked by the key or the |
|---|
| 891 |
menu in the appropriate manual (not necessarily the Emacs manual). |
|---|
| 892 |
Likewise, use `C-h C-f' for reading documentation of a command. |
|---|
| 893 |
|
|---|
| 894 |
* Menu: |
|---|
| 895 |
|
|---|
| 896 |
* Help Summary:: Brief list of all Help commands. |
|---|
| 897 |
* Key Help:: Asking what a key does in Emacs. |
|---|
| 898 |
* Name Help:: Asking about a command, variable or function name. |
|---|
| 899 |
* Apropos:: Asking what pertains to a given topic. |
|---|
| 900 |
* Library Keywords:: Finding Lisp libraries by keywords (topics). |
|---|
| 901 |
* Language Help:: Help relating to international language support. |
|---|
| 902 |
* Help Mode:: Special features of Help mode and Help buffers. |
|---|
| 903 |
* Misc Help:: Other help commands. |
|---|
| 904 |
* Help Echo:: Help on active text and tooltips (`balloon help') |
|---|
| 905 |
|
|---|
| 906 |
|
|---|
| 907 |
File: emacs, Node: Help Summary, Next: Key Help, Up: Help |
|---|
| 908 |
|
|---|
| 909 |
Help Summary |
|---|
| 910 |
============ |
|---|
| 911 |
|
|---|
| 912 |
Here is a summary of the defined help commands. |
|---|
| 913 |
|
|---|
| 914 |
`C-h a REGEXP <RET>' |
|---|
| 915 |
Display a list of commands whose names match REGEXP |
|---|
| 916 |
(`apropos-command'). |
|---|
| 917 |
|
|---|
| 918 |
`C-h b' |
|---|
| 919 |
Display a table of all key bindings in effect now, in this order: |
|---|
| 920 |
minor mode bindings, major mode bindings, and global bindings |
|---|
| 921 |
(`describe-bindings'). |
|---|
| 922 |
|
|---|
| 923 |
`C-h c KEY' |
|---|
| 924 |
Show the name of the command that KEY runs |
|---|
| 925 |
(`describe-key-briefly'). Here `c' stands for "character." For |
|---|
| 926 |
more extensive information on KEY, use `C-h k'. |
|---|
| 927 |
|
|---|
| 928 |
`C-h f FUNCTION <RET>' |
|---|
| 929 |
Display documentation on the Lisp function named FUNCTION |
|---|
| 930 |
(`describe-function'). Since commands are Lisp functions, a |
|---|
| 931 |
command name may be used. |
|---|
| 932 |
|
|---|
| 933 |
`C-h h' |
|---|
| 934 |
Display the `HELLO' file, which shows examples of various character |
|---|
| 935 |
sets. |
|---|
| 936 |
|
|---|
| 937 |
`C-h i' |
|---|
| 938 |
Run Info, the program for browsing documentation files (`info'). |
|---|
| 939 |
The complete Emacs manual is available on-line in Info. |
|---|
| 940 |
|
|---|
| 941 |
`C-h k KEY' |
|---|
| 942 |
Display the name and documentation of the command that KEY runs |
|---|
| 943 |
(`describe-key'). |
|---|
| 944 |
|
|---|
| 945 |
`C-h l' |
|---|
| 946 |
Display a description of the last 100 characters you typed |
|---|
| 947 |
(`view-lossage'). |
|---|
| 948 |
|
|---|
| 949 |
`C-h m' |
|---|
| 950 |
Display documentation of the current major mode (`describe-mode'). |
|---|
| 951 |
|
|---|
| 952 |
`C-h n' |
|---|
| 953 |
Display documentation of Emacs changes, most recent first |
|---|
| 954 |
(`view-emacs-news'). |
|---|
| 955 |
|
|---|
| 956 |
`C-h P' |
|---|
| 957 |
Display info on known problems with Emacs and possible workarounds |
|---|
| 958 |
(`view-emacs-problems'). |
|---|
| 959 |
|
|---|
| 960 |
`C-h p' |
|---|
| 961 |
Find packages by topic keyword (`finder-by-keyword'). |
|---|
| 962 |
|
|---|
| 963 |
`C-h s' |
|---|
| 964 |
Display the current contents of the syntax table, plus an |
|---|
| 965 |
explanation of what they mean (`describe-syntax'). *Note Syntax::. |
|---|
| 966 |
|
|---|
| 967 |
`C-h t' |
|---|
| 968 |
Enter the Emacs interactive tutorial (`help-with-tutorial'). |
|---|
| 969 |
|
|---|
| 970 |
`C-h v VAR <RET>' |
|---|
| 971 |
Display the documentation of the Lisp variable VAR |
|---|
| 972 |
(`describe-variable'). |
|---|
| 973 |
|
|---|
| 974 |
`C-h w COMMAND <RET>' |
|---|
| 975 |
Show which keys run the command named COMMAND (`where-is'). |
|---|
| 976 |
|
|---|
| 977 |
`C-h C CODING <RET>' |
|---|
| 978 |
Describe coding system CODING (`describe-coding-system'). |
|---|
| 979 |
|
|---|
| 980 |
`C-h C <RET>' |
|---|
| 981 |
Describe the coding systems currently in use. |
|---|
| 982 |
|
|---|
| 983 |
`C-h I METHOD <RET>' |
|---|
| 984 |
Describe an input method (`describe-input-method'). |
|---|
| 985 |
|
|---|
| 986 |
`C-h L LANGUAGE-ENV <RET>' |
|---|
| 987 |
Display information on the character sets, coding systems, and |
|---|
| 988 |
input methods used for language environment LANGUAGE-ENV |
|---|
| 989 |
(`describe-language-environment'). |
|---|
| 990 |
|
|---|
| 991 |
`C-h C-c' |
|---|
| 992 |
Display the copying conditions for GNU Emacs. |
|---|
| 993 |
|
|---|
| 994 |
`C-h C-d' |
|---|
| 995 |
Display information about getting new versions of GNU Emacs. |
|---|
| 996 |
|
|---|
| 997 |
`C-h C-f FUNCTION <RET>' |
|---|
| 998 |
Enter Info and go to the node documenting the Emacs function |
|---|
| 999 |
FUNCTION (`Info-goto-emacs-command-node'). |
|---|
| 1000 |
|
|---|
| 1001 |
`C-h C-k KEY' |
|---|
| 1002 |
Enter Info and go to the node where the key sequence KEY is |
|---|
| 1003 |
documented (`Info-goto-emacs-key-command-node'). |
|---|
| 1004 |
|
|---|
| 1005 |
`C-h C-p' |
|---|
| 1006 |
Display information about the GNU Project. |
|---|
| 1007 |
|
|---|
| 1008 |
`C-h <TAB> SYMBOL <RET>' |
|---|
| 1009 |
Display the Info documentation on symbol SYMBOL according to the |
|---|
| 1010 |
programming language you are editing (`info-lookup-symbol'). |
|---|
| 1011 |
|
|---|
| 1012 |
|
|---|
| 1013 |
File: emacs, Node: Key Help, Next: Name Help, Prev: Help Summary, Up: Help |
|---|
| 1014 |
|
|---|
| 1015 |
Documentation for a Key |
|---|
| 1016 |
======================= |
|---|
| 1017 |
|
|---|
| 1018 |
The most basic `C-h' options are `C-h c' (`describe-key-briefly') |
|---|
| 1019 |
and `C-h k' (`describe-key'). `C-h c KEY' displays in the echo area |
|---|
| 1020 |
the name of the command that KEY is bound to. For example, `C-h c C-f' |
|---|
| 1021 |
displays `forward-char'. Since command names are chosen to describe |
|---|
| 1022 |
what the commands do, this is a good way to get a very brief |
|---|
| 1023 |
description of what KEY does. |
|---|
| 1024 |
|
|---|
| 1025 |
`C-h k KEY' is similar but gives more information: it displays the |
|---|
| 1026 |
documentation string of the command as well as its name. This is too |
|---|
| 1027 |
big for the echo area, so a window is used for the display. |
|---|
| 1028 |
|
|---|
| 1029 |
`C-h c' and `C-h k' work for any sort of key sequences, including |
|---|
| 1030 |
function keys and mouse events. |
|---|
| 1031 |
|
|---|
| 1032 |
|
|---|
| 1033 |
File: emacs, Node: Name Help, Next: Apropos, Prev: Key Help, Up: Help |
|---|
| 1034 |
|
|---|
| 1035 |
Help by Command or Variable Name |
|---|
| 1036 |
================================ |
|---|
| 1037 |
|
|---|
| 1038 |
`C-h f' (`describe-function') reads the name of a Lisp function |
|---|
| 1039 |
using the minibuffer, then displays that function's documentation string |
|---|
| 1040 |
in a window. Since commands are Lisp functions, you can use this to get |
|---|
| 1041 |
the documentation of a command that you know by name. For example, |
|---|
| 1042 |
|
|---|
| 1043 |
C-h f auto-fill-mode <RET> |
|---|
| 1044 |
|
|---|
| 1045 |
displays the documentation of `auto-fill-mode'. This is the only way |
|---|
| 1046 |
to get the documentation of a command that is not bound to any key (one |
|---|
| 1047 |
which you would normally run using `M-x'). |
|---|
| 1048 |
|
|---|
| 1049 |
`C-h f' is also useful for Lisp functions that you are planning to |
|---|
| 1050 |
use in a Lisp program. For example, if you have just written the |
|---|
| 1051 |
expression `(make-vector len)' and want to check that you are using |
|---|
| 1052 |
`make-vector' properly, type `C-h f make-vector <RET>'. Because `C-h |
|---|
| 1053 |
f' allows all function names, not just command names, you may find that |
|---|
| 1054 |
some of your favorite abbreviations that work in `M-x' don't work in |
|---|
| 1055 |
`C-h f'. An abbreviation may be unique among command names yet fail to |
|---|
| 1056 |
be unique when other function names are allowed. |
|---|
| 1057 |
|
|---|
| 1058 |
The default function name for `C-h f' to describe, if you type just |
|---|
| 1059 |
<RET>, is the name of the function called by the innermost Lisp |
|---|
| 1060 |
expression in the buffer around point, _provided_ that is a valid, |
|---|
| 1061 |
defined Lisp function name. For example, if point is located following |
|---|
| 1062 |
the text `(make-vector (car x)', the innermost list containing point is |
|---|
| 1063 |
the one that starts with `(make-vector', so the default is to describe |
|---|
| 1064 |
the function `make-vector'. |
|---|
| 1065 |
|
|---|
| 1066 |
`C-h f' is often useful just to verify that you have the right |
|---|
| 1067 |
spelling for the function name. If `C-h f' mentions a name from the |
|---|
| 1068 |
buffer as the default, that name must be defined as a Lisp function. If |
|---|
| 1069 |
that is all you want to know, just type `C-g' to cancel the `C-h f' |
|---|
| 1070 |
command, then go on editing. |
|---|
| 1071 |
|
|---|
| 1072 |
`C-h w COMMAND <RET>' tells you what keys are bound to COMMAND. It |
|---|
| 1073 |
displays a list of the keys in the echo area. If it says the command |
|---|
| 1074 |
is not on any key, you must use `M-x' to run it. `C-h w' runs the |
|---|
| 1075 |
command `where-is'. |
|---|
| 1076 |
|
|---|
| 1077 |
`C-h v' (`describe-variable') is like `C-h f' but describes Lisp |
|---|
| 1078 |
variables instead of Lisp functions. Its default is the Lisp symbol |
|---|
| 1079 |
around or before point, but only if that is the name of a known Lisp |
|---|
| 1080 |
variable. *Note Variables::. |
|---|
| 1081 |
|
|---|
| 1082 |
Help buffers describing variables or functions defined in Lisp |
|---|
| 1083 |
normally have hyperlinks to the Lisp definition, if you have the Lisp |
|---|
| 1084 |
source files installed. If you know Lisp, this provides the ultimate |
|---|
| 1085 |
documentation. If you don't know Lisp, you should learn it. If you |
|---|
| 1086 |
are treating Emacs as an object file, then you are just _using_ Emacs. |
|---|
| 1087 |
For real intimacy with Emacs, you must read the source code. |
|---|
| 1088 |
|
|---|
| 1089 |
|
|---|
| 1090 |
File: emacs, Node: Apropos, Next: Library Keywords, Prev: Name Help, Up: Help |
|---|
| 1091 |
|
|---|
| 1092 |
Apropos |
|---|
| 1093 |
======= |
|---|
| 1094 |
|
|---|
| 1095 |
A more sophisticated sort of question to ask is, "What are the |
|---|
| 1096 |
commands for working with files?" To ask this question, type `C-h a |
|---|
| 1097 |
file <RET>', which displays a list of all command names that contain |
|---|
| 1098 |
`file', including `copy-file', `find-file', and so on. With each |
|---|
| 1099 |
command name appears a brief description of how to use the command, and |
|---|
| 1100 |
what keys you can currently invoke it with. For example, it would say |
|---|
| 1101 |
that you can invoke `find-file' by typing `C-x C-f'. The `a' in `C-h |
|---|
| 1102 |
a' stands for "Apropos"; `C-h a' runs the command `apropos-command'. |
|---|
| 1103 |
This command normally checks only commands (interactive functions); if |
|---|
| 1104 |
you specify a prefix argument, it checks noninteractive functions as |
|---|
| 1105 |
well. |
|---|
| 1106 |
|
|---|
| 1107 |
Because `C-h a' looks only for functions whose names contain the |
|---|
| 1108 |
string you specify, you must use ingenuity in choosing the string. If |
|---|
| 1109 |
you are looking for commands for killing backwards and `C-h a |
|---|
| 1110 |
kill-backwards <RET>' doesn't reveal any, don't give up. Try just |
|---|
| 1111 |
`kill', or just `backwards', or just `back'. Be persistent. Also note |
|---|
| 1112 |
that you can use a regular expression as the argument, for more |
|---|
| 1113 |
flexibility (*note Regexps::). |
|---|
| 1114 |
|
|---|
| 1115 |
Here is a set of arguments to give to `C-h a' that covers many |
|---|
| 1116 |
classes of Emacs commands, since there are strong conventions for naming |
|---|
| 1117 |
the standard Emacs commands. By giving you a feel for the naming |
|---|
| 1118 |
conventions, this set should also serve to aid you in developing a |
|---|
| 1119 |
technique for picking `apropos' strings. |
|---|
| 1120 |
|
|---|
| 1121 |
char, line, word, sentence, paragraph, region, page, sexp, list, |
|---|
| 1122 |
defun, rect, buffer, frame, window, face, file, dir, register, |
|---|
| 1123 |
mode, beginning, end, forward, backward, next, previous, up, down, |
|---|
| 1124 |
search, goto, kill, delete, mark, insert, yank, fill, indent, |
|---|
| 1125 |
case, change, set, what, list, find, view, describe, default. |
|---|
| 1126 |
|
|---|
| 1127 |
To list all user variables that match a regexp, use the command `M-x |
|---|
| 1128 |
apropos-variable'. This comman |
|---|