|
|
1.1 root 1: This is Info file ../info/emacs, produced by Makeinfo-1.49 from the
2: input file emacs.texi.
3:
4: This file documents the GNU Emacs editor.
5:
6: Copyright (C) 1985, 1986, 1988, 1992 Richard M. Stallman.
7:
8: Permission is granted to make and distribute verbatim copies of this
9: manual provided the copyright notice and this permission notice are
10: preserved on all copies.
11:
12: Permission is granted to copy and distribute modified versions of
13: this manual under the conditions for verbatim copying, provided also
14: that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
15: General Public License" are included exactly as in the original, and
16: provided that the entire resulting derived work is distributed under the
17: terms of a permission notice identical to this one.
18:
19: Permission is granted to copy and distribute translations of this
20: manual into another language, under the above conditions for modified
21: versions, except that the sections entitled "The GNU Manifesto",
22: "Distribution" and "GNU General Public License" may be included in a
23: translation approved by the author instead of in the original English.
24:
25:
26: File: emacs, Node: Commands, Next: Entering Emacs, Prev: Keys, Up: Top
27:
28: Keys and Commands
29: =================
30:
31: This manual is full of passages that tell you what particular keys
32: do. But Emacs does not assign meanings to keys directly. Instead, Emacs
33: assigns meanings to "functions", and then gives keys their meanings by
34: "binding" them to functions.
35:
36: A function is a Lisp object that can be executed as a program.
37: Usually it is a Lisp symbol which has been given a function definition;
38: every symbol has a name, usually made of a few English words separated
39: by dashes, such as `next-line' or `forward-word'. It also has a
40: "definition" which is a Lisp program; this is what makes the function
41: do what it does. Only some functions can be the bindings of keys;
42: these are functions whose definitions use `interactive' to specify how
43: to call them interactively. Such functions are called "commands", and
44: their names are "command names". *Note Defining Commands:
45: (elisp)Defining Commands, for more information.
46:
47: The bindings between keys and functions are recorded in various
48: tables called "keymaps". *Note Keymaps::.
49:
50: When we say that "`C-n' moves down vertically one line" we are
51: glossing over a distinction that is irrelevant in ordinary use but is
52: vital in understanding how to customize Emacs. It is the function
53: `next-line' that is programmed to move down vertically. `C-n' has this
54: effect because it is bound to that function. If you rebind `C-n' to
55: the function `forward-word' then `C-n' will move forward by words
56: instead. Rebinding keys is a common method of customization.
57:
58: In the rest of this manual, we usually ignore this subtlety to keep
59: things simple. To give the customizer the information he needs, we
60: state the name of the command which really does the work in parentheses
61: after mentioning the key that runs it. For example, we will say that
62: "The command `C-n' (`next-line') moves point vertically down," meaning
63: that `next-line' is a command that moves vertically down and `C-n' is a
64: key that is standardly bound to it.
65:
66: While we are on the subject of information for customization only,
67: it's a good time to tell you about "variables". Often the description
68: of a command will say, "To change this, set the variable `mumble-foo'."
69: A variable is a name used to remember a value. Most of the variables
70: documented in this manual exist just to facilitate customization: some
71: command or other part of Emacs examines the variable and behaves
72: differently accordingly. Until you are interested in customizing, you
73: can ignore the information about variables. When you are ready to be
74: interested, read the basic information on variables, and then the
75: information on individual variables will make sense. *Note Variables::.
76:
77:
78: File: emacs, Node: Entering Emacs, Next: Exiting, Prev: Commands, Up: Top
79:
80: Entering and Exiting Emacs
81: **************************
82:
83: The usual way to invoke Emacs is just to type `emacs RET' at the
84: shell. Emacs clears the screen and then displays an initial advisor
85: message and copyright notice. You can begin typing Emacs commands
86: immediately afterward.
87:
88: Some operating systems insist on discarding all type-ahead when Emacs
89: starts up; they give Emacs no way to prevent this. Therefore, it is
90: wise to wait until Emacs clears the screen before typing your first
91: editing command.
92:
93: Before Emacs reads the first command, you have not had a chance to
94: give a command to specify a file to edit. But Emacs must always have a
95: current buffer for editing. In an attempt to do something useful,
96: Emacs presents a buffer named `*scratch*' which is in Lisp Interaction
97: mode; you can use it to type Lisp expressions and evaluate them, or you
98: can ignore that capability and simply doodle. (You can specify a
99: different major mode for this buffer by setting the variable
100: `initial-major-mode' in your init file. *Note Init File::.)
101:
102: It is also possible to specify files to be visited, Lisp files to be
103: loaded, and functions to be called, by giving Emacs arguments in the
104: shell command line. *Note Command Switches::.
105:
106:
107: File: emacs, Node: Exiting, Next: Command Switches, Prev: Entering Emacs, Up: Top
108:
109: Exiting Emacs
110: =============
111:
112: There are two commands for exiting Emacs because there are two kinds
113: of exiting: "suspending" Emacs and "killing" Emacs. "Suspending" means
114: stopping Emacs temporarily and returning control to its superior
115: (usually the shell), allowing you to resume editing later in the same
116: Emacs job, with the same files, same kill ring, same undo history, and
117: so on. This is the usual way to exit. "Killing" Emacs means
118: destroying the Emacs job. You can run Emacs again later, but you will
119: get a fresh Emacs; there is no way to resume the same editing session
120: after it has been killed.
121:
122: `C-z'
123: Suspend Emacs (`suspend-emacs').
124:
125: `C-x C-c'
126: Kill Emacs (`save-buffers-kill-emacs').
127:
128: To suspend Emacs, type `C-z' (`suspend-emacs'). This takes you back
129: to the shell from which you invoked Emacs. You can resume Emacs with
130: the command `%emacs' if you are using the C shell or the Bourne-Again
131: shell.
132:
133: On systems that do not permit programs to be suspended, `C-z' runs an
134: inferior shell that communicates directly with the terminal, and Emacs
135: waits until you exit the subshell. The only way on these systems to get
136: back to the shell from which Emacs was run (to log out, for example) is
137: to kill Emacs. `C-d' or `exit' are typical commands to exit a subshell.
138:
139: To kill Emacs, type `C-x C-c' (`save-buffers-kill-emacs'). A
140: two-character key is used for this to make it harder to type. Unless a
141: numeric argument is used, this command first offers to save any modified
142: buffers. If you do not save them all, it asks for reconfirmation with
143: `yes' before killing Emacs, since any changes not saved before that
144: will be lost forever. Also, if any subprocesses are still running,
145: `C-x C-c' asks for confirmation about them, since killing Emacs will
146: kill the subprocesses immediately.
147:
148: In most programs running on Unix, certain characters may instantly
149: suspend or kill the program. (In Berkeley Unix these characters are
150: normally `C-z' and `C-c'.) This Unix feature is turned off while you
151: are in Emacs. The meanings of `C-z' and `C-x C-c' as keys in Emacs
152: were inspired by the standard Berkeley Unix meanings of `C-z' and
153: `C-c', but that is their only relationship with Unix. You could
154: customize these keys to do anything (*note Keymaps::.).
155:
156:
157: File: emacs, Node: Command Switches, Next: Basic, Prev: Exiting, Up: Top
158:
159: Command Line Switches and Arguments
160: ===================================
161:
162: GNU Emacs supports command line arguments to request various actions
163: when invoking Emacs. These are for compatibility with other editors and
164: for sophisticated activities. They are not needed for ordinary editing
165: with Emacs, so new users can skip this section.
166:
167: You may be used to using command line arguments with other editors
168: to specify which file to edit. That's because many other editors are
169: designed to be started afresh each time you want to edit. You edit one
170: file and then exit the editor. The next time you want to edit either
171: another file or the same one, you must run the editor again. With these
172: editors, it makes sense to use a command line argument to say which
173: file to edit.
174:
175: The recommended way to use GNU Emacs is to start it only once, just
176: after you log in, and do all your editing in the same Emacs process.
177: Each time you want to edit a different file, you visit it with the
178: existing Emacs, which eventually comes to have many files in it ready
179: for editing. Usually you do not kill the Emacs until you are about to
180: log out.
181:
182: In the usual style of Emacs use, files are nearly always read by
183: typing commands to an editor that is already running. So command line
184: arguments for specifying a file when the editor is started are seldom
185: used.
186:
187: Emacs accepts command-line arguments that specify files to visit,
188: functions to call, and other activities and operating modes.
189:
190: The command arguments are processed in the order they appear in the
191: command argument list; however, certain arguments (the ones in the
192: second table) must be at the front of the list if they are used.
193:
194: Here are the arguments allowed:
195:
196: `FILE'
197: Visit FILE using `find-file'. *Note Visiting::.
198:
199: `+LINENUM FILE'
200: Visit FILE using `find-file', then go to line number LINENUM in it.
201:
202: `-l FILE'
203: `-load FILE'
204: Load a file FILE of Lisp code with the function `load'. *Note Lisp
205: Libraries::.
206:
207: `-f FUNCTION'
208: `-funcall FUNCTION'
209: Call Lisp function FUNCTION with no arguments.
210:
211: `-i FILE'
212: `-insert FILE'
213: Insert the contents of FILE into the current buffer. This is like
214: what `M-x insert-buffer' does; see *Note Misc File Ops::.
215:
216: `-kill'
217: Exit from Emacs without asking for confirmation.
218:
219: The following switches are recognized only at the beginning of the
220: command line. If more than one of them appears, they must appear in the
221: order that they appear in this table.
222:
223: `-t DEVICE'
224: Use DEVICE as the device for terminal input and output.
225:
226: `-d DISPLAY'
227: When running with the X window system, use the display named
228: DISPLAY to make Emacs's X window.
229:
230: `-nw'
231: Don't use a window system; display text only, using an ordinary
232: terminal device. Thus, if you run an X-capable Emacs in an Xterm
233: with `emacs -nw', it displays in the Xterm's own window instead of
234: making its own.
235:
236: `-batch'
237: Run Emacs in "batch mode", which means that the text being edited
238: is not displayed and the standard Unix interrupt characters such
239: as `C-z' and `C-c' continue to have their normal effect. Emacs in
240: batch mode outputs to `stdout' only what would normally be printed
241: in the echo area under program control.
242:
243: Batch mode is used for running programs written in Emacs Lisp from
244: shell scripts, makefiles, and so on. Normally the `-l' switch or
245: `-f' switch will be used as well, to invoke a Lisp program to do
246: the batch processing.
247:
248: `-batch' implies `-q' (do not load an init file). It also causes
249: Emacs to exit after all command switches have been processed. In
250: addition, auto-saving is not done except in buffers for which it
251: has been explicitly requested.
252:
253: `-q'
254: `-no-init-file'
255: Do not load your Emacs init file `~/.emacs'.
256:
257: `-u USER'
258: `-user USER'
259: Load USER's Emacs init file `~USER/.emacs' instead of your own.
260:
261: With X Windows, you can use these additional options to specify how
262: to display the window. Each option has a corresponding resource name
263: (used with `emacs' unless you specify another name with `-rn NAME'),
264: listed with the option, which lets you specify the same parameter using
265: the usual X Windows defaulting mechanism. The corresponding generic
266: resource name (used with `Emacs') is usually made by capitalizing the
267: first letter of the individual resource name, but in some cases it is a
268: completely different string (which is listed below).
269:
270: `-rn NAME'
271: Use NAME instead of `emacs' when looking for X resources.
272:
273: `-font FONTNAME'
274: `-fn FONTNAME'
275: Use font FONTNAME.
276: (Resource `font'.)
277:
278: `-wn NAME'
279: Name the window NAME.
280: (Resource `title'.)
281:
282: `-i'
283: Use a bitmap icon (showing the kitchen sink) rather than a textual
284: icon.
285: (Resource `bitmapIcon'.)
286:
287: `-in NAME'
288: Name the icon NAME. (Resource `iconName'; `Title').
289:
290: `-geometry COORDS'
291: `-w COORDS'
292: Specify the shape and optionally the position of the Emacs window
293: in the usual X way.
294: (Resource `geometry'.)
295:
296: `-b WIDTH'
297: Specify that the window border is WIDTH pixels thick.
298: (Resource `borderWidth'.)
299:
300: `-ib WIDTH'
301: Leave WIDTH blank pixels between the border and the window
302: contents.
303: (Resource `internalBorder'; `BorderWidth'.)
304:
305: `-r'
306: Use reverse video.
307: (Resource `reverseVideo'.)
308:
309: `-fg COLOR'
310: Use color COLOR for text in the window.
311: (Resource `foreground'.)
312:
313: `-bg COLOR'
314: Use the color COLOR for the background of the window.
315: (Resource `background'.)
316:
317: `-bd COLOR'
318: Use color COLOR for the window border.
319: (Resource `borderColor'.)
320:
321: `-cr COLOR'
322: Specify the color, COLOR, to use for the cursor.
323: (Resource `cursorColor'; `Foreground'.)
324:
325: `-ms COLOR'
326: Use color COLOR for the mouse cursor.
327: (Resource `pointerColor'; `Foreground'.)
328:
329: The init file can get access to the command line argument values as
330: the elements of a list in the variable `command-line-args'. (The
331: arguments in the second table above will already have been processed and
332: will not be in the list.) The init file can override the normal
333: processing of the other arguments by setting this variable.
334:
335: One way to use command arguments is to visit many files
336: automatically:
337:
338: emacs *.c
339:
340: passes each `.c' file as a separate argument to Emacs, so that Emacs
341: visits each file (*note Visiting::.).
342:
343: Here is an advanced example that assumes you have a Lisp program
344: file called `hack-c-program.el' which, when loaded, performs some
345: useful operation on current buffer, expected to be a C program.
346:
347: emacs -batch foo.c -l hack-c-program -f save-buffer -kill > log
348:
349: This says to visit `foo.c', load `hack-c-program.el' (which makes
350: changes in the visited file), save `foo.c' (note that `save-buffer' is
351: the function that `C-x C-s' is bound to), and then exit to the shell
352: that this command was done with. `-batch' guarantees there will be no
353: problem redirecting output to `log', because Emacs will not assume that
354: it has a display terminal to work with.
355:
356:
357: File: emacs, Node: Basic, Next: Undo, Prev: Command Switches, Up: Top
358:
359: Basic Editing Commands
360: **********************
361:
362: We now give the basics of how to enter text, make corrections, and
363: save the text in a file. If this material is new to you, you might
364: learn it more easily by running the Emacs learn-by-doing tutorial. To
365: do this, type `Control-h t' (`help-with-tutorial').
366:
367: Inserting Text
368: ==============
369:
370: To insert printing characters into the text you are editing, just
371: type them. This inserts the character into the buffer at the cursor
372: (that is, at "point"; *note Point::.). The cursor moves forward. Any
373: characters after the cursor move forward too. If the text in the
374: buffer is `FOOBAR', with the cursor before the `B', then if you type
375: `XX', you get `FOOXXBAR', with the cursor still before the `B'.
376:
377: To "delete" text you have just inserted, use DEL. DEL deletes the
378: character BEFORE the cursor (not the one that the cursor is on top of
379: or under; that is the character AFTER the cursor). The cursor and all
380: characters after it move backwards. Therefore, if you type a printing
381: character and then type DEL, they cancel out.
382:
383: To end a line and start typing a new one, type RET. This inserts a
384: newline character in the buffer. If point is in the middle of a line,
385: RET splits the line. Typing DEL when the cursor is at the beginning of
386: a line rubs out the newline before the line, thus joining the line with
387: the preceding line.
388:
389: Emacs will split lines automatically when they become too long, if
390: you turn on a special mode called "Auto Fill" mode. *Note Filling::,
391: for how to use Auto Fill mode.
392:
393: Customization information: DEL in most modes runs the command named
394: `delete-backward-char'; RET runs the command `newline', and
395: self-inserting printing characters run the command `self-insert', which
396: inserts whatever character was typed to invoke it. Some major modes
397: rebind DEL to other commands.
398:
399: Direct insertion works for printing characters and SPC, but other
400: characters act as editing commands and do not insert themselves. If you
401: need to insert a control character or a character whose code is above
402: 200 octal, you must "quote" it by typing the character `control-q'
403: (`quoted-insert') first. There are two ways to use `C-q':
404:
405: * `Control-q' followed by any non-graphic character (even `C-g')
406: inserts that character.
407:
408: * `Control-q' followed by three octal digits inserts the character
409: with the specified character code.
410:
411: A numeric argument to `C-q' specifies how many copies of the quoted
412: character should be inserted (*note Arguments::.).
413:
414: If you prefer to have text characters replace (overwrite) existing
415: text rather than shove it to the right, you can enable Overwrite mode,
416: a minor mode. *Note Minor Modes::.
417:
418: Changing the Location of Point
419: ==============================
420:
421: To do more than insert characters, you have to know how to move
422: point (*note Point::.). Here are a few of the commands for doing that.
423:
424: `C-a'
425: Move to the beginning of the line (`beginning-of-line').
426:
427: `C-e'
428: Move to the end of the line (`end-of-line').
429:
430: `C-f'
431: Move forward one character (`forward-char').
432:
433: `C-b'
434: Move backward one character (`backward-char').
435:
436: `M-f'
437: Move forward one word (`forward-word').
438:
439: `M-b'
440: Move backward one word (`backward-word').
441:
442: `C-n'
443: Move down one line, vertically (`next-line'). This command
444: attempts to keep the horizontal position unchanged, so if you
445: start in the middle of one line, you end in the middle of the
446: next. When on the last line of text, `C-n' creates a new line and
447: moves onto it.
448:
449: `C-p'
450: Move up one line, vertically (`previous-line').
451:
452: `C-l'
453: Clear the screen and reprint everything (`recenter'). Text moves
454: on the screen to bring point to the center of the window.
455:
456: `M-r'
457: Move point to left margin on the line halfway down the screen or
458: window (`move-to-window-line'). Text does not move on the screen.
459: A numeric argument says how many screen lines down from the top
460: of the window (zero for the top). A negative argument counts from
461: the bottom (-1 for the bottom).
462:
463: `C-t'
464: Transpose two characters, the ones before and after the cursor
465: (`transpose-chars').
466:
467: `M-<'
468: Move to the top of the buffer (`beginning-of-buffer'). With
469: numeric argument N, move to N/10 of the way from the top. *Note
470: Arguments::, for more information on numeric arguments.
471:
472: `M->'
473: Move to the end of the buffer (`end-of-buffer').
474:
475: `M-x goto-char'
476: Read a number N and move cursor to character number N. Position 1
477: is the beginning of the buffer.
478:
479: `M-x goto-line'
480: Read a number N and move cursor to line number N. Line 1 is the
481: beginning of the buffer.
482:
483: `C-x C-n'
484: Use the current column of point as the "semipermanent goal column"
485: for `C-n' and `C-p' (`set-goal-column'). Henceforth, those
486: commands always move to this column in each line moved into, or as
487: close as possible given the contents of the line. This goal
488: column remains in effect until canceled.
489:
490: `C-u C-x C-n'
491: Cancel the goal column. Henceforth, `C-n' and `C-p' once again
492: try to avoid changing the horizontal position, as usual.
493:
494: If you set the variable `track-eol' to a non-`nil' value, then `C-n'
495: and `C-p' when at the end of the starting line move to the end of the
496: line. Normally, `track-eol' is `nil'.
497:
498: Erasing Text
499: ============
500:
501: `DEL'
502: Delete the character before the cursor (`delete-backward-char').
503:
504: `C-d'
505: Delete the character after the cursor (`delete-char').
506:
507: `C-k'
508: Kill to the end of the line (`kill-line').
509:
510: `M-d'
511: Kill forward to the end of the next word (`kill-word').
512:
513: `M-DEL'
514: Kill back to the beginning of the previous word
515: (`backward-kill-word').
516:
517: You already know about the DEL key which deletes the character
518: before the cursor. Another key, `Control-d', deletes the character
519: after the cursor, causing the rest of the text on the line to shift
520: left. If `Control-d' is typed at the end of a line, that line and the
521: next line are joined together.
522:
523: To erase a larger amount of text, use the `Control-k' key, which
524: kills a line at a time. If `C-k' is done at the beginning or middle of
525: a line, it kills all the text up to the end of the line. If `C-k' is
526: done at the end of a line, it joins that line and the next line.
527:
528: *Note Killing::, for more flexible ways of killing text.
529:
530: Files
531: =====
532:
533: The commands above are sufficient for creating and altering text in
534: an Emacs buffer; the more advanced Emacs commands just make things
535: easier. But to keep any text permanently you must put it in a "file".
536: Files are named units of text which are stored by the operating system
537: for you to retrieve later by name. To look at or use the contents of a
538: file in any way, including editing the file with Emacs, you must
539: specify the file name.
540:
541: Consider a file named `/usr/rms/foo.c'. In Emacs, to begin editing
542: this file, type
543:
544: C-x C-f /usr/rms/foo.c RET
545:
546: Here the file name is given as an "argument" to the command `C-x C-f'
547: (`find-file'). That command uses the "minibuffer" to read the
548: argument, and you type RET to terminate the argument (*note
549: Minibuffer::.).
550:
551: Emacs obeys the command by "visiting" the file: creating a buffer,
552: copying the contents of the file into the buffer, and then displaying
553: the buffer for you to edit. You can make changes in it, and then "save"
554: the file by typing `C-x C-s' (`save-buffer'). This makes the changes
555: permanent by copying the altered contents of the buffer back into the
556: file `/usr/rms/foo.c'. Until then, the changes are only inside your
557: Emacs, and the file `foo.c' is not changed.
558:
559: To create a file, just visit the file with `C-x C-f' as if it already
560: existed. Emacs will make an empty buffer in which you can insert the
561: text you want to put in the file. When you save your text with `C-x
562: C-s', the file will be created.
563:
564: Of course, there is a lot more to learn about using files. *Note
565: Files::.
566:
567: Help
568: ====
569:
570: If you forget what a key does, you can find out with the Help
571: character, which is `C-h'. Type `C-h k' followed by the key you want
572: to know about; for example, `C-h k C-n' tells you all about what `C-n'
573: does. `C-h' is a prefix key; `C-h k' is just one of its subcommands
574: (the command `describe-key'). The other subcommands of `C-h' provide
575: different kinds of help. Type `C-h' three times to get a description
576: of all the help facilities. *Note Help::.
577:
578: * Menu:
579:
580: * Blank Lines:: Commands to make or delete blank lines.
581: * Continuation Lines:: Lines too wide for the screen.
582: * Position Info:: What page, line, row, or column is point on?
583: * Arguments:: Numeric arguments for repeating a command.
584:
585:
586: File: emacs, Node: Blank Lines, Next: Continuation Lines, Prev: Basic, Up: Basic
587:
588: Blank Lines
589: ===========
590:
591: Here are special commands and techniques for putting in and taking
592: out blank lines.
593:
594: `C-o'
595: Insert one or more blank lines after the cursor (`open-line').
596:
597: `C-x C-o'
598: Delete all but one of many consecutive blank lines
599: (`delete-blank-lines').
600:
601: When you want to insert a new line of text before an existing line,
602: you can do it by typing the new line of text, followed by RET. However,
603: it may be easier to see what you are doing if you first make a blank
604: line and then insert the desired text into it. This is easy to do
605: using the key `C-o' (`open-line'), which inserts a newline after point
606: but leaves point in front of the newline. After `C-o', type the text
607: for the new line. `C-o F O O' has the same effect as `F O O RET',
608: except for the final location of point.
609:
610: You can make several blank lines by typing `C-o' several times, or by
611: giving it an argument to tell it how many blank lines to make. *Note
612: Arguments::, for how.
613:
614: If you have many blank lines in a row and want to get rid of them,
615: use `C-x C-o' (`delete-blank-lines'). When point is on a blank line
616: which is adjacent to at least one other blank line, `C-x C-o' deletes
617: all but one of the consecutive blank lines, leaving exactly one. With
618: point on a blank line with no other blank line adjacent to it, the sole
619: blank line is deleted, leaving none. When point is on a nonblank line,
620: `C-x C-o' deletes any blank lines following that nonblank line.
621:
622:
623: File: emacs, Node: Continuation Lines, Next: Position Info, Prev: Blank Lines, Up: Basic
624:
625: Continuation Lines
626: ==================
627:
628: If you add too many characters to one line, without breaking it with
629: a RET, the line will grow to occupy two (or more) lines on the screen,
630: with a `\' at the extreme right margin of all but the last of them. The
631: `\' says that the following screen line is not really a distinct line
632: in the text, but just the "continuation" of a line too long to fit the
633: screen. Sometimes it is nice to have Emacs insert newlines
634: automatically when a line gets too long; for this, use Auto Fill mode
635: (*note Filling::.).
636:
637: Instead of continuation, long lines can be displayed by "truncation".
638: This means that all the characters that do not fit in the width of the
639: screen or window do not appear at all. They remain in the buffer,
640: temporarily invisible. `$' is used in the last column instead of `\'
641: to inform you that truncation is in effect.
642:
643: Continuation can be turned off for a particular buffer by setting the
644: variable `truncate-lines' to non-`nil' in that buffer. Truncation
645: instead of continuation also happens whenever horizontal scrolling is
646: in use, and optionally whenever side-by-side windows are in use (*note
647: Windows::.). Altering the value of `truncate-lines' makes it local to
648: the current buffer; until that time, the default value is in effect.
649: The default is initially `nil'. *Note Locals::.
650:
651:
652: File: emacs, Node: Position Info, Next: Arguments, Prev: Continuation Lines, Up: Basic
653:
654: Cursor Position Information
655: ===========================
656:
657: If you are accustomed to other display editors, you may be surprised
658: that Emacs does not always display the page number or line number of
659: point in the mode line. This is because the text is stored in a way
660: that makes it difficult to compute this information. Displaying them
661: all the time would be intolerably slow. They are not needed very often
662: in Emacs anyway, but there are commands to compute them and print them.
663:
664: `M-x what-page'
665: Print page number of point, and line number within page.
666:
667: `M-x what-line'
668: Print line number of point in the buffer.
669:
670: `M-='
671: Print number of lines in the current region (`count-lines-region').
672:
673: `C-x ='
674: Print character code of character after point, character position
675: of point, and column of point (`what-cursor-position').
676:
677: There are two commands for printing line numbers. `M-x what-line'
678: counts lines from the beginning of the file and prints the line number
679: point is on. The first line of the file is line number 1. These
680: numbers can be used as arguments to `M-x goto-line'. By contrast, `M-x
681: what-page' counts pages from the beginning of the file, and counts lines
682: within the page, printing both of them. *Note Pages::.
683:
684: While on this subject, we might as well mention `M-='
685: (`count-lines-region'), which prints the number of lines in the region
686: (*note Mark::.). *Note Pages::, for the command `C-x l' which counts
687: the lines in the current page.
688:
689: The command `C-x =' (`what-cursor-position') can be used to find out
690: the column that the cursor is in, and other miscellaneous information
691: about point. It prints a line in the echo area that looks like this:
692:
693: Char: x (0170) point=65986 of 563027(12%) x=44
694:
695: (In fact, this is the output produced when point is before the `x=44'
696: in the example.)
697:
698: The two values after `Char:' describe the character following point,
699: first by showing it and second by giving its octal character code.
700:
701: `point=' is followed by the position of point expressed as a
702: character count. The front of the buffer counts as position 1, one
703: character later as 2, and so on. The next, larger number is the total
704: number of characters in the buffer. Afterward in parentheses comes the
705: position expressed as a percentage of the total size.
706:
707: `x=' is followed by the horizontal position of point, in columns
708: from the left edge of the window.
709:
710: If the buffer has been narrowed, making some of the text at the
711: beginning and the end temporarily invisible, `C-x =' prints additional
712: text describing the current visible range. For example, it might say
713:
714: Char: x (0170) point=65986 of 563025(12%) <65102 - 68533> x=44
715:
716: where the two extra numbers give the smallest and largest character
717: position that point is allowed to assume. The characters between those
718: two positions are the visible ones. *Note Narrowing::.
719:
720: If point is at the end of the buffer (or the end of the visible
721: part), `C-x =' omits any description of the character after point. The
722: output looks like
723:
724: point=563026 of 563025(100%) x=0
725:
726:
727: File: emacs, Node: Arguments, Prev: Position Info, Up: Basic
728:
729: Numeric Arguments
730: =================
731:
732: Any Emacs command can be given a "numeric argument". Some commands
733: interpret the argument as a repetition count. For example, giving an
734: argument of ten to the key `C-f' (the command `forward-char', move
735: forward one character) moves forward ten characters. With these
736: commands, no argument is equivalent to an argument of one. Negative
737: arguments are allowed. Often they tell a command to move or act
738: backwards.
739:
740: If your terminal keyboard has a META key, the easiest way to specify
741: a numeric argument is to type digits and/or a minus sign while holding
742: down the META key. For example,
743: M-5 C-n
744:
745: would move down five lines. The characters `Meta-1', `Meta-2', and so
746: on, as well as `Meta--', do this because they are keys bound to
747: commands (`digit-argument' and `negative-argument') that are defined to
748: contribute to an argument for the next command.
749:
750: Another way of specifying an argument is to use the `C-u'
751: (`universal-argument') command followed by the digits of the argument.
752: With `C-u', you can type the argument digits without holding down shift
753: keys. To type a negative argument, start with a minus sign. Just a
754: minus sign normally means -1. `C-u' works on all terminals.
755:
756: `C-u' followed by a character which is neither a digit nor a minus
757: sign has the special meaning of "multiply by four". It multiplies the
758: argument for the next command by four. `C-u' twice multiplies it by
759: sixteen. Thus, `C-u C-u C-f' moves forward sixteen characters. This
760: is a good way to move forward "fast", since it moves about 1/5 of a line
761: in the usual size screen. Other useful combinations are `C-u C-n',
762: `C-u C-u C-n' (move down a good fraction of a screen), `C-u C-u C-o'
763: (make "a lot" of blank lines), and `C-u C-k' (kill four lines).
764:
765: Some commands care only about whether there is an argument, and not
766: about its value. For example, the command `M-q' (`fill-paragraph') with
767: no argument fills text; with an argument, it justifies the text as well.
768: (*Note Filling::, for more information on `M-q'.) Just `C-u' is a
769: handy way of providing an argument for such commands.
770:
771: Some commands use the value of the argument as a repeat count, but do
772: something peculiar when there is no argument. For example, the command
773: `C-k' (`kill-line') with argument N kills N lines, including their
774: terminating newlines. But `C-k' with no argument is special: it kills
775: the text up to the next newline, or, if point is right at the end of
776: the line, it kills the newline itself. Thus, two `C-k' commands with
777: no arguments can kill a nonblank line, just like `C-k' with an argument
778: of one. (*Note Killing::, for more information on `C-k'.)
779:
780: A few commands treat a plain `C-u' differently from an ordinary
781: argument. A few others may treat an argument of just a minus sign
782: differently from an argument of -1. These unusual cases will be
783: described when they come up; they are always for reasons of convenience
784: of use of the individual command.
785:
786: To insert multiple copies of a digit, you can type `C-u COUNT C-u
787: DIGIT'. The second `C-u' ends the numeric argument, so that the
788: following character always acts a key sequence to be executed.
789:
790:
791: File: emacs, Node: Undo, Next: Minibuffer, Prev: Basic, Up: Top
792:
793: Undoing Changes
794: ***************
795:
796: Emacs allows all changes made in the text of a buffer to be undone,
797: up to a certain amount of change (8000 characters). Each buffer records
798: changes individually, and the undo command always applies to the
799: current buffer. Usually each editing command makes a separate entry in
800: the undo records, but some commands such as `query-replace' make many
801: entries, and very simple commands such as self-inserting characters are
802: often grouped to make undoing less tedious.
803:
804: `C-x u'
805: Undo one batch of changes (usually, one command worth) (`undo').
806:
807: `C-_'
808: The same.
809:
810: The command `C-x u' or `C-_' is how you undo. The first time you
811: give this command, it undoes the last change. Point moves to the text
812: affected by the undo, so you can see what was undone.
813:
814: Consecutive repetitions of the `C-_' or `C-x u' commands undo earlier
815: and earlier changes, back to the limit of what has been recorded. If
816: all recorded changes have already been undone, the undo command prints
817: an error message and does nothing.
818:
819: Any command other than an undo command breaks the sequence of undo
820: commands. Starting at this moment, the previous undo commands are
821: considered ordinary changes that can themselves be undone. Thus, to
822: redo changes you have undone, type `C-f' or any other command that will
823: have no important effect, and then give more undo commands.
824:
825: If you notice that a buffer has been modified accidentally, the
826: easiest way to recover is to type `C-_' repeatedly until the stars
827: disappear from the front of the mode line. At this time, all the
828: modifications you made have been cancelled. If you do not remember
829: whether you changed the buffer deliberately, type `C-_' once, and when
830: you see the last change you made undone, you will remember why you made
831: it. If it was an accident, leave it undone. If it was deliberate,
832: redo the change as described in the preceding paragraph.
833:
834: Whenever an undo command makes the stars disappear from the mode
835: line, it means that the buffer contents are the same as they were when
836: the file was last read in or saved.
837:
838: Not all buffers record undo information. Buffers whose names start
839: with spaces don't; these buffers are used internally by Emacs and its
840: extensions to hold text that users don't normally look at or edit.
841: Also, minibuffers, help buffers and documentation buffers don't record
842: undo information. Use the command `buffer-enable-undo' to enable
843: recording undo information in the current buffer.
844:
845: As editing continues, undo lists get longer and longer. To prevent
846: them from using up all available memory space, garbage collection trims
847: back their sizes to thresholds you can set. (For this purpose, the
848: "size" of an undo list measures the cons cells that make up the list,
849: plus the strings of deleted text.)
850:
851: Two variables control the range of acceptable sizes: `undo-limit'
852: and `undo-strong-limit'. Normally, the most recent changes are kept
853: until their size exceeds `undo-limit'; all older changes are discarded.
854: But if a change pushes the size above `undo-strong-limit', it is
855: discarded as well as all older changes. One exception: the most recent
856: set of changes is sacred; garbage collection never discards that. (In
857: Emacs versions 18.57 and 18.58, these variables are called
858: `undo-threshold' and `undo-high-threshold'.)
859:
860: The reason the `undo' command has two keys, `C-x u' and `C-_', set
861: up to run it is that it is worthy of a single-character key, but the
862: way to type `C-_' on some keyboards is not obvious. `C-x u' is an
863: alternative you can type in the same fashion on any terminal.
864:
865:
866: File: emacs, Node: Minibuffer, Next: M-x, Prev: Undo, Up: Top
867:
868: The Minibuffer
869: **************
870:
871: The "minibuffer" is the facility used by Emacs commands to read
872: arguments more complicated than a single number. Minibuffer arguments
873: can be file names, buffer names, Lisp function names, Emacs command
874: names, Lisp expressions, and many other things, depending on the
875: command reading the argument. The usual Emacs editing commands can be
876: used in the minibuffer to edit the argument.
877:
878: When the minibuffer is in use, it appears in the echo area, and the
879: terminal's cursor moves there. The beginning of the minibuffer line
880: displays a "prompt" which says what kind of input you should supply and
881: how it will be used. Often this prompt is derived from the name of the
882: command that the argument is for. The prompt normally ends with a
883: colon.
884:
885: Sometimes a "default argument" appears in parentheses after the
886: colon; it too is part of the prompt. The default will be used as the
887: argument value if you enter an empty argument (e.g., just type RET).
888: For example, commands that read buffer names always show a default,
889: which is the name of the buffer that will be used if you type just RET.
890:
891: The simplest way to give a minibuffer argument is to type the text
892: you want, terminated by RET which exits the minibuffer. You can get out
893: of the minibuffer, canceling the command that it was for, by typing
894: `C-g'.
895:
896: Since the minibuffer uses the screen space of the echo area, it can
897: conflict with other ways Emacs customarily uses the echo area. Here is
898: how Emacs handles such conflicts:
899:
900: * If a command gets an error while you are in the minibuffer, this
901: does not cancel the minibuffer. However, the echo area is needed
902: for the error message and therefore the minibuffer itself is
903: hidden for a while. It comes back after a few seconds, or as soon
904: as you type anything.
905:
906: * If in the minibuffer you use a command whose purpose is to print a
907: message in the echo area, such as `C-x =', the message is printed
908: normally, and the minibuffer is hidden for a while. It comes back
909: after a few seconds, or as soon as you type anything.
910:
911: * Echoing of keystrokes does not take place while the minibuffer is
912: in use.
913:
914: * Menu:
915:
916: * File: Minibuffer File. Entering file names with the minibuffer.
917: * Edit: Minibuffer Edit. How to edit in the minibuffer.
918: * Completion:: An abbreviation facility for minibuffer input.
919: * Repetition:: Re-executing commands that used the minibuffer.
920:
921:
922: File: emacs, Node: Minibuffer File, Next: Minibuffer Edit, Prev: Minibuffer, Up: Minibuffer
923:
924: Minibuffers for File Names
925: ==========================
926:
927: Sometimes the minibuffer starts out with text in it. For example,
928: when you are supposed to give a file name, the minibuffer starts out
929: containing the "default directory", which ends with a slash. This is
930: to inform you which directory the file will be found in if you do not
931: specify a directory. For example, the minibuffer might start out with
932:
933: Find File: /u2/emacs/src/
934:
935: where `Find File: ' is the prompt. Typing `buffer.c' specifies the
936: file `/u2/emacs/src/buffer.c'. To find files in nearby directories,
937: use `..'; thus, if you type `../lisp/simple.el', the file that you
938: visit will be the one named `/u2/emacs/lisp/simple.el'. Alternatively,
939: you can kill with `M-DEL' the directory names you don't want (*note
940: Words::.).
941:
942: You can also type an absolute file name, one starting with a slash
943: or a tilde, ignoring the default directory. For example, to find the
944: file `/etc/termcap', just type the name, giving
945:
946: Find File: /u2/emacs/src//etc/termcap
947:
948: Two slashes in a row are not normally meaningful in Unix file names, but
949: they are allowed in GNU Emacs. They mean, "ignore everything before the
950: second slash in the pair." Thus, `/u2/emacs/src/' is ignored, and you
951: get the file `/etc/termcap'.
952:
953: If you set `insert-default-directory' to `nil', the default directory
954: is not inserted in the minibuffer. This way, the minibuffer starts out
955: empty. But the name you type, if relative, is still interpreted with
956: respect to the same default directory.
957:
958:
959: File: emacs, Node: Minibuffer Edit, Next: Completion, Prev: Minibuffer File, Up: Minibuffer
960:
961: Editing in the Minibuffer
962: =========================
963:
964: The minibuffer is an Emacs buffer (albeit a peculiar one), and the
965: usual Emacs commands are available for editing the text of an argument
966: you are entering.
967:
968: Since RET in the minibuffer is defined to exit the minibuffer,
969: inserting a newline into the minibuffer must be done with `C-o' or with
970: `C-q LFD'. (Recall that a newline is really the LFD character.)
971:
972: The minibuffer has its own window which always has space on the
973: screen but acts as if it were not there when the minibuffer is not in
974: use. When the minibuffer is in use, its window is just like the
975: others; you can switch to another window with `C-x o', edit text in
976: other windows and perhaps even visit more files, before returning to
977: the minibuffer to submit the argument. You can kill text in another
978: window, return to the minibuffer window, and then yank the text to use
979: it in the argument. *Note Windows::.
980:
981: There are some restrictions on the use of the minibuffer window,
982: however. You cannot switch buffers in it--the minibuffer and its window
983: are permanently attached. Also, you cannot split or kill the minibuffer
984: window. But you can make it taller in the normal fashion with `C-x ^'
985: (*note Change Window::.).
986:
987: If while in the minibuffer you issue a command that displays help
988: text of any sort in another window, then that window is identified as
989: the one to scroll if you type `C-M-v' while in the minibuffer. This
990: lasts until you exit the minibuffer. This feature comes into play if a
991: completing minibuffer gives you a list of possible completions.
992:
993: Recursive use of the minibuffer is supported by Emacs. However, it
994: is easy to do this by accident (because of autorepeating keyboards, for
995: example) and get confused. Therefore, most Emacs commands that use the
996: minibuffer refuse to operate if the minibuffer window is selected. If
997: the minibuffer is active but you have switched to a different window,
998: recursive use of the minibuffer is allowed--if you know enough to try
999: to do this, you probably will not get confused.
1000:
1001: If you set the variable `enable-recursive-minibuffers' to be
1002: non-`nil', recursive use of the minibuffer is always allowed.
1003:
1004:
1005: File: emacs, Node: Completion, Next: Repetition, Prev: Minibuffer Edit, Up: Minibuffer
1006:
1007: Completion
1008: ==========
1009:
1010: When appropriate, the minibuffer provides a "completion" facility.
1011: This means that you type enough of the argument to determine the rest,
1012: based on Emacs's knowledge of which arguments make sense, and Emacs
1013: visibly fills in the rest, or as much as can be determined from the
1014: part you have typed.
1015:
1016: When completion is available, certain keys--TAB, RET, and SPC--are
1017: redefined to complete an abbreviation present in the minibuffer into a
1018: longer string that it stands for, by matching it against a set of
1019: "completion alternatives" provided by the command reading the argument.
1020: `?' is defined to display a list of possible completions of what you
1021: have inserted.
1022:
1023: For example, when the minibuffer is being used by `Meta-x' to read
1024: the name of a command, it is given a list of all available Emacs command
1025: names to complete against. The completion keys match the text in the
1026: minibuffer against all the command names, find any additional
1027: characters of the name that are implied by the ones already present in
1028: the minibuffer, and add those characters to the ones you have given.
1029:
1030: Case is normally significant in completion, because it is
1031: significant in most of the names that you can complete (buffer names,
1032: file names and command names). Thus, `fo' will not complete to `Foo'.
1033: When you are completing a name in which case does not matter, case may
1034: be ignored for completion's sake if the program said to do so.
1035:
1036: Completion Example
1037: ------------------
1038:
1039: A concrete example may help here. If you type `Meta-x au TAB', the
1040: TAB looks for alternatives (in this case, command names) that start
1041: with `au'. There are only two: `auto-fill-mode' and `auto-save-mode'.
1042: These are the same as far as `auto-', so the `au' in the minibuffer
1043: changes to `auto-'.
1044:
1045: If you type TAB again immediately, there are multiple possibilities
1046: for the very next character--it could be `s' or `f'--so no more
1047: characters are added; but a list of all possible completions is
1048: displayed in another window.
1049:
1050: If you go on to type `f TAB', this TAB sees `auto-f'. The only
1051: command name starting this way is `auto-fill-mode', so completion
1052: inserts the rest of that. You now have `auto-fill-mode' in the
1053: minibuffer after typing just `au TAB f TAB'. Note that TAB has this
1054: effect because in the minibuffer it is bound to the function
1055: `minibuffer-complete' when completion is supposed to be done.
1056:
1057: Completion Commands
1058: -------------------
1059:
1060: Here is a list of all the completion commands, defined in the
1061: minibuffer when completion is available.
1062:
1063: `TAB'
1064: Complete the text in the minibuffer as much as possible
1065: (`minibuffer-complete').
1066:
1067: `SPC'
1068: Complete the text in the minibuffer but don't add or fill out more
1069: than one word (`minibuffer-complete-word').
1070:
1071: `RET'
1072: Submit the text in the minibuffer as the argument, possibly
1073: completing first as described below
1074: (`minibuffer-complete-and-exit').
1075:
1076: `?'
1077: Print a list of all possible completions of the text in the
1078: minibuffer (`minibuffer-list-completions').
1079:
1080: SPC completes much like TAB, but never goes beyond the next hyphen
1081: or space. If you have `auto-f' in the minibuffer and type SPC, it
1082: finds that the completion is `auto-fill-mode', but it stops completing
1083: after `fill-'. This gives `auto-fill-'. Another SPC at this point
1084: completes all the way to `auto-fill-mode'. SPC in the minibuffer runs
1085: the function `minibuffer-complete-word' when completion is available.
1086:
1087: There are three different ways that RET can work in completing
1088: minibuffers, depending on how the argument will be used.
1089:
1090: * "Strict" completion is used when it is meaningless to give any
1091: argument except one of the known alternatives. For example, when
1092: `C-x k' reads the name of a buffer to kill, it is meaningless to
1093: give anything but the name of an existing buffer. In strict
1094: completion, RET refuses to exit if the text in the minibuffer does
1095: not complete to an exact match.
1096:
1097: * "Cautious" completion is similar to strict completion, except that
1098: RET exits only if the text was an exact match already, not needing
1099: completion. If the text is not an exact match, RET does not exit,
1100: but it does complete the text. If it completes to an exact match,
1101: a second RET will exit.
1102:
1103: Cautious completion is used for reading file names for files that
1104: must already exist.
1105:
1106: * "Permissive" completion is used when any string whatever is
1107: meaningful, and the list of completion alternatives is just a
1108: guide. For example, when `C-x C-f' reads the name of a file to
1109: visit, any file name is allowed, in case you want to create a
1110: file. In permissive completion, RET takes the text in the
1111: minibuffer exactly as given, without completing it.
1112:
1113: The completion commands display a list of all possible completions
1114: in a window whenever there is more than one possibility for the very
1115: next character. Also, typing `?' explicitly requests such a list. The
1116: list of completions counts as help text, so `C-M-v' typed in the
1117: minibuffer scrolls the list.
1118:
1119: When completion is done on file names, certain file names are usually
1120: ignored. The variable `completion-ignored-extensions' contains a list
1121: of strings; a file whose name ends in any of those strings is ignored
1122: as a possible completion. The standard value of this variable has
1123: several elements including `".o"', `".elc"', `".dvi"' and `"~"'. The
1124: effect is that, for example, `foo' can complete to `foo.c' even though
1125: `foo.o' exists as well. If the only possible completions are files
1126: that end in "ignored" strings, then they are not ignored.
1127:
1128: Normally, a completion command that finds the next character is
1129: undetermined automatically displays a list of all possible completions.
1130: If the variable `completion-auto-help' is set to `nil', this does not
1131: happen, and you must type `?' to display the possible completions.
1132:
1133:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.