|
|
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: Several Buffers, Prev: Kill Buffer, Up: Buffers
27:
28: Operating on Several Buffers
29: ============================
30:
31: The "buffer-menu" facility is like a "Dired for buffers"; it allows
32: you to request operations on various Emacs buffers by editing an Emacs
33: buffer containing a list of them. You can save buffers, kill them
34: (here called "deleting" them, for consistency with Dired), or display
35: them.
36:
37: `M-x buffer-menu'
38: Begin editing a buffer listing all Emacs buffers.
39:
40: The command `buffer-menu' writes a list of all Emacs buffers into
41: the buffer `*Buffer List*', and selects that buffer in Buffer Menu
42: mode. The buffer is read-only, and can only be changed through the
43: special commands described in this section. Most of these commands are
44: graphic characters. The usual Emacs cursor motion commands can be used
45: in the `*Buffer List*' buffer. The following special commands apply to
46: the buffer described on the current line.
47:
48: `d'
49: Request to delete (kill) the buffer, then move down. The request
50: shows as a `D' on the line, before the buffer name. Requested
51: deletions take place when the `x' command is used.
52:
53: `k'
54: Synonym for `d'.
55:
56: `C-d'
57: Like `d' but move up afterwards instead of down.
58:
59: `s'
60: Request to save the buffer. The request shows as an `S' on the
61: line. Requested saves take place when the `x' command is used.
62: You may request both saving and deletion for the same buffer.
63:
64: `~'
65: Mark buffer "unmodified". The command `~' does this immediately
66: when typed.
67:
68: `x'
69: Perform previously requested deletions and saves.
70:
71: `u'
72: Remove any request made for the current line, and move down.
73:
74: `DEL'
75: Move to previous line and remove any request made for that line.
76:
77: All the commands that put in or remove flags to request later
78: operations also move down a line, and accept a numeric argument as a
79: repeat count, unless otherwise specified.
80:
81: There are also special commands to use the buffer list to select
82: another buffer, and to specify one or more other buffers for display in
83: additional windows.
84:
85: `1'
86: Select the buffer in a full-screen window. This command takes
87: effect immediately.
88:
89: `2'
90: Immediately set up two windows, with this buffer in one, and the
91: previously selected buffer (aside from the buffer `*Buffer List*')
92: in the other.
93:
94: `f'
95: Immediately select the buffer in place of the `*Buffer List*'
96: buffer.
97:
98: `o'
99: Immediately select the buffer in another window as if by `C-x 4 b',
100: leaving `*Buffer List*' visible.
101:
102: `q'
103: Immediately select this buffer, and also display in other windows
104: any buffers previously flagged with the `m' command. If there are
105: no such buffers, this command is equivalent to `1'.
106:
107: `m'
108: Flag this buffer to be displayed in another window if the `q'
109: command is used. The request shows as a `>' at the beginning of
110: the line. The same buffer may not have both a delete request and a
111: display request.
112:
113: All that `buffer-menu' does directly is create and select a suitable
114: buffer, and turn on Buffer Menu mode. Everything else described above
115: is implemented by the special commands provided in Buffer Menu mode.
116: One consequence of this is that you can switch from the `*Buffer List*'
117: buffer to another Emacs buffer, and edit there. You can reselect the
118: `buffer-menu' buffer later, to perform the operations already
119: requested, or you can kill it, or pay no further attention to it.
120:
121: The only difference between `buffer-menu' and `list-buffers' is that
122: `buffer-menu' selects the `*Buffer List*' buffer and `list-buffers'
123: does not. If you run `list-buffers' (that is, type `C-x C-b') and
124: select the buffer list manually, you can use all of the commands
125: described here.
126:
127:
128: File: emacs, Node: Windows, Next: Major Modes, Prev: Buffers, Up: Top
129:
130: Multiple Windows
131: ****************
132:
133: Emacs can split the screen into two or many windows, which can
134: display parts of different buffers, or different parts of one buffer.
135:
136: * Menu:
137:
138: * Basic Window:: Introduction to Emacs windows.
139: * Split Window:: New windows are made by splitting existing windows.
140: * Other Window:: Moving to another window or doing something to it.
141: * Pop Up Window:: Finding a file or buffer in another window.
142: * Change Window:: Deleting windows and changing their sizes.
143:
144:
145: File: emacs, Node: Basic Window, Next: Split Window, Prev: Windows, Up: Windows
146:
147: Concepts of Emacs Windows
148: =========================
149:
150: When multiple windows are being displayed, each window has an Emacs
151: buffer designated for display in it. The same buffer may appear in more
152: than one window; if it does, any changes in its text are displayed in
153: all the windows where it appears. But the windows showing the same
154: buffer can show different parts of it, because each window has its own
155: value of point.
156:
157: At any time, one of the windows is the "selected window"; the buffer
158: this window is displaying is the current buffer. The terminal's cursor
159: shows the location of point in this window. Each other window has a
160: location of point as well, but since the terminal has only one cursor
161: there is no way to show where those locations are.
162:
163: Commands to move point affect the value of point for the selected
164: Emacs window only. They do not change the value of point in any other
165: Emacs window, even one showing the same buffer. The same is true for
166: commands such as `C-x b' to change the selected buffer in the selected
167: window; they do not affect other windows at all. However, there are
168: other commands such as `C-x 4 b' that select a different window and
169: switch buffers in it. Also, all commands that display information in a
170: window, including (for example) `C-h f' (`describe-function') and `C-x
171: C-b' (`list-buffers'), work by switching buffers in a nonselected window
172: without affecting the selected window.
173:
174: Each window has its own mode line, which displays the buffer name,
175: modification status and major and minor modes of the buffer that is
176: displayed in the window. *Note Mode Line::, for full details on the
177: mode line.
178:
179:
180: File: emacs, Node: Split Window, Next: Other Window, Prev: Basic Window, Up: Windows
181:
182: Splitting Windows
183: =================
184:
185: `C-x 2'
186: Split the selected window into two windows, one above the other
187: (`split-window-vertically').
188:
189: `C-x 5'
190: Split the selected window into two windows positioned side by side
191: (`split-window-horizontally').
192:
193: The command `C-x 2' (`split-window-vertically') breaks the selected
194: window into two windows, one above the other. Both windows start out
195: displaying the same buffer, with the same value of point. By default
196: the two windows each get half the height of the window that was split; a
197: numeric argument specifies how many lines to give to the top window.
198:
199: `C-x 5' (`split-window-horizontally') breaks the selected window
200: into two side-by-side windows. A numeric argument specifies how many
201: columns to give the one on the left. A line of vertical bars separates
202: the two windows. Windows that are not the full width of the screen
203: have mode lines, but they are truncated; also, they do not always
204: appear in inverse video, because, the Emacs display routines have not
205: been taught how to display a region of inverse video that is only part
206: of a line on the screen.
207:
208: When a window is less than the full width, text lines too long to
209: fit are frequent. Continuing all those lines might be confusing. The
210: variable `truncate-partial-width-windows' can be set non-`nil' to force
211: truncation in all windows less than the full width of the screen,
212: independent of the buffer being displayed and its value for
213: `truncate-lines'. *Note Continuation Lines::.
214:
215: Horizontal scrolling is often used in side-by-side windows. *Note
216: Display::.
217:
218:
219: File: emacs, Node: Other Window, Next: Pop Up Window, Prev: Split Window, Up: Windows
220:
221: Using Other Windows
222: ===================
223:
224: `C-x o'
225: Select another window (`other-window'). That is `o', not zero.
226:
227: `C-M-v'
228: Scroll the next window (`scroll-other-window').
229:
230: `M-x compare-windows'
231: Find next place where the text in the selected window does not
232: match the text in the next window.
233:
234: To select a different window, use `C-x o' (`other-window'). That is
235: an `o', for `other', not a zero. When there are more than two windows,
236: this command moves through all the windows in a cyclic order, generally
237: top to bottom and left to right. From the rightmost and bottommost
238: window, it goes back to the one at the upper left corner. A numeric
239: argument means to move several steps in the cyclic order of windows. A
240: negative argument moves around the cycle in the opposite order. When
241: the minibuffer is active, the minibuffer is the last window in the
242: cycle; you can switch from the minibuffer window to one of the other
243: windows, and later switch back and finish supplying the minibuffer
244: argument that is requested. *Note Minibuffer Edit::.
245:
246: The usual scrolling commands (*note Display::.) apply to the selected
247: window only, but there is one command to scroll the next window.
248: `C-M-v' (`scroll-other-window') scrolls the window that `C-x o' would
249: select. It takes arguments, positive and negative, like `C-v'.
250:
251: The command `M-x compare-windows' compares the text in the current
252: window with that in the next window. Comparison starts at point in each
253: window. Point moves forward in each window, a character at a time in
254: each window, until the next characters in the two windows are
255: different. Then the command is finished.
256:
257:
258: File: emacs, Node: Pop Up Window, Next: Change Window, Prev: Other Window, Up: Windows
259:
260: Displaying in Another Window
261: ============================
262:
263: `C-x 4' is a prefix key for commands that select another window
264: (splitting the window if there is only one) and select a buffer in that
265: window. Different `C-x 4' commands have different ways of finding the
266: buffer to select.
267:
268: `C-x 4 b BUFNAME RET'
269: Select buffer BUFNAME in another window. This runs
270: `switch-to-buffer-other-window'.
271:
272: `C-x 4 f FILENAME RET'
273: Visit file FILENAME and select its buffer in another window. This
274: runs `find-file-other-window'. *Note Visiting::.
275:
276: `C-x 4 d DIRECTORY RET'
277: Select a Dired buffer for directory DIRECTORY in another window.
278: This runs `dired-other-window'. *Note Dired::.
279:
280: `C-x 4 m'
281: Start composing a mail message in another window. This runs
282: `mail-other-window', and its same-window version is `C-x m' (*note
283: Sending Mail::.).
284:
285: `C-x 4 .'
286: Find a tag in the current tag table in another window. This runs
287: `find-tag-other-window', the multiple-window variant of `M-.'
288: (*note Tags::.).
289:
290:
291: File: emacs, Node: Change Window, Prev: Pop Up Window, Up: Windows
292:
293: Deleting and Rearranging Windows
294: ================================
295:
296: `C-x 0'
297: Get rid of the selected window (`kill-window'). That is a zero.
298:
299: `C-x 1'
300: Get rid of all windows except the selected one
301: (`delete-other-windows').
302:
303: `C-x ^'
304: Make the selected window taller, at the expense of the other(s)
305: (`enlarge-window').
306:
307: `C-x }'
308: Widen the selected window (`enlarge-window-horizontally').
309:
310: To delete a window, type `C-x 0' (`delete-window'). (That is a
311: zero.) The space occupied by the deleted window is distributed among
312: the other active windows (but not the minibuffer window, even if that
313: is active at the time). Once a window is deleted, its attributes are
314: forgotten; there is no automatic way to make another window of the same
315: shape or showing the same buffer. But the buffer continues to exist,
316: and you can select it in any window with `C-x b'.
317:
318: `C-x 1' (`delete-other-windows') is more powerful than `C-x 0'; it
319: deletes all the windows except the selected one (and the minibuffer);
320: the selected window expands to use the whole screen except for the echo
321: area.
322:
323: To readjust the division of space among existing windows, use `C-x ^'
324: (`enlarge-window'). It makes the currently selected window get one
325: line bigger, or as many lines as is specified with a numeric argument.
326: With a negative argument, it makes the selected window smaller. `C-x
327: }' (`enlarge-window-horizontally') makes the selected window wider by
328: the specified number of columns. The extra screen space given to a
329: window comes from one of its neighbors, if that is possible; otherwise,
330: all the competing windows are shrunk in the same proportion. If this
331: makes any windows too small, those windows are deleted and their space
332: is divided up. The minimum size is specified by the variables
333: `window-min-height' and `window-min-width'.
334:
335:
336: File: emacs, Node: Major Modes, Next: Indentation, Prev: Windows, Up: Top
337:
338: Major Modes
339: ***********
340:
341: Emacs has many different "major modes", each of which customizes
342: Emacs for editing text of a particular sort. The major modes are
343: mutually exclusive, and each buffer has one major mode at any time.
344: The mode line normally contains the name of the current major mode, in
345: parentheses. *Note Mode Line::.
346:
347: The least specialized major mode is called "Fundamental mode". This
348: mode has no mode-specific redefinitions or variable settings, so that
349: each Emacs command behaves in its most general manner, and each option
350: is in its default state. For editing any specific type of text, such
351: as Lisp code or English text, you should switch to the appropriate
352: major mode, such as Lisp mode or Text mode.
353:
354: Selecting a major mode changes the meanings of a few keys to become
355: more specifically adapted to the language being edited. The ones which
356: are changed frequently are TAB, DEL, and LFD. In addition, the
357: commands which handle comments use the mode to determine how comments
358: are to be delimited. Many major modes redefine the syntactical
359: properties of characters appearing in the buffer. *Note Syntax::.
360:
361: The major modes fall into three major groups. Lisp mode (which has
362: several variants), C mode and Muddle mode are for specific programming
363: languages. Text mode, Nroff mode, TeX mode and Outline mode are for
364: editing English text. The remaining major modes are not intended for
365: use on users' files; they are used in buffers created for specific
366: purposes by Emacs, such as Dired mode for buffers made by Dired (*note
367: Dired::.), and Mail mode for buffers made by `C-x m' (*note Sending
368: Mail::.), and Shell mode for buffers used for communicating with an
369: inferior shell process (*note Interactive Shell::.).
370:
371: Most programming language major modes specify that only blank lines
372: separate paragraphs. This is so that the paragraph commands remain
373: useful. *Note Paragraphs::. They also cause Auto Fill mode to use the
374: definition of TAB to indent the new lines it creates. This is because
375: most lines in a program are usually indented. *Note Indentation::.
376:
377: * Menu:
378:
379: * Choosing Modes:: How major modes are specified or chosen.
380:
381:
382: File: emacs, Node: Choosing Modes, Prev: Major Modes, Up: Major Modes
383:
384: How Major Modes are Chosen
385: ==========================
386:
387: You can select a major mode explicitly for the current buffer, but
388: most of the time Emacs determines which mode to use based on the file
389: name or some text in the file.
390:
391: Explicit selection of a new major mode is done with a `M-x' command.
392: From the name of a major mode, add `-mode' to get the name of a command
393: to select that mode. Thus, you can enter Lisp mode by executing `M-x
394: lisp-mode'.
395:
396: When you visit a file, Emacs usually chooses the right major mode
397: based on the file's name. For example, files whose names end in `.c'
398: are edited in C mode. The correspondence between file names and major
399: mode is controlled by the variable `auto-mode-alist'. Its value is a
400: list in which each element has the form
401:
402: (REGEXP . MODE-FUNCTION)
403:
404: For example, one element normally found in the list has the form
405: `("\\.c$" . c-mode)', and it is responsible for selecting C mode for
406: files whose names end in `.c'. (Note that `\\' is needed in Lisp
407: syntax to include a `\' in the string, which is needed to suppress the
408: special meaning of `.' in regexps.) The only practical way to change
409: this variable is with Lisp code.
410:
411: You can specify which major mode should be used for editing a certain
412: file by a special sort of text in the first nonblank line of the file.
413: The mode name should appear in this line both preceded and followed by
414: `-*-'. Other text may appear on the line as well. For example,
415:
416: ;-*-Lisp-*-
417:
418: tells Emacs to use Lisp mode. Note how the semicolon is used to make
419: Lisp treat this line as a comment. Such an explicit specification
420: overrides any defaulting based on the file name.
421:
422: Another format of mode specification is
423:
424: -*-Mode: MODENAME;-*-
425:
426: which allows other things besides the major mode name to be specified.
427: However, Emacs does not look for anything except the mode name.
428:
429: The major mode can also be specified in a local variables list.
430: *Note File Variables::.
431:
432: When a file is visited that does not specify a major mode to use, or
433: when a new buffer is created with `C-x b', the major mode used is that
434: specified by the variable `default-major-mode'. Normally this value is
435: the symbol `fundamental-mode', which specifies Fundamental mode. If
436: `default-major-mode' is `nil', the major mode is taken from the
437: previously selected buffer.
438:
439: The command `M-x normal-mode' recalculates the major mode from the
440: visited file name and the contents of the buffer.
441:
442:
443: File: emacs, Node: Indentation, Next: Text, Prev: Major Modes, Up: Top
444:
445: Indentation
446: ***********
447:
448: `TAB'
449: Indent current line "appropriately" in a mode-dependent fashion.
450:
451: `LFD'
452: Perform RET followed by TAB (`newline-and-indent').
453:
454: `M-^'
455: Merge two lines (`delete-indentation'). This would cancel out the
456: effect of LFD.
457:
458: `C-M-o'
459: Split line at point; text on the line after point becomes a new
460: line indented to the same column that it now starts in
461: (`split-line').
462:
463: `M-m'
464: Move (forward or back) to the first nonblank character on the
465: current line (`back-to-indentation').
466:
467: `C-M-\'
468: Indent several lines to same column (`indent-region').
469:
470: `C-x TAB'
471: Shift block of lines rigidly right or left (`indent-rigidly').
472:
473: `M-i'
474: Indent from point to the next prespecified tab stop column
475: (`tab-to-tab-stop').
476:
477: `M-x indent-relative'
478: Indent from point to under an indentation point in the previous
479: line.
480:
481: Most programming languages have some indentation convention. For
482: Lisp code, lines are indented according to their nesting in
483: parentheses. The same general idea is used for C code, though many
484: details are different.
485:
486: Whatever the language, to indent a line, use the TAB command. Each
487: major mode defines this command to perform the sort of indentation
488: appropriate for the particular language. In Lisp mode, TAB aligns the
489: line according to its depth in parentheses. No matter where in the
490: line you are when you type TAB, it aligns the line as a whole. In C
491: mode, TAB implements a subtle and sophisticated indentation style that
492: knows about many aspects of C syntax.
493:
494: In Text mode, TAB runs the command `tab-to-tab-stop', which indents
495: to the next tab stop column. You can set the tab stops with `M-x
496: edit-tab-stops'.
497:
498: * Menu:
499:
500: * Indentation Commands:: Various commands and techniques for indentation.
501: * Tab Stops:: You can set arbitrary "tab stops" and then
502: indent to the next tab stop when you want to.
503: * Just Spaces:: You can request indentation using just spaces.
504:
505:
506: File: emacs, Node: Indentation Commands, Next: Tab Stops, Prev: Indentation, Up: Indentation
507:
508: Indentation Commands and Techniques
509: ===================================
510:
511: If you just want to insert a tab character in the buffer, you can
512: type `C-q TAB'.
513:
514: To move over the indentation on a line, type `Meta-m'. This command,
515: given anywhere on a line, positions point at the first nonblank
516: character on the line (`back-to-indentation').
517:
518: To insert an indented line before the current line, do `C-a C-o
519: TAB'. To make an indented line after the current line, use `C-e LFD'.
520:
521: `C-M-o' (`split-line') moves the text from point to the end of the
522: line vertically down, so that the current line becomes two lines.
523: `C-M-o' first moves point forward over any spaces and tabs. Then it
524: inserts after point a newline and enough indentation to reach the same
525: column point is on. Point remains before the inserted newline; in this
526: regard, `C-M-o' resembles `C-o'.
527:
528: To join two lines cleanly, use the `Meta-^' (`delete-indentation')
529: command to delete the indentation at the front of the current line, and
530: the line boundary as well. They are replaced by a single space, or by
531: no space if point after joining is at the beginning of a line or before
532: a `)' or after a `('. To delete just the indentation of a line, go to
533: the beginning of the line and use `Meta-\' (`delete-horizontal-space'),
534: which deletes all spaces and tabs around the cursor.
535:
536: There are also commands for changing the indentation of several
537: lines at once. `Control-Meta-\' (`indent-region') gives each line which
538: begins in the region the "usual" indentation by invoking TAB at the
539: beginning of the line. A numeric argument specifies the column to
540: indent to, and each line is shifted left or right so that its first
541: nonblank character appears in that column. `C-x TAB'
542: (`indent-rigidly') moves all of the lines in the region right by its
543: argument (left, for negative arguments). The whole group of lines moves
544: rigidly sideways, which is how the command gets its name.
545:
546: `M-x indent-relative' indents at point based on the previous line
547: (actually, the last nonempty line.) It inserts whitespace at point,
548: moving point, until it is underneath an indentation point in the
549: previous line. An indentation point is the end of a sequence of
550: whitespace or the end of the line. If point is farther right than any
551: indentation point in the previous line, the whitespace before point is
552: deleted and the first indentation point then applicable is used. If no
553: indentation point is applicable even then, `tab-to-tab-stop' is run
554: (see next section).
555:
556: `indent-relative' is the definition of TAB in Indented Text mode.
557: *Note Text::.
558:
559:
560: File: emacs, Node: Tab Stops, Next: Just Spaces, Prev: Indentation Commands, Up: Indentation
561:
562: Tab Stops
563: =========
564:
565: For typing in tables, you can use Text mode's definition of TAB,
566: `tab-to-tab-stop'. This command inserts indentation before point,
567: enough to reach the next tab stop column. If you are not in Text mode,
568: this function can be found on `M-i' anyway.
569:
570: The tab stops used by `M-i' can be set arbitrarily by the user. They
571: are stored in a variable called `tab-stop-list', as a list of
572: column-numbers in increasing order.
573:
574: The convenient way to set the tab stops is using `M-x
575: edit-tab-stops', which creates and selects a buffer containing a
576: description of the tab stop settings. You can edit this buffer to
577: specify different tab stops, and then type `C-c C-c' to make those new
578: tab stops take effect. In the tab stop buffer, `C-c C-c' runs the
579: function `edit-tab-stops-note-changes' rather than its usual definition
580: `save-buffer'. `edit-tab-stops' records which buffer was current when
581: you invoked it, and stores the tab stops back in that buffer; normally
582: all buffers share the same tab stops and changing them in one buffer
583: affects all, but if you happen to make `tab-stop-list' local in one
584: buffer then `edit-tab-stops' in that buffer will edit the local
585: settings.
586:
587: Here is what the text representing the tab stops looks like for
588: ordinary tab stops every eight columns.
589:
590: : : : : : :
591: 0 1 2 3 4
592: 0123456789012345678901234567890123456789012345678
593: To install changes, type C-c C-c
594:
595: The first line contains a colon at each tab stop. The remaining
596: lines are present just to help you see where the colons are and know
597: what to do.
598:
599: Note that the tab stops that control `tab-to-tab-stop' have nothing
600: to do with displaying tab characters in the buffer. *Note Display
601: Vars::, for more information on that.
602:
603:
604: File: emacs, Node: Just Spaces, Prev: Tab Stops, Up: Indentation
605:
606: Tabs vs. Spaces
607: ===============
608:
609: Emacs normally uses both tabs and spaces to indent lines. If you
610: prefer, all indentation can be made from spaces only. To request this,
611: set `indent-tabs-mode' to `nil'. This is a per-buffer variable;
612: altering the variable affects only the current buffer, but there is a
613: default value which you can change as well. *Note Locals::.
614:
615: There are also commands to convert tabs to spaces or vice versa,
616: always preserving the columns of all nonblank text. `M-x tabify' scans
617: the region for sequences of spaces, and converts sequences of at least
618: three spaces to tabs if that can be done without changing indentation.
619: `M-x untabify' changes all tabs in the region to appropriate numbers of
620: spaces.
621:
622:
623: File: emacs, Node: Text, Next: Programs, Prev: Indentation, Up: Top
624:
625: Commands for Human Languages
626: ****************************
627:
628: The term "text" has two widespread meanings in our area of the
629: computer field. One is data that is a sequence of characters. Any file
630: that you edit with Emacs is text, in this sense of the word. The other
631: meaning is more restrictive: a sequence of characters in a human
632: language for humans to read (possibly after processing by a text
633: formatter), as opposed to a program or commands for a program.
634:
635: Human languages have syntactic/stylistic conventions that can be
636: supported or used to advantage by editor commands: conventions involving
637: words, sentences, paragraphs, and capital letters. This chapter
638: describes Emacs commands for all of these things. There are also
639: commands for "filling", or rearranging paragraphs into lines of
640: approximately equal length. The commands for moving over and killing
641: words, sentences and paragraphs, while intended primarily for editing
642: text, are also often useful for editing programs.
643:
644: Emacs has several major modes for editing human language text. If
645: the file contains text pure and simple, use Text mode, which customizes
646: Emacs in small ways for the syntactic conventions of text. For text
647: which contains embedded commands for text formatters, Emacs has other
648: major modes, each for a particular text formatter. Thus, for input to
649: TeX, you would use TeX mode; for input to nroff, Nroff mode.
650:
651: * Menu:
652:
653: * Text Mode:: The major modes for editing text files.
654: * Nroff Mode:: The major mode for editing input to the formatter nroff.
655: * TeX Mode:: The major modes for editing input to the formatter TeX.
656: * Outline Mode::The major mode for editing outlines.
657: * Words:: Moving over and killing words.
658: * Sentences:: Moving over and killing sentences.
659: * Paragraphs:: Moving over paragraphs.
660: * Pages:: Moving over pages.
661: * Filling:: Filling or justifying text
662: * Case:: Changing the case of text
663:
664:
665: File: emacs, Node: Text Mode, Next: Words, Prev: Text, Up: Text
666:
667: Text Mode
668: =========
669:
670: Editing files of text in a human language ought to be done using Text
671: mode rather than Lisp or Fundamental mode. Invoke `M-x text-mode' to
672: enter Text mode. In Text mode, TAB runs the function
673: `tab-to-tab-stop', which allows you to use arbitrary tab stops set with
674: `M-x edit-tab-stops' (*note Tab Stops::.). Features concerned with
675: comments in programs are turned off except when explicitly invoked. The
676: syntax table is changed so that periods are not considered part of a
677: word, while apostrophes, backspaces and underlines are.
678:
679: A similar variant mode is Indented Text mode, intended for editing
680: text in which most lines are indented. This mode defines TAB to run
681: `indent-relative' (*note Indentation::.), and makes Auto Fill indent
682: the lines it creates. The result is that normally a line made by Auto
683: Filling, or by LFD, is indented just like the previous line. Use `M-x
684: indented-text-mode' to select this mode.
685:
686: Entering Text mode or Indented Text mode calls with no arguments the
687: value of the variable `text-mode-hook', if that value exists and is not
688: `nil'. This value is also called when modes related to Text mode are
689: entered; this includes Nroff mode, TeX mode, Outline mode and Mail
690: mode. Your hook can look at the value of `major-mode' to see which of
691: these modes is actually being entered.
692:
693: * Menu:
694:
695: Three modes similar to Text mode are of use for editing text that is to
696: be passed through a text formatter before achieving the form in which
697: humans are to read it.
698:
699: * Nroff Mode:: The nroff formatter typesets text.
700: * TeX Mode:: The TeX formatter typesets text and mathematics.
701: * Texinfo Mode::Texinfo provides both on-line information and printed output
702: from the same source file.
703:
704: Another similar mode is used for editing outlines. It allows you
705: to view the text at various levels of detail. You can view either
706: the outline headings alone or both headings and text; you can also
707: hide some of the headings at lower levels from view to make the high
708: level structure more visible.
709:
710: * Outline Mode::The major mode for editing outlines.
711:
712:
713: File: emacs, Node: Nroff Mode, Next: TeX Mode, Prev: Text Mode, Up: Text Mode
714:
715: Nroff Mode
716: ----------
717:
718: Nroff mode is a mode like Text mode but modified to handle nroff
719: commands present in the text. Invoke `M-x nroff-mode' to enter this
720: mode. It differs from Text mode in only a few ways. All nroff command
721: lines are considered paragraph separators, so that filling will never
722: garble the nroff commands. Pages are separated by `.bp' commands.
723: Comments start with backslash-doublequote. Also, three special
724: commands are provided that are not in Text mode:
725:
726: `M-n'
727: Move to the beginning of the next line that isn't an nroff command
728: (`forward-text-line'). An argument is a repeat count.
729:
730: `M-p'
731: Like `M-n' but move up (`backward-text-line').
732:
733: `M-?'
734: Prints in the echo area the number of text lines (lines that are
735: not nroff commands) in the region (`count-text-lines').
736:
737: The other feature of Nroff mode is Electric Nroff newline mode. This
738: is a minor mode that you can turn on or off with `M-x
739: electric-nroff-mode' (*note Minor Modes::.). When the mode is on, each
740: time you use RET to end a line that contains an nroff command that
741: opens a kind of grouping, it also inserts the matching nroff command to
742: close that grouping, on the following line. For example, if you are at
743: the beginning of a line and type `. ( b RET', this inserts the matching
744: command `.)b' on a new line following point.
745:
746: Entering Nroff mode calls with no arguments the value of the variable
747: `text-mode-hook', if that value exists and is not `nil'; then it does
748: the same with the variable `nroff-mode-hook'.
749:
750:
751: File: emacs, Node: TeX Mode, Next: Texinfo Mode, Prev: Nroff Mode, Up: Text Mode
752:
753: TeX Mode
754: --------
755:
756: TeX is a powerful text formatter written by Donald Knuth; it is also
757: free, like GNU Emacs. LaTeX is a simplified input format for TeX,
758: implemented by TeX macros. It comes with TeX.
759:
760: Emacs has a special TeX mode for editing TeX input files. It
761: provides facilities for checking the balance of delimiters and for
762: invoking TeX on all or part of the file.
763:
764: TeX mode has two variants, Plain TeX mode and LaTeX mode (actually
765: two distinct major modes which differ only slightly). They are
766: designed for editing the two different input formats. The command `M-x
767: tex-mode' looks at the contents of the buffer to determine whether the
768: contents appear to be LaTeX input or not; it then selects the
769: appropriate mode. If it can't tell which is right (e.g., the buffer is
770: empty), the variable `TeX-default-mode' controls which mode is used.
771:
772: The commands `M-x plain-tex-mode' and `M-x latex-mode' explicitly
773: select the two variants of TeX mode. Use these commands when `M-x
774: tex-mode' does not guess right.
775:
776: * Menu:
777:
778: * Editing: TeX Editing. Special commands for editing in TeX mode.
779: * Printing: TeX Print. Commands for printing part of a file with TeX.
780:
781: TeX for Unix systems can be obtained from the University of
782: Washington for a distribution fee.
783:
784: To order a full distribution, send $200.00 for a 1/2-inch 9-track
785: 1600 bpi (`tar' or `cpio') tape reel, or $210.00 for a 1/4-inch 4-track
786: QIC-24 (`tar' or `cpio') cartridge, to:
787:
788: Northwest Computing Support Center
789: DR-10, Thomson Hall 35
790: University of Washington
791: Seattle, Washington 98195
792:
793: Please make checks payable to the University of Washington.
794:
795: Prepaid orders are preferred but purchase orders are acceptable;
796: however, purchase orders carry an extra charge of $10.00, to pay for
797: processing.
798:
799: Overseas sites: please add to the base cost $20.00 for shipment via
800: air parcel post, or $30.00 for shipment via courier.
801:
802: Please check with the Northwest Computing Support Center at the
803: University of Washington for current prices and formats:
804:
805: telephone: (206) 543-6259
806: email: [email protected]
807:
808:
809: File: emacs, Node: TeX Editing, Next: TeX Print, Prev: TeX Mode, Up: TeX Mode
810:
811: TeX Editing Commands
812: ....................
813:
814: Here are the special commands provided in TeX mode for editing the
815: text of the file.
816:
817: `"'
818: Insert, according to context, either ```' or `"' or `'''
819: (`TeX-insert-quote').
820:
821: `LFD'
822: Insert a paragraph break (two newlines) and check the previous
823: paragraph for unbalanced braces or dollar signs
824: (`TeX-terminate-paragraph').
825:
826: `M-x validate-TeX-buffer'
827: Check each paragraph in the buffer for unbalanced braces or dollar
828: signs.
829:
830: `M-{'
831: Insert `{}' and position point between them (`TeX-insert-braces').
832:
833: `M-}'
834: Move forward past the next unmatched close brace (`up-list').
835:
836: `C-c C-f'
837: Close a block for LaTeX (`TeX-close-LaTeX-block').
838:
839: In TeX, the character `"' is not normally used; use ```' to start a
840: quotation and `''' to end one. TeX mode defines the key `"' to insert
841: ```' after whitespace or an open brace, `"' after a backslash, or `'''
842: otherwise. This is done by the command `TeX-insert-quote'. If you
843: need the character `"' itself in unusual contexts, use `C-q' to insert
844: it. Also, `"' with a numeric argument always inserts that number of
845: `"' characters.
846:
847: In TeX mode, `$' has a special syntax code which attempts to
848: understand the way TeX math mode delimiters match. When you insert a
849: `$' that is meant to exit math mode, the position of the matching `$'
850: that entered math mode is displayed for a second. This is the same
851: feature that displays the open brace that matches a close brace that is
852: inserted. However, there is no way to tell whether a `$' enters math
853: mode or leaves it; so when you insert a `$' that enters math mode, the
854: previous `$' position is shown as if it were a match, even though they
855: are actually unrelated.
856:
857: If you prefer to keep braces balanced at all times, you can use `M-{'
858: (`TeX-insert-braces') to insert a pair of braces. It leaves point
859: between the two braces so you can insert the text that belongs inside.
860: Afterward, use the command `M-}' (`up-list') to move forward past the
861: close brace.
862:
863: There are two commands for checking the matching of braces. LFD
864: (`TeX-terminate-paragraph') checks the paragraph before point, and
865: inserts two newlines to start a new paragraph. It prints a message in
866: the echo area if any mismatch is found. `M-x validate-TeX-buffer'
867: checks the entire buffer, paragraph by paragraph. When it finds a
868: paragraph that contains a mismatch, it displays point at the beginning
869: of the paragraph for a few seconds and pushes a mark at that spot.
870: Scanning continues until the whole buffer has been checked or until you
871: type another key. The positions of the last several paragraphs with
872: mismatches can be found in the mark ring (*note Mark Ring::.).
873:
874: Note that square brackets and parentheses are matched in TeX mode,
875: not just braces. This is wrong for the purpose of checking TeX syntax.
876: However, parentheses and square brackets are likely to be used in text
877: as matching delimiters and it is useful for the various motion commands
878: and automatic match display to work with them.
879:
880: In LaTeX input, `\begin' and `\end' commands must balance. After you
881: insert a `\begin', use `C-c C-f' (`TeX-close-LaTeX-block') to insert
882: automatically a matching `\end' (on a new line following the `\begin').
883: A blank line is inserted between the two, and point is left there.
884:
885:
886: File: emacs, Node: TeX Print, Prev: TeX Editing, Up: TeX Mode
887:
888: TeX Printing Commands
889: .....................
890:
891: You can invoke TeX as an inferior of Emacs on either the entire
892: contents of the buffer or just a region at a time. Running TeX in this
893: way on just one chapter is a good way to see what your changes look
894: like without taking the time to format the entire file.
895:
896: `C-c C-r'
897: Invoke TeX on the current region, plus the buffer's header
898: (`TeX-region').
899:
900: `C-c C-b'
901: Invoke TeX on the entire current buffer (`TeX-buffer').
902:
903: `C-c C-l'
904: Recenter the window showing output from the inferior TeX so that
905: the last line can be seen (`TeX-recenter-output-buffer').
906:
907: `C-c C-k'
908: Kill the inferior TeX (`TeX-kill-job').
909:
910: `C-c C-p'
911: Print the output from the last `C-c C-r' or `C-c C-b' command
912: (`TeX-print').
913:
914: `C-c C-q'
915: Show the printer queue (`TeX-show-print-queue').
916:
917: You can pass the current buffer through an inferior TeX by means of
918: `C-c C-b' (`TeX-buffer'). The formatted output appears in a file in
919: `/tmp'; to print it, type `C-c C-p' (`TeX-print'). Afterward use `C-c
920: C-q' (`TeX-show-print-queue') to view the progress of your output
921: towards being printed.
922:
923: The console output from TeX, including any error messages, appears
924: in a buffer called `*TeX-shell*'. If TeX gets an error, you can switch
925: to this buffer and feed it input (this works as in Shell mode; *note
926: Interactive Shell::.). Without switching to this buffer you can scroll
927: it so that its last line is visible by typing `C-c C-l'.
928:
929: Type `C-c C-k' (`TeX-kill-job') to kill the TeX process if you see
930: that its output is no longer useful. Using `C-c C-b' or `C-c C-r' also
931: kills any TeX process still running.
932:
933: You can also pass an arbitrary region through an inferior TeX by
934: typing `C-c C-r' (`TeX-region'). This is tricky, however, because most
935: files of TeX input contain commands at the beginning to set parameters
936: and define macros, without which no later part of the file will format
937: correctly. To solve this problem, `C-c C-r' allows you to designate a
938: part of the file as containing essential commands; it is included before
939: the specified region as part of the input to TeX. The designated part
940: of the file is called the "header".
941:
942: To indicate the bounds of the header in Plain TeX mode, you insert
943: two special strings in the file. Insert `%**start of header' before the
944: header, and `%**end of header' after it. Each string must appear
945: entirely on one line, but there may be other text on the line before or
946: after. The lines containing the two strings are included in the header.
947: If `%**start of header' does not appear within the first 100 lines of
948: the buffer, `C-c C-r' assumes that there is no header.
949:
950: In LaTeX mode, the header begins with `\documentstyle' and ends with
951: `\begin{document}'. These are commands that LaTeX requires you to use
952: in any case, so nothing special needs to be done to identify the header.
953:
954: Entering either kind of TeX mode calls with no arguments the value of
955: the variable `text-mode-hook', if that value exists and is not `nil';
956: then it does the same with the variable `TeX-mode-hook'. Finally it
957: does the same with either `plain-TeX-mode-hook' or `LaTeX-mode-hook'.
958:
959:
960: File: emacs, Node: Texinfo Mode, Next: Outline Mode, Prev: TeX Mode, Up: Text Mode
961:
962: Texinfo Mode
963: ------------
964:
965: Texinfo is a documentation system that uses a single source file to
966: produce both on-line information and printed output. This means that
967: instead of writing two different documents, one for the on-line help or
968: other on-line information and the other for a typeset manual or other
969: printed work, you need write only one document. When the work is
970: revised, you need revise only one document. (You can read the on-line
971: information, known as an "Info file", with an Info
972: documentation-reading program. *note info: (info)Top, for more
973: information about Info.) Texinfo is the format in which documentation
974: for GNU utilities and libraries is written.
975:
976: Texinfo mode provides special features for working with Texinfo files
977: including utilities to construct Info menus and pointers automatically,
978: keybindings to insert frequently used formatting commands, and
979: keybindings for commands to format both for Info and for printing.
980:
981: Texinfo mode is described in *Note Using Texinfo Mode: (
982: texinfo)Texinfo Mode.
983:
984:
985: File: emacs, Node: Outline Mode, Prev: Texinfo Mode, Up: Text Mode
986:
987: Outline Mode
988: ------------
989:
990: Outline mode is a major mode much like Text mode but intended for
991: editing outlines. It allows you to make parts of the text temporarily
992: invisible so that you can see just the overall structure of the
993: outline. Type `M-x outline-mode' to turn on Outline mode in the
994: current buffer.
995:
996: Entering Outline mode calls with no arguments the value of the
997: variable `text-mode-hook', if that value exists and is not `nil'; then
998: it does the same with the variable `outline-mode-hook'.
999:
1000: When a line is invisible in outline mode, it does not appear on the
1001: screen. The screen appears exactly as if the invisible line were
1002: deleted, except that an ellipsis (three periods in a row) appears at
1003: the end of the previous visible line (only one ellipsis no matter how
1004: many invisible lines follow).
1005:
1006: All editing commands treat the text of the invisible line as part of
1007: the previous visible line. For example, `C-n' moves onto the next
1008: visible line. Killing an entire visible line, including its
1009: terminating newline, really kills all the following invisible lines
1010: along with it; yanking it all back yanks the invisible lines and they
1011: remain invisible.
1012:
1013: * Menu:
1014:
1015: * Format: Outline Format. What the text of an outline looks like.
1016: * Motion: Outline Motion. Special commands for moving through outlines.
1017: * Visibility: Outline Visibility. Commands to control what is visible.
1018:
1019:
1020: File: emacs, Node: Outline Format, Next: Outline Motion, Prev: Outline Mode, Up: Outline Mode
1021:
1022: Format of Outlines
1023: ..................
1024:
1025: Outline mode assumes that the lines in the buffer are of two types:
1026: "heading lines" and "body lines". A heading line represents a topic in
1027: the outline. Heading lines start with one or more stars; the number of
1028: stars determines the depth of the heading in the outline structure.
1029: Thus, a heading line with one star is a major topic; all the heading
1030: lines with two stars between it and the next one-star heading are its
1031: subtopics; and so on. Any line that is not a heading line is a body
1032: line. Body lines belong to the preceding heading line. Here is an
1033: example:
1034:
1035: * Food
1036:
1037: This is the body,
1038: which says something about the topic of food.
1039:
1040: ** Delicious Food
1041:
1042: This is the body of the second-level header.
1043:
1044: ** Distasteful Food
1045:
1046: This could have
1047: a body too, with
1048: several lines.
1049:
1050: *** Dormitory Food
1051:
1052: * Shelter
1053:
1054: A second first-level topic with its header line.
1055:
1056: A heading line together with all following body lines is called
1057: collectively an "entry". A heading line together with all following
1058: deeper heading lines and their body lines is called a "subtree".
1059:
1060: You can customize the criterion for distinguishing heading lines by
1061: setting the variable `outline-regexp'. Any line whose beginning has a
1062: match for this regexp is considered a heading line. Matches that start
1063: within a line (not at the beginning) do not count. The length of the
1064: matching text determines the level of the heading; longer matches make
1065: a more deeply nested level. Thus, for example, if a text formatter has
1066: commands `@chapter', `@section' and `@subsection' to divide the
1067: document into chapters and sections, you could make those lines count
1068: as heading lines by setting `outline-regexp' to
1069: `"@chap\\|@\\(sub\\)*section"'. Note the trick: the two words `chapter'
1070: and `section' are equally long, but by defining the regexp to match
1071: only `chap' we ensure that the length of the text matched on a chapter
1072: heading is shorter, so that Outline mode will know that sections are
1073: contained in chapters. This works as long as no other command starts
1074: with `@chap'.
1075:
1076: Outline mode makes a line invisible by changing the newline before it
1077: into an ASCII Control-M (code 015). Most editing commands that work on
1078: lines treat an invisible line as part of the previous line because,
1079: strictly speaking, it is part of that line, since there is no longer a
1080: newline in between. When you save the file in Outline mode, Control-M
1081: characters are saved as newlines, so the invisible lines become ordinary
1082: lines in the file. But saving does not change the visibility status of
1083: a line inside Emacs.
1084:
1085:
1086: File: emacs, Node: Outline Motion, Next: Outline Visibility, Prev: Outline Format, Up: Outline Mode
1087:
1088: Outline Motion Commands
1089: .......................
1090:
1091: There are some special motion commands in Outline mode that move
1092: backward and forward to heading lines.
1093:
1094: `C-c C-n'
1095: Move point to the next visible heading line
1096: (`outline-next-visible-heading').
1097:
1098: `C-c C-p'
1099: Move point to the previous visible heading line
1100: (`outline-previous-visible-heading').
1101:
1102: `C-c C-f'
1103: Move point to the next visible heading line at the same level as
1104: the one point is on (`outline-forward-same-level').
1105:
1106: `C-c C-b'
1107: Move point to the previous visible heading line at the same level
1108: (`outline-backward-same-level').
1109:
1110: `C-c C-u'
1111: Move point up to a lower-level (more inclusive) visible heading
1112: line (`outline-up-heading').
1113:
1114: `C-c C-n' (`next-visible-heading') moves down to the next heading
1115: line. `C-c C-p' (`previous-visible-heading') moves similarly backward.
1116: Both accept numeric arguments as repeat counts. The names emphasize
1117: that invisible headings are skipped, but this is not really a special
1118: feature. All editing commands that look for lines ignore the invisible
1119: lines automatically.
1120:
1121: More advanced motion commands understand the levels of headings. The
1122: two commands, `C-c C-f' (`outline-forward-same-level') and `C-c C-b'
1123: (`outline-backward-same-level'), move from one heading line to another
1124: visible heading at the same depth in the outline. `C-c C-u'
1125: (`outline-up-heading') moves backward to another heading that is less
1126: deeply nested.
1127:
1128:
1129: File: emacs, Node: Outline Visibility, Prev: Outline Motion, Up: Outline Mode
1130:
1131: Outline Visibility Commands
1132: ...........................
1133:
1134: The other special commands of outline mode are used to make lines
1135: visible or invisible. Their names all start with `hide' or `show'.
1136: Most of them fall into pairs of opposites. They are not undoable;
1137: instead, you can undo right past them. Making lines visible or
1138: invisible is simply not recorded by the undo mechanism.
1139:
1140: `M-x hide-body'
1141: Make all body lines in the buffer invisible.
1142:
1143: `M-x show-all'
1144: Make all lines in the buffer visible.
1145:
1146: `C-c C-h'
1147: Make everything under this heading invisible, not including this
1148: heading itself (`hide-subtree').
1149:
1150: `C-c C-s'
1151: Make everything under this heading visible, including body,
1152: subheadings, and their bodies (`show-subtree').
1153:
1154: `M-x hide-leaves'
1155: Make the body of this heading line, and of all its subheadings,
1156: invisible.
1157:
1158: `M-x show-branches'
1159: Make all subheadings of this heading line, at all levels, visible.
1160:
1161: `C-c C-i'
1162: Make immediate subheadings (one level down) of this heading line
1163: visible (`show-children').
1164:
1165: `M-x hide-entry'
1166: Make this heading line's body invisible.
1167:
1168: `M-x show-entry'
1169: Make this heading line's body visible.
1170:
1171: Two commands that are exact opposites are `M-x hide-entry' and `M-x
1172: show-entry'. They are used with point on a heading line, and apply
1173: only to the body lines of that heading. The subtopics and their bodies
1174: are not affected.
1175:
1176: Two more powerful opposites are `C-c C-h' (`hide-subtree') and `C-c
1177: C-s' (`show-subtree'). Both expect to be used when point is on a
1178: heading line, and both apply to all the lines of that heading's
1179: "subtree": its body, all its subheadings, both direct and indirect, and
1180: all of their bodies. In other words, the subtree contains everything
1181: following this heading line, up to and not including the next heading of
1182: the same or higher rank.
1183:
1184: Intermediate between a visible subtree and an invisible one is having
1185: all the subheadings visible but none of the body. There are two
1186: commands for doing this, depending on whether you want to hide the
1187: bodies or make the subheadings visible. They are `M-x hide-leaves' and
1188: `M-x show-branches'.
1189:
1190: A little weaker than `show-branches' is `C-c C-i' (`show-children').
1191: It makes just the direct subheadings visible--those one level down.
1192: Deeper subheadings remain invisible, if they were invisible.
1193:
1194: Two commands have a blanket effect on the whole file. `M-x
1195: hide-body' makes all body lines invisible, so that you see just the
1196: outline structure. `M-x show-all' makes all lines visible. These
1197: commands can be thought of as a pair of opposites even though `M-x
1198: show-all' applies to more than just body lines.
1199:
1200: The use of ellipses at the ends of visible lines can be turned off
1201: by setting `selective-display-ellipses' to `nil'. Then there is no
1202: visible indication of the presence of invisible lines.
1203:
1204:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.