|
|
1.1 root 1: Info file emacs, produced by texinfo-format-buffer -*-Text-*-
2: from file emacs.tex
3:
4: This file documents the GNU Emacs editor.
5:
6: Copyright (C) 1985, 1986 Richard M. Stallman.
7:
8: Permission is granted to make and distribute verbatim copies of
9: this manual provided the copyright notice and this permission notice
10: are preserved on all copies.
11:
12: Permission is granted to copy and distribute modified versions of this
13: manual under the conditions for verbatim copying, provided also that the
14: sections entitled "The GNU Manifesto", "Distribution" and "GNU Emacs
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 manual
20: into another language, under the above conditions for modified versions,
21: except that the sections entitled "The GNU Manifesto", "Distribution"
22: and "GNU Emacs General Public License" may be included in a translation
23: approved by the author instead of in the original English.
24:
25:
26: File: emacs Node: Just Spaces, Prev: Tab Stops, Up: Indentation
27:
28: Tabs vs. Spaces
29: ===============
30:
31: Emacs normally uses both tabs and spaces to indent lines. If you prefer,
32: all indentation can be made from spaces only. To request this, set
33: `indent-tabs-mode' to `nil'. This is a per-buffer variable;
34: altering the variable affects only the current buffer, but there is a
35: default value which you can change as well. *Note Locals::.
36:
37: There are also commands to convert tabs to spaces or vice versa, always
38: preserving the columns of all nonblank text. `M-x tabify' scans the
39: region for sequences of spaces, and converts sequences of at least three
40: spaces to tabs if that can be done without changing indentation. `M-x
41: untabify' changes all tabs in the region to appropriate numbers of spaces.
42:
43:
44: File: emacs Node: Text, Prev: Indentation, Up: Top, Next: Programs
45:
46: Commands for Human Languages
47: ****************************
48:
49: The term "text" has two widespread meanings in our area of the
50: computer field. One is data that is a sequence of characters. Any file
51: that you edit with Emacs is text, in this sense of the word. The other
52: meaning is more restrictive: a sequence of characters in a human language
53: for humans to read (possibly after processing by a text formatter), as
54: opposed to a program or commands for a program.
55:
56: Human languages have syntactic/stylistic conventions that can be
57: supported or used to advantage by editor commands: conventions involving
58: words, sentences, paragraphs, and capital letters. This chapter describes
59: Emacs commands for all of these things. There are also commands for
60: "filling", or rearranging paragraphs into lines of approximately equal
61: length. The commands for moving over and killing words, sentences
62: and paragraphs, while intended primarily for editing text, are also often
63: useful for editing programs.
64:
65: Emacs has several major modes for editing human language text.
66: If the file contains text pure and simple, use Text mode, which customizes
67: Emacs in small ways for the syntactic conventions of text. For text which
68: contains embedded commands for text formatters, Emacs has other major modes,
69: each for a particular text formatter. Thus, for input to TeX, you would
70: use TeX mode; for input to nroff, Nroff mode.
71:
72: * Menu:
73:
74: * Text Mode:: The major modes for editing text files.
75: * Nroff Mode:: The major mode for editing input to the formatter nroff.
76: * TeX Mode:: The major modes for editing input to the formatter TeX.
77: * Outline Mode::The major mode for editing outlines.
78: * Words:: Moving over and killing words.
79: * Sentences:: Moving over and killing sentences.
80: * Paragraphs:: Moving over paragraphs.
81: * Pages:: Moving over pages.
82: * Filling:: Filling or justifying text
83: * Case:: Changing the case of text
84:
85:
86: File: emacs Node: Text Mode, Prev: Text, Up: Text, Next: Words
87:
88: Text Mode
89: =========
90:
91: Editing files of text in a human language ought to be done using Text
92: mode rather than Lisp or Fundamental mode. Invoke `M-x text-mode' to
93: enter Text mode. In Text mode, TAB runs the function
94: `tab-to-tab-stop', which allows you to use arbitrary tab stops set
95: with `M-x edit-tab-stops' (*Note Tab Stops::). Features concerned with
96: comments in programs are turned off except when explicitly invoked. The
97: syntax table is changed so that periods are not considered part of a word,
98: while apostrophes, backspaces and underlines are.
99:
100: A similar variant mode is Indented Text mode, intended for editing text
101: in which most lines are indented. This mode defines TAB to run
102: `indent-relative' (*Note Indentation::), and makes Auto Fill indent
103: the lines it creates. The result is that normally a line made by Auto
104: Filling, or by LFD, is indented just like the previous line. Use
105: `M-x indented-text-mode' to select this mode.
106:
107: Entering Text mode or Indented Text mode calls with no arguments the
108: value of the variable `text-mode-hook', if that value exists and is
109: not `nil'. This value is also called when modes related to Text mode
110: are entered; this includes Nroff mode, TeX mode, Outline mode and Mail
111: mode. Your hook can look at the value of `major-mode' to see which of
112: these modes is actually being entered.
113:
114: * Menu:
115:
116: Two modes similar to Text mode are of use for editing text that is to
117: be passed through a text formatter before achieving the form in which
118: humans are to read it.
119:
120: * Nroff Mode:: The major mode for editing input to the formatter nroff.
121: * TeX Mode:: The major modes for editing input to the formatter TeX.
122:
123: Another similar mode is used for editing outlines. It allows you
124: to view the text at various levels of detail. You can view either
125: the outline headings alone or both headings and text; you can also
126: hide some of the headings at lower levels from view to make the high
127: level structure more visible.
128:
129: * Outline Mode::The major mode for editing outlines.
130:
131:
132: File: emacs Node: Nroff Mode, Prev: Text Mode, Up: Text Mode, Next: TeX Mode
133:
134: Nroff Mode
135: ----------
136:
137: Nroff mode is a mode like Text mode but modified to handle nroff commands
138: present in the text. Invoke `M-x nroff-mode' to enter this mode. It
139: differs from Text mode in only a few ways. All nroff command lines are
140: considered paragraph separators, so that filling will never garble the
141: nroff commands. Pages are separated by `.bp' commands. Comments
142: start with backslash-doublequote. Also, three special commands are
143: provided that are not in Text mode:
144:
145: `M-n'
146: Move to the beginning of the next line that isn't an nroff command
147: (`forward-text-line'). An argument is a repeat count.
148: `M-p'
149: Like `M-n' but move up (`backward-text-line').
150: `M-?'
151: Prints in the echo area the number of text lines (lines that are not
152: nroff commands) in the region (`count-text-lines').
153:
154: The other feature of Nroff mode is that you can turn on Electric
155: Nroff newline mode. This is a minor mode that you can turn on or off
156: with `M-x electric-nroff-mode' (*Note Minor Modes::). When the
157: mode is on, each time you use RET to end a line that contains
158: an nroff command that opens a kind of grouping, the matching
159: nroff command to close that grouping is automatically inserted on
160: the following line. For example, if you are at the beginning of
161: a line and type `. ( b RET', the matching command
162: `.)b' will be inserted on a new line following point.
163:
164: Entering Nroff mode calls with no arguments the value of the variable
165: `text-mode-hook', if that value exists and is not `nil'; then it
166: does the same with the variable `nroff-mode-hook'.
167:
168:
169: File: emacs Node: TeX Mode, Prev: Nroff Mode, Up: Text Mode, Next: Outline Mode
170:
171: TeX Mode
172: --------
173:
174: TeX is a powerful text formatter written by Donald Knuth; it is also
175: free, like GNU Emacs. LaTeX is a simplified input format for TeX,
176: implemented by TeX macros. It comes with TeX.
177:
178: Emacs has a special TeX mode for editing TeX input files.
179: It provides facilities for checking the balance of delimiters and for
180: invoking TeX on all or part of the file.
181:
182: TeX mode has two variants, Plain TeX mode and LaTeX mode
183: (actually two distinct major modes which differ only slightly). They are
184: designed for editing the two different input formats. The command `M-x
185: tex-mode' looks at the contents of the buffer to determine whether the
186: contents appear to be LaTeX input or not; it then selects the
187: appropriate mode. If it can't tell which is right (e.g., the buffer is
188: empty), the variable `TeX-default-mode' controls which mode is used.
189:
190: The commands `M-x plain-tex-mode' and `M-x latex-mode' explicitly select
191: the two variants of TeX mode. Use these commands when `M-x tex-mode' does
192: not guess right.
193:
194: * Menu:
195:
196: * Editing: TeX Editing. Special commands for editing in TeX mode.
197: * Printing: TeX Print. Commands for printing part of a file with TeX.
198:
199: TeX for Berkeley Unix can be obtained on a 1600bpi tar tape for a $100
200: distribution fee from
201:
202: Pierre MacKay
203: Department of Computer Science, FR-35
204: University of Washington
205: Seattle, WA 98195
206:
207: It would work on system V as well if that version of Unix had a reasonable
208: Pascal compiler. Outside the U.S., add $10 to cover extra costs.
209:
210:
211: File: emacs Node: TeX Editing, Prev: TeX Mode, Up: TeX Mode, Next: TeX Print
212:
213: TeX Editing Commands
214: ....................
215:
216: Here are the special commands provided in TeX mode for editing the
217: text of the file.
218:
219: `"'
220: Insert, according to context, either ```' or `"' or
221: `''' (`TeX-insert-quote').
222: `LFD'
223: Insert a paragraph break (two newlines) and check the previous
224: paragraph for unbalanced braces or dollar signs
225: (`TeX-terminate-paragraph').
226: `M-x validate-TeX-buffer'
227: Check each paragraph in the buffer for unbalanced braces or dollar signs.
228: `M-{'
229: Insert `{}' and position point between them (`TeX-insert-braces').
230: `M-}'
231: Move forward past the next unmatched close brace (`up-list').
232: `C-c C-f'
233: Close a block for LaTeX (`TeX-close-LaTeX-block').
234:
235: In TeX, the character `"' is not normally used; one uses `"'
236: to start a quotation and `"' to end one. TeX mode defines the key
237: `"' to insert `"' after whitespace or an open brace, `"'
238: after a backslash, or `"' otherwise. This is done by the command
239: `TeX-insert-quote'. If you need the character `"' itself in
240: unusual contexts, use `C-q' to insert it. Also, `"' with a
241: numeric argument always inserts that number of `"' characters.
242:
243: In TeX mode, `$' has a special syntax code which attempts to
244: understand the way TeX math mode delimiters match. When you insert a
245: `$' that is meant to exit math mode, the position of the matching
246: `$' that entered math mode is displayed for a second. This is the
247: same feature that displays the open brace that matches a close brace that
248: is inserted. However, there is no way to tell whether a `$' enters
249: math mode or leaves it; so when you insert a `$' that enters math
250: mode, the previous `$' position is shown as if it were a match, even
251: though they are actually unrelated.
252:
253: If you prefer to keep braces balanced at all times, you can use `M-{'
254: (`TeX-insert-braces') to insert a pair of braces. It leaves point
255: between the two braces so you can insert the text that belongs inside.
256: Afterward, use the command `M-}' (`up-list') to move forward
257: past the close brace.
258:
259: There are two commands for checking the matching of braces. LFD
260: (`TeX-terminate-paragraph') checks the paragraph before point, and
261: inserts two newlines to start a new paragraph. It prints a message in the
262: echo area if any mismatch is found. `M-x validate-TeX-buffer' checks
263: the entire buffer, paragraph by paragraph. When it finds a paragraph that
264: contains a mismatch, it displays point at the beginning of the paragraph
265: for a few seconds and pushes a mark at that spot. Scanning continues
266: until the whole buffer has been checked or until you type another key.
267: The positions of the last several paragraphs with mismatches can be
268: found in the mark ring (*Note Mark Ring::).
269:
270: Note that square brackets and parentheses are matched in TeX mode, not
271: just braces. This is wrong for the purpose of checking TeX syntax.
272: However, parentheses and square brackets are likely to be used in text as
273: matching delimiters and it is useful for the various motion commands and
274: automatic match display to work with them.
275:
276: In LaTeX input, `\begin' and `\end' commands must balance. After you
277: insert a `\begin', use `C-c C-f' (`TeX-close-LaTeX-block') to insert
278: automatically a matching `\end' (on a new line following the `\begin'). A
279: blank line is inserted between the two, and point is left there.
280:
281:
282: File: emacs Node: TeX Print, Prev: TeX Editing, Up: TeX Mode
283:
284: TeX Printing Commands
285: .....................
286:
287: You can invoke TeX as an inferior of Emacs on either the entire
288: contents of the buffer or just a region at a time. Running TeX in
289: this way on just one chapter is a good way to see what your changes
290: look like without taking the time to format the entire file.
291:
292: `C-c C-r'
293: Invoke TeX on the current region, plus the buffer's header
294: (`TeX-region').
295: `C-c C-b'
296: Invoke TeX on the entire current buffer (`TeX-buffer').
297: `C-c C-l'
298: Recenter the window showing output from the inferior TeX so that
299: the last line can be seen (`TeX-recenter-output-buffer').
300: `C-c C-k'
301: Kill the inferior TeX (`TeX-kill-job').
302: `C-c C-p'
303: Print the output from the last `C-c C-r' or `C-c C-b' command
304: (`TeX-print').
305: `C-c C-q'
306: Show the printer queue (`TeX-show-print-queue').
307:
308: You can pass the current buffer through an inferior TeX by means of
309: `C-c C-b' (`TeX-buffer'). The formatted output appears in a file
310: in `/tmp'; to print it, type `C-c C-p' (`TeX-print').
311: Afterward use `C-c C-q' (`TeX-show-print-queue') to view the
312: progress of your output towards being printed.
313:
314: The console output from TeX, including any error messages, appear in a
315: buffer called `*TeX-shell*'. If TeX gets an error, you can switch
316: to this buffer and feed it input (this works as in Shell mode;
317: *Note Interactive Shell::). Without switching to this buffer you can scroll
318: it so that its last line is visible by typing `C-c C-l'.
319:
320: Type `C-c C-k' (`TeX-kill-job') to kill the TeX process if you see that
321: its output is no longer useful. Using `C-c C-b' or `C-c C-r' also kills
322: any TeX process still running.
323:
324: You can also pass an arbitrary region through an inferior TeX by typing
325: `C-c C-r' (`TeX-region'). This is tricky, however, because most files
326: of TeX input contain commands at the beginning to set parameters and
327: define macros, without which no later part of the file will format
328: correctly. To solve this problem, `C-c C-r' allows you to designate a
329: part of the file as containing essential commands; it is included before
330: the specified region as part of the input to TeX. The designated part
331: of the file is called the "header".
332:
333: To indicate the bounds of the header in Plain TeX mode, you insert two
334: special strings in the file. Insert `%**start of header' before the
335: header, and `%**end of header' after it. Each string must appear
336: entirely on one line, but there may be other text on the line before or
337: after. The lines containing the two strings are included in the header.
338: If `%**start of header' does not appear within the first 100 lines of
339: the buffer, `C-c C-r' assumes that there is no header.
340:
341: In LaTeX mode, the header begins with `\documentstyle' and ends
342: with `\begin{document}'. These are commands that LaTeX requires
343: you to use in any case, so nothing special needs to be done to identify the
344: header.
345:
346: Entering either kind of TeX mode calls with no arguments the value of
347: the variable `text-mode-hook', if that value exists and is not
348: `nil'; then it does the same with the variable `TeX-mode-hook'.
349: Finally it does the same with either `plain-TeX-mode-hook' or
350: `LaTeX-mode-hook'.
351:
352:
353: File: emacs Node: Outline Mode, Prev: TeX Mode, Up: Text Mode
354:
355: Outline Mode
356: ------------
357:
358: Outline mode is a major mode much like Text mode but intended for editing
359: outlines. It allows you to make parts of the text temporarily invisible
360: so that you can see just the overall structure of the outline. Type
361: `M-x outline-mode' to turn on Outline mode in the current buffer.
362:
363: Entering Outline mode calls with no arguments the value of the variable
364: `text-mode-hook', if that value exists and is not `nil'; then it
365: does the same with the variable `outline-mode-hook'.
366:
367: When a line is invisible in outline mode, it does not appear on the
368: screen. The screen appears exactly as if the invisible line
369: were deleted, except that an ellipsis (three periods in a row) appears
370: at the end of the previous visible line (only one ellipsis no matter
371: how many invisible lines follow).
372:
373: All editing commands treat the text of the invisible line as part of the
374: previous visible line. For example, `C-n' moves onto the next visible
375: line. Killing an entire visible line, including its terminating newline,
376: really kills all the following invisible lines along with it; yanking it
377: all back yanks the invisible lines and they remain invisible.
378:
379: * Menu:
380:
381: * Format: Outline Format. What the text of an outline looks like.
382: * Motion: Outline Motion. Special commands for moving through outlines.
383: * Visibility: Outline Visibility. Commands to control what is visible.
384:
385:
386: File: emacs Node: Outline Format, Prev: Outline Mode, Up: Outline Mode, Next: Outline Motion
387:
388: Format of Outlines
389: ..................
390:
391: Outline mode assumes that the lines in the buffer are of two types:
392: "heading lines" and "body lines". A heading line represents a topic in the
393: outline. Heading lines start with one or more stars; the number of stars
394: determines the depth of the heading in the outline structure. Thus, a
395: heading line with one star is a major topic; all the heading lines with
396: two stars between it and the next one-star heading are its subtopics; and
397: so on. Any line that is not a heading line is a body line. Body lines
398: belong to the preceding heading line. Here is an example:
399:
400: * Food
401:
402: This is the body,
403: which says something about the topic of food.
404:
405: ** Delicious Food
406:
407: This is the body of the second-level header.
408:
409: ** Distasteful Food
410:
411: This could have
412: a body too, with
413: several lines.
414:
415: *** Dormitory Food
416:
417: * Shelter
418:
419: A second first-level topic with its header line.
420:
421: A heading line together with all following body lines is called
422: collectively an "entry". A heading line together with all following
423: deeper heading lines and their body lines is called a "subtree".
424:
425: You can customize the criterion for distinguishing heading lines
426: by setting the variable `outline-regexp'. Any line whose
427: beginning has a match for this regexp is considered a heading line.
428: Matches that start within a line (not at the beginning) do not count.
429: The length of the matching text determines the level of the heading;
430: longer matches make a more deeply nested level. Thus, for example,
431: if a text formatter has commands `@chapter', `@section'
432: and `@subsection' to divide the document into chapters and
433: sections, you could make those lines count as heading lines by
434: setting `outline-regexp' to `"@chap\\|@\\(sub\\)*section"'.
435: Note the trick: the two words `chapter' and `section' are equally
436: long, but by defining the regexp to match only `chap' we ensure
437: that the length of the text matched on a chapter heading is shorter,
438: so that Outline mode will know that sections are contained in chapters.
439: This works as long as no other command starts with `@chap'.
440:
441: Outline mode makes a line invisible by changing the newline before it
442: into an ASCII Control-M (code 015). Most editing commands that work on
443: lines treat an invisible line as part of the previous line because,
444: strictly speaking, it is part of that line, since there is no longer a
445: newline in between. When you save the file in Outline mode, Control-M
446: characters are saved as newlines, so the invisible lines become ordinary
447: lines in the file. But saving does not change the visibility status of a
448: line inside Emacs.
449:
450:
451: File: emacs Node: Outline Motion, Prev: Outline Format, Up: Outline Mode, Next: Outline Visibility
452:
453: Outline Motion Commands
454: .......................
455:
456: There are some special motion commands in Outline mode that move
457: backward and forward to heading lines.
458:
459: `C-c C-n'
460: Move point to the next visible heading line
461: (`outline-next-visible-heading').
462: `C-c C-p'
463: Move point to the previous visible heading line
464: (`outline-previous-visible-heading').
465: `C-c C-f'
466: Move point to the next visible heading line at the same level
467: as the one point is on (`outline-forward-same-level').
468: `C-c C-b'
469: Move point to the previous visible heading line at the same level
470: (`outline-backward-same-level').
471: `C-c C-u'
472: Move point up to a lower-level (more inclusive) visible heading line
473: (`outline-up-heading').
474:
475: `C-c C-n' (`next-visible-heading') moves down to the next heading line.
476: `C-c C-p' (`previous-visible-heading') moves similarly backward. Both
477: accept numeric arguments as repeat counts. The names emphasize that
478: invisible headings are skipped, but this is not really a special feature.
479: All editing commands that look for lines ignore the invisible lines
480: automatically.
481:
482: More advanced motion commands understand the levels of headings.
483: `C-c C-f' (`outline-forward-same-level') and
484: `C-c C-b' (`outline-backward-same-level') move from one
485: heading line to another visible heading at the same depth in
486: the outline. `C-c C-u' (`outline-up-heading') moves
487: backward to another heading that is less deeply nested.
488:
489:
490: File: emacs Node: Outline Visibility, Prev: Outline Motion, Up: Outline Mode
491:
492: Outline Visibility Commands
493: ...........................
494:
495: The other special commands of outline mode are used to make lines visible
496: or invisible. Their names all start with `hide' or `show'.
497: Most of them fall into pairs of opposites. They are not undoable; instead,
498: you can undo right past them. Making lines visible or invisible is simply
499: not recorded by the undo mechanism.
500:
501: `M-x hide-body'
502: Make all body lines in the buffer invisible.
503: `M-x show-all'
504: Make all lines in the buffer visible.
505: `C-c C-h'
506: Make everything under this heading invisible, not including this
507: heading itself (`hide-subtree').
508: `C-c C-s'
509: Make everything under this heading visible, including body,
510: subheadings, and their bodies (`show-subtree').
511: `M-x hide-leaves'
512: Make the body of this heading line, and of all its subheadings,
513: invisible.
514: `M-x show-branches'
515: Make all subheadings of this heading line, at all levels, visible.
516: `C-c C-i'
517: Make immediate subheadings (one level down) of this heading line
518: visible (`show-children').
519: `M-x hide-entry'
520: Make this heading line's body invisible.
521: `M-x show-entry'
522: Make this heading line's body visible.
523:
524: Two commands that are exact opposites are `M-x hide-entry' and
525: `M-x show-entry'. They are used with point on a heading line, and
526: apply only to the body lines of that heading. The subtopics and their
527: bodies are not affected.
528:
529: Two more powerful opposites are `C-c C-h' (`hide-subtree') and `C-c C-s'
530: (`show-subtree'). Both expect to be used when point is on a heading line,
531: and both apply to all the lines of that heading's "subtree": its body, all
532: its subheadings, both direct and indirect, and all of their bodies. In
533: other words, the subtree contains everything following this heading line,
534: up to and not including the next heading of the same or higher rank.
535:
536: Intermediate between a visible subtree and an invisible one is having
537: all the subheadings visible but none of the body. There are two commands
538: for doing this, depending on whether you want to hide the bodies or
539: make the subheadings visible. They are `M-x hide-leaves' and
540: `M-x show-branches'.
541:
542: A little weaker than `show-branches' is `C-c C-i' (`show-children'). It
543: makes just the direct subheadings visible---those one level down. Deeper
544: subheadings remain invisible, if they were invisible.
545:
546: Two commands have a blanket effect on the whole file. `M-x hide-body'
547: makes all body lines invisible, so that you see just the outline structure.
548: `M-x show-all' makes all lines visible. These commands can be thought
549: of as a pair of opposites even though `M-x show-all' applies to more
550: than just body lines.
551:
552: The use of ellipses at the ends of visible lines can be turned off
553: by setting `selective-display-ellipses' to `nil'. Then there
554: is no visible indication of the presence of invisible lines.
555:
556:
557: File: emacs Node: Words, Prev: Text Mode, Up: Text, Next: Sentences
558:
559: Words
560: =====
561:
562: Emacs has commands for moving over or operating on words. By convention,
563: the keys for them are all `Meta-' characters.
564:
565: `M-f'
566: Move forward over a word (`forward-word').
567: `M-b'
568: Move backward over a word (`backward-word').
569: `M-d'
570: Kill up to the end of a word (`kill-word').
571: `M-DEL'
572: Kill back to the beginning of a word (`backward-kill-word').
573: `M-@'
574: Mark the end of the next word (`mark-word').
575: `M-t'
576: Transpose two words; drag a word forward
577: or backward across other words (`transpose-words').
578:
579: Notice how these keys form a series that parallels the character-based
580: `C-f', `C-b', `C-d', `C-t' and DEL. `M-@' is related to `C-@', which is an
581: alias for `C-SPC'.
582:
583: The commands `Meta-f' (`forward-word') and `Meta-b' (`backward-word')
584: move forward and backward over words. They are thus analogous to
585: `Control-f' and `Control-b', which move over single characters. Like their
586: `Control-' analogues, `Meta-f' and `Meta-b' move several words if given an
587: argument. `Meta-f' with a negative argument moves backward, and `Meta-b'
588: with a negative argument moves forward. Forward motion stops right after
589: the last letter of the word, while backward motion stops right before the
590: first letter.
591:
592: `Meta-d' (`kill-word') kills the word after point. To be
593: precise, it kills everything from point to the place `Meta-f' would
594: move to. Thus, if point is in the middle of a word, `Meta-d' kills
595: just the part after point. If some punctuation comes between point and the
596: next word, it is killed along with the word. (If you wish to kill only the
597: next word but not the punctuation before it, simply do `Meta-f' to get
598: the end, and kill the word backwards with `Meta-DEL'.)
599: `Meta-d' takes arguments just like `Meta-f'.
600:
601: `Meta-DEL' (`backward-kill-word') kills the word before
602: point. It kills everything from point back to where `Meta-b' would
603: move to. If point is after the space in `FOO, BAR', then
604: `FOO, ' is killed. (If you wish to kill just `FOO', do
605: `Meta-b Meta-d' instead of `Meta-DEL'.)
606:
607: `Meta-t' (`transpose-words') exchanges the word before or
608: containing point with the following word. The delimiter characters between
609: the words do not move. For example, `FOO, BAR' transposes into
610: `BAR, FOO' rather than `BAR FOO,'. *Note Transpose::, for
611: more on transposition and on arguments to transposition commands.
612:
613: To operate on the next N words with an operation which applies
614: between point and mark, you can either set the mark at point and then move
615: over the words, or you can use the command `Meta-@' (`mark-word')
616: which does not move point, but sets the mark where `Meta-f' would move
617: to. It can be given arguments just like `Meta-f'.
618:
619: The word commands' understanding of syntax is completely controlled by
620: the syntax table. Any character can, for example, be declared to be a word
621: delimiter. *Note Syntax::.
622:
623:
624: File: emacs Node: Sentences, Prev: Words, Up: Text, Next: Paragraphs
625:
626: Sentences
627: =========
628:
629: The Emacs commands for manipulating sentences and paragraphs are mostly
630: on `Meta-' keys, so as to be like the word-handling commands.
631:
632: `M-a'
633: Move back to the beginning of the sentence (`backward-sentence').
634: `M-e'
635: Move forward to the end of the sentence (`forward-sentence').
636: `M-k'
637: Kill forward to the end of the sentence (`kill-sentence').
638: `C-x DEL'
639: Kill back to the beginning of the sentence (`backward-kill-sentence').
640:
641: The commands `Meta-a' and `Meta-e' (`backward-sentence' and
642: `forward-sentence') move to the beginning and end of the current sentence,
643: respectively. They were chosen to resemble `Control-a' and `Control-e',
644: which move to the beginning and end of a line. Unlike them, `Meta-a' and
645: `Meta-e' if repeated or given numeric arguments move over successive
646: sentences. Emacs assumes that the typist's convention is followed, and
647: thus considers a sentence to end wherever there is a `.', `?' or `!'
648: followed by the end of a line or two spaces, with any number of `)', `]',
649: `'', or `"' characters allowed in between. A sentence also begins or ends
650: wherever a paragraph begins or ends.
651:
652: Neither `M-a' nor `M-e' moves past the newline or spaces beyond
653: the sentence edge at which it is stopping.
654:
655: Just as `C-a' and `C-e' have a kill command, `C-k', to go with them, so
656: `M-a' and `M-e' have a corresponding kill command `M-k' (`kill-sentence')
657: which kills from point to the end of the sentence. With minus one as an
658: argument it kills back to the beginning of the sentence. Larger arguments
659: serve as a repeat count.
660:
661: There is a special command, `C-x DEL' (`backward-kill-sentence') for
662: killing back to the beginning of a sentence, because this is useful when
663: you change your mind in the middle of composing text.
664:
665: The variable `sentence-end' controls recognition of the end of a
666: sentence. It is a regexp that matches the last few characters of a
667: sentence, together with the whitespace following the sentence. Its
668: normal value is
669:
670: "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*"
671:
672: This example is explained in the section on regexps. *Note Regexps::.
673:
674:
675: File: emacs Node: Paragraphs, Prev: Sentences, Up: Text, Next: Pages
676:
677: Paragraphs
678: ==========
679:
680: The Emacs commands for manipulating paragraphs are also `Meta-'
681: keys.
682:
683: `M-['
684: Move back to previous paragraph beginning (`backward-paragraph').
685: `M-]'
686: Move forward to next paragraph end (`forward-paragraph').
687: `M-h'
688: Put point and mark around this or next paragraph (`mark-paragraph').
689:
690: `Meta-[' moves to the beginning of the current or previous paragraph,
691: while `Meta-]' moves to the end of the current or next paragraph.
692: Blank lines and text formatter command lines separate paragraphs and are
693: not part of any paragraph. Also, an indented line starts a new
694: paragraph.
695:
696: In major modes for programs (as opposed to Text mode), paragraphs begin
697: and end only at blank lines. This makes the paragraph commands continue to
698: be useful even though there are no paragraphs per se.
699:
700: When there is a fill prefix, then paragraphs are delimited by all lines
701: which don't start with the fill prefix. *Note Filling::.
702:
703: When you wish to operate on a paragraph, you can use the command
704: `Meta-h' (`mark-paragraph') to set the region around it. This
705: command puts point at the beginning and mark at the end of the paragraph
706: point was in. If point is between paragraphs (in a run of blank lines, or
707: at a boundary), the paragraph following point is surrounded by point and
708: mark. If there are blank lines preceding the first line of the paragraph,
709: one of these blank lines is included in the region. Thus, for example,
710: `M-h C-w' kills the paragraph around or after point.
711:
712: The precise definition of a paragraph boundary is controlled by the
713: variables `paragraph-separate' and `paragraph-start'. The value of
714: `paragraph-start' is a regexp that should match any line that either starts
715: or separates paragraphs. The value of `paragraph-separate' is another
716: regexp that should match only lines that separate paragraphs without being
717: part of any paragraph. Lines that start a new paragraph and are contained
718: in it must match both regexps. For example, normally `paragraph-start' is
719: `"^[ \t\n\f]"' and `paragraph-separate' is `"^[ \t\f]*$"'.
720:
721: Normally it is desirable for page boundaries to separate paragraphs.
722: The default values of these variables recognize the usual separator for
723: pages.
724:
725:
726: File: emacs Node: Pages, Prev: Paragraphs, Up: Text, Next: Filling
727:
728: Pages
729: =====
730:
731: Files are often thought of as divided into "pages" by the
732: "formfeed" character (ASCII Control-L, octal code 014). For example,
733: if a file is printed on a line printer, each page of the file, in this
734: sense, will start on a new page of paper. Emacs treats a page-separator
735: character just like any other character. It can be inserted with `C-q
736: C-l', or deleted with DEL. Thus, you are free to paginate your file
737: or not. However, since pages are often meaningful divisions of the file,
738: commands are provided to move over them and operate on them.
739:
740: `C-x ['
741: Move point to previous page boundary (`backward-page').
742: `C-x ]'
743: Move point to next page boundary (`forward-page').
744: `C-x C-p'
745: Put point and mark around this page (or another page) (`mark-page').
746: `C-x l'
747: Count the lines in this page (`count-lines-page').
748:
749: The `C-x [' (`backward-page') command moves point to immediately
750: after the previous page delimiter. If point is already right after a page
751: delimiter, it skips that one and stops at the previous one. A numeric
752: argument serves as a repeat count. The `C-x ]' (`forward-page')
753: command moves forward past the next page delimiter.
754:
755: The `C-x C-p' command (`mark-page') puts point at the beginning
756: of the current page and the mark at the end. The page delimiter at the end
757: is included (the mark follows it). The page delimiter at the front is
758: excluded (point follows it). This command can be followed by `C-w' to
759: kill a page which is to be moved elsewhere. If it is inserted after a page
760: delimiter, at a place where `C-x ]' or `C-x [' would take you, then
761: the page will be properly delimited before and after once again.
762:
763: A numeric argument to `C-x C-p' is used to specify which page to go
764: to, relative to the current one. Zero means the current page. One means
765: the next page, and -1 means the previous one.
766:
767: The `C-x l' command (`count-lines-page') is good for deciding
768: where to break a page in two. It prints in the echo area the total number
769: of lines in the current page, and then divides it up into those preceding
770: the current line and those following, as in
771:
772: Page has 96 (72+25) lines
773:
774: Notice that the sum is off by one; this is correct if point is not at the
775: beginning of a line.
776:
777: The variable `page-delimiter' should have as its value a regexp that
778: matches the beginning of a line that separates pages. This is what defines
779: where pages begin. The normal value of this variable is `"^\f"',
780: which matches a formfeed character at the beginning of a line.
781:
782:
783: File: emacs Node: Filling, Prev: Pages, Up: Text, Next: Case
784:
785: Filling Text
786: ============
787:
788: With Auto Fill mode, text can be "filled" (broken up into lines that
789: fit in a specified width) as you insert it. If you alter existing text it
790: may no longer be properly filled; then explicit commands for filling can be
791: used.
792:
793: * Menu:
794:
795: * Auto Fill:: Auto Fill mode breaks long lines automatically.
796: * Fill Commands:: Commands to refill paragraphs and center lines.
797: * Fill Prefix:: Filling when every line is indented or in a comment, etc.
798:
799:
800: File: emacs Node: Auto Fill, Prev: Filling, Up: Filling, Next: Fill Commands
801:
802: Auto Fill Mode
803: --------------
804:
805:
806: "Auto Fill" mode is a minor mode in which lines are broken
807: automatically when they become too wide. Breaking happens only when
808: you type a SPC or RET.
809:
810: `M-x auto-fill-mode'
811: Enable or disable Auto Fill mode.
812: `SPC'
813: `RET'
814: In Auto Fill mode, break lines when appropriate.
815:
816: `M-x auto-fill-mode' turns Auto Fill mode on if it was off, or off if
817: it was on. With a positive numeric argument it always turns Auto Fill mode
818: on, and with a negative argument always turns it off. You can see when
819: Auto Fill mode is in effect by the presence of the word `Fill' in the
820: mode line, inside the parentheses. Auto Fill mode is a minor mode, turned
821: on or off for each buffer individually. *Note Minor Modes::.
822:
823: In Auto Fill mode, lines are broken automatically at spaces when they get
824: longer than the desired width. Line breaking and rearrangement takes place
825: only when you type SPC or RET. If you wish to insert a space
826: or newline without permitting line-breaking, type `C-q SPC' or
827: `C-q LFD' (recall that a newline is really a linefeed). Also,
828: `C-o' inserts a newline without line breaking.
829:
830: Auto Fill mode works well with Lisp mode, because when it makes a new
831: line in Lisp mode it indents that line with TAB. If a line ending in
832: a comment gets too long, the text of the comment is split into two
833: comment lines. Optionally new comment delimiters are inserted at the end of
834: the first line and the beginning of the second so that each line is
835: a separate comment; the variable `comment-multi-line' controls the
836: choice (*Note Comments::).
837:
838: Auto Fill mode does not refill entire paragraphs. It can break lines but
839: cannot merge lines. So editing in the middle of a paragraph can result in
840: a paragraph that is not correctly filled. The easiest way to make the
841: paragraph properly filled again is usually with the explicit fill commands.
842:
843: Many users like Auto Fill mode and want to use it in all text files.
844: The section on init files says how to arrange this permanently for yourself.
845: *Note Init File::.
846:
847:
848: File: emacs Node: Fill Commands, Prev: Auto Fill, Up: Filling, Next: Fill Prefix
849:
850: Explicit Fill Commands
851: ----------------------
852:
853: `M-q'
854: Fill current paragraph (`fill-paragraph').
855: `M-g'
856: Fill each paragraph in the region (`fill-region').
857: `C-x f'
858: Set the fill column (`set-fill-column').
859: `M-x fill-region-as-paragraph.'
860: Fill the region, considering it as one paragraph.
861: `M-s'
862: Center a line.
863:
864: To refill a paragraph, use the command `Meta-q' (`fill-paragraph'). It
865: causes the paragraph that point is inside, or the one after point if point
866: is between paragraphs, to be refilled. All the line-breaks are removed,
867: and then new ones are inserted where necessary. `M-q' can be undone with
868: `C-_'. *Note Undo::.
869:
870: To refill many paragraphs, use `M-g' (`fill-region'), which
871: divides the region into paragraphs and fills each of them.
872:
873: `Meta-q' and `Meta-g' use the same criteria as `Meta-h' for finding
874: paragraph boundaries (*Note Paragraphs::). For more control, you can use
875: `M-x fill-region-as-paragraph', which refills everything between point and
876: mark. This command recognizes only blank lines as paragraph separators.
877:
878: A numeric argument to `M-g' or `M-q' causes it to "justify" the text as
879: well as filling it. This means that extra spaces are inserted to make the
880: right margin line up exactly at the fill column. To remove the extra
881: spaces, use `M-q' or `M-g' with no argument.
882:
883: The command `Meta-s' (`center-line') centers the current line
884: within the current fill column. With an argument, it centers several lines
885: individually and moves past them.
886:
887: The maximum line width for filling is in the variable `fill-column'.
888: Altering the value of `fill-column' makes it local to the current
889: buffer; until that time, the default value is in effect. The default is
890: initially 70. *Note Locals::.
891:
892: The easiest way to set `fill-column' is to use the command `C-x
893: f' (`set-fill-column'). With no argument, it sets `fill-column'
894: to the current horizontal position of point. With a numeric argument, it
895: uses that as the new fill column.
896:
897:
898: File: emacs Node: Fill Prefix, Prev: Fill Commands, Up: Filling
899:
900: The Fill Prefix
901: ---------------
902:
903: To fill a paragraph in which each line starts with a special marker
904: (which might be a few spaces, giving an indented paragraph), use the
905: "fill prefix" feature. The fill prefix is a string which Emacs expects
906: every line to start with, and which is not included in filling.
907:
908: `C-x .'
909: Set the fill prefix (`set-fill-prefix').
910: `M-q'
911: Fill a paragraph using current fill prefix (`fill-paragraph').
912: `M-x fill-individual-paragraphs'
913: Fill the region, considering each change of indentation as starting a
914: new paragraph.
915:
916: To specify a fill prefix, move to a line that starts with the desired
917: prefix, put point at the end of the prefix, and give the command `C-x .'
918: (`set-fill-prefix'). That's a period after the `C-x'. To turn off the
919: fill prefix, specify an empty prefix: type `C-x .' with point at the
920: beginning of a line.
921:
922: When a fill prefix is in effect, the fill commands remove the fill prefix
923: from each line before filling and insert it on each line after filling.
924: The fill prefix is also inserted on new lines made automatically by Auto
925: Fill mode. Lines that do not start with the fill prefix are considered to
926: start paragraphs, both in `M-q' and the paragraph commands; this is
927: just right if you are using paragraphs with hanging indentation (every line
928: indented except the first one). Lines which are blank or indented once the
929: prefix is removed also separate or start paragraphs; this is what you want
930: if you are writing multi-paragraph comments with a comment delimiter on
931: each line.
932:
933: The fill prefix is stored in the variable `fill-prefix'. Its value
934: is a string, or `nil' when there is no fill prefix. This is a
935: per-buffer variable; altering the variable affects only the current buffer,
936: but there is a default value which you can change as well. *Note Locals::.
937:
938: Another way to use fill prefixes is through `M-x
939: fill-individual-paragraphs'. This function divides the region into groups
940: of consecutive lines with the same amount and kind of indentation and fills
941: each group as a paragraph using its indentation as a fill prefix.
942:
943:
944: File: emacs Node: Case, Prev: Filling, Up: Text
945:
946: Case Conversion Commands
947: ========================
948:
949: Emacs has commands for converting either a single word or any arbitrary
950: range of text to upper case or to lower case.
951:
952: `M-l'
953: Convert following word to lower case (`downcase-word').
954: `M-u'
955: Convert following word to upper case (`upcase-word').
956: `M-c'
957: Capitalize the following word (`capitalize-word').
958: `C-x C-l'
959: Convert region to lower case (`downcase-region').
960: `C-x C-u'
961: Convert region to upper case (`upcase-region').
962:
963: The word conversion commands are the most useful. `Meta-l'
964: (`downcase-word') converts the word after point to lower case, moving
965: past it. Thus, repeating `Meta-l' converts successive words.
966: `Meta-u' (`upcase-word') converts to all capitals instead, while
967: `Meta-c' (`capitalize-word') puts the first letter of the word
968: into upper case and the rest into lower case. All these commands convert
969: several words at once if given an argument. They are especially convenient
970: for converting a large amount of text from all upper case to mixed case,
971: because you can move through the text using `M-l', `M-u' or
972: `M-c' on each word as appropriate, occasionally using `M-f' instead
973: to skip a word.
974:
975: When given a negative argument, the word case conversion commands apply
976: to the appropriate number of words before point, but do not move point.
977: This is convenient when you have just typed a word in the wrong case: you
978: can give the case conversion command and continue typing.
979:
980: If a word case conversion command is given in the middle of a word, it
981: applies only to the part of the word which follows point. This is just
982: like what `Meta-d' (`kill-word') does. With a negative argument,
983: case conversion applies only to the part of the word before point.
984:
985: The other case conversion commands are `C-x C-u' (`upcase-region') and
986: `C-x C-l' (`downcase-region'), which convert everything between point and
987: mark to the specified case. Point and mark do not move.
988:
989:
990: File: emacs Node: Programs, Prev: Text, Up: Top, Next: Running
991:
992: Editing Programs
993: ****************
994:
995: Emacs has many commands designed to understand the syntax of programming
996: languages such as Lisp and C. These commands can
997:
998: * Move over or kill balanced expressions or "sexps" (*Note Lists::).
999: * Move over or mark top-level balanced expressions ("defuns", in Lisp;
1000: functions, in C).
1001: * Show how parentheses balance (*Note Matching::).
1002: * Insert, kill or align comments (*Note Comments::).
1003: * Follow the usual indentation conventions of the language
1004: (*Note Grinding::).
1005:
1006: The commands for words, sentences and paragraphs are very useful in
1007: editing code even though their canonical application is for editing human
1008: language text. Most symbols contain words (*Note Words::); sentences can
1009: be found in strings and comments (*Note Sentences::). Paragraphs per se
1010: are not present in code, but the paragraph commands are useful anyway,
1011: because Lisp mode and C mode define paragraphs to begin and end at blank
1012: lines (*Note Paragraphs::). Judicious use of blank lines to make the
1013: program clearer will also provide interesting chunks of text for the
1014: paragraph commands to work on.
1015:
1016: The selective display feature is useful for looking at the overall
1017: structure of a function (*Note Selective Display::). This feature causes
1018: only the lines that are indented less than a specified amount to appear
1019: on the screen.
1020:
1021: * Menu:
1022:
1023: * Program Modes:: Major modes for editing programs.
1024: * Lists:: Expressions with balanced parentheses.
1025: There are editing commands to operate on them.
1026: * Defuns:: Each program is made up of separate functions.
1027: There are editing commands to operate on them.
1028: * Grinding:: Adjusting indentation to show the nesting.
1029: * Matching:: Insertion of a close-delimiter flashes matching open.
1030: * Comments:: Inserting, illing and aligning comments.
1031: * Balanced Editing:: Inserting two matching parentheses at once, etc.
1032: * Lisp Completion:: Completion on symbol names in Lisp code.
1033: * Documentation:: Getting documentation of functions you plan to call.
1034: * Change Log:: Maintaining a change history for your program.
1035: * Tags:: Go direct to any function in your program in one
1036: command. Tags remembers which file it is in.
1037: * Fortran:: Fortran mode and its special features.
1038:
1039:
1040: File: emacs Node: Program Modes, Prev: Programs, Up: Programs, Next: Lists
1041:
1042: Major Modes for Programming Languages
1043: =====================================
1044:
1045: Emacs also has major modes for the programming languages Lisp, Scheme (a
1046: variant of Lisp), C, Fortran and Muddle. Ideally, a major mode should be
1047: implemented for each programming language that you might want to edit with
1048: Emacs; but often the mode for one language can serve for other
1049: syntactically similar languages. The language modes that exist are those
1050: that someone decided to take the trouble to write.
1051:
1052: There are several forms of Lisp mode, which differ in the way they
1053: interface to Lisp execution. *Note Lisp Modes::.
1054:
1055: Each of the programming language modes defines the TAB key to run
1056: an indentation function that knows the indentation conventions of that
1057: language and updates the current line's indentation accordingly. For
1058: example, in C mode TAB is bound to `c-indent-line'. LFD
1059: is normally defined to do RET followed by TAB; thus, it too
1060: indents in a mode-specific fashion.
1061:
1062: In most programming languages, indentation is likely to vary from line to
1063: line. So the major modes for those languages rebind DEL to treat a
1064: tab as if it were the equivalent number of spaces (using the command
1065: `backward-delete-char-untabify'). This makes it possible to rub out
1066: indentation one column at a time without worrying whether it is made up of
1067: spaces or tabs. Use `C-b C-d' to delete a tab character before point,
1068: in these modes.
1069:
1070: Programming language modes define paragraphs to be separated only by
1071: blank lines, so that the paragraph commands remain useful. Auto Fill mode,
1072: if enabled in a programming language major mode, indents the new lines
1073: which it creates.
1074:
1075: Turning on a major mode calls a user-supplied function called the "mode
1076: hook", which is the value of a Lisp variable. For example, turning on C
1077: mode calls the value of the variable `c-mode-hook' if that value exists and
1078: is non-`nil'. Mode hook variables for other programming language modes
1079: include `lisp-mode-hook', `emacs-lisp-mode-hook',
1080: `lisp-interaction-mode-hook', `scheme-mode-hook' and `muddle-mode-hook'.
1081: The mode hook function receives no arguments.
1082:
1083:
1084: File: emacs Node: Lists, Prev: Program Modes, Up: Programs, Next: Defuns
1085:
1086: Lists and Sexps
1087: ===============
1088:
1089: By convention, Emacs keys for dealing with balanced expressions are
1090: usually `Control-Meta-' characters. They tend to be analogous in
1091: function to their `Control-' and `Meta-' equivalents. These commands
1092: are usually thought of as pertaining to expressions in programming
1093: languages, but can be useful with any language in which some sort of
1094: parentheses exist (including English).
1095:
1096: These commands fall into two classes. Some deal only with "lists"
1097: (parenthetical groupings). They see nothing except parentheses, brackets,
1098: braces (whichever ones must balance in the language you are working with),
1099: and escape characters that might be used to quote those.
1100:
1101: The other commands deal with expressions or "sexps". The word `sexp'
1102: is derived from "s-expression", the ancient term for an expression in
1103: Lisp. But in Emacs, the notion of `sexp' is not limited to Lisp. It
1104: refers to an expression in whatever language your program is written in.
1105: Each programming language has its own major mode, which customizes the
1106: syntax tables so that expressions in that language count as sexps.
1107:
1108: Sexps typically include symbols, numbers, and string constants, as well
1109: as anything contained in parentheses, brackets or braces.
1110:
1111: In languages that use prefix and infix operators, such as C, it is not
1112: possible for all expressions to be sexps. For example, C mode does not
1113: recognize `foo + bar' as a sexp, even though it is a C expression;
1114: it recognizes `foo' as one sexp and `bar' as another, with the
1115: `+' as punctuation between them. This is a fundamental ambiguity:
1116: both `foo + bar' and `foo' are legitimate choices for the sexp to
1117: move over if point is at the `f'. Note that `(foo + bar)' is a
1118: sexp in C mode.
1119:
1120: Some languages have obscure forms of syntax for expressions that nobody
1121: has bothered to make Emacs understand properly.
1122:
1123: `C-M-f'
1124: Move forward over a sexp (`forward-sexp').
1125: `C-M-b'
1126: Move backward over a sexp (`backward-sexp').
1127: `C-M-k'
1128: Kill sexp forward (`kill-sexp').
1129: `C-M-u'
1130: Move up and backward in list structure (`backward-up-list').
1131: `C-M-d'
1132: Move down and forward in list structure (`down-list').
1133: `C-M-n'
1134: Move forward over a list (`forward-list').
1135: `C-M-p'
1136: Move backward over a list (`backward-list').
1137: `C-M-t'
1138: Transpose expressions (`transpose-sexps').
1139: `C-M-@'
1140: Put mark after following expression (`mark-sexp').
1141:
1142: To move forward over a sexp, use `C-M-f' (`forward-sexp'). If the first
1143: significant character after point is an opening delimiter (`(' in Lisp;
1144: `(', `[' or `{' in C), `C-M-f' moves past the matching closing delimiter.
1145: If the character begins a symbol, string, or number, `C-M-f' moves over
1146: that. If the character after point is a closing delimiter, `C-M-f' just
1147: moves past it. (This last is not really moving across a sexp; it is an
1148: exception which is included in the definition of `C-M-f' because it is as
1149: useful a behavior as anyone can think of for that situation.)
1150:
1151: The command `C-M-b' (`backward-sexp') moves backward over a
1152: sexp. The detailed rules are like those above for `C-M-f', but with
1153: directions reversed. If there are any prefix characters (singlequote,
1154: backquote and comma, in Lisp) preceding the sexp, `C-M-b' moves back
1155: over them as well.
1156:
1157: `C-M-f' or `C-M-b' with an argument repeats that operation the
1158: specified number of times; with a negative argument, it moves in the
1159: opposite direction.
1160:
1161: The sexp commands move across comments as if they were whitespace, in
1162: languages such as C where the comment-terminator can be recognized. In
1163: Lisp, and other languages where comments run until the end of a line, it is
1164: very difficult to ignore comments when parsing backwards; therefore, in
1165: such languages the sexp commands treat the text of comments as if it were
1166: code.
1167:
1168: Killing a sexp at a time can be done with `C-M-k' (`kill-sexp').
1169: `C-M-k' kills the characters that `C-M-f' would move over.
1170:
1171: The "list commands" move over lists like the sexp commands but skip
1172: blithely over any number of other kinds of sexps (symbols, strings, etc).
1173: They are `C-M-n' (`forward-list') and `C-M-p' (`backward-list'). The main
1174: reason they are useful is that they usually ignore comments (since the
1175: comments usually do not contain any lists).
1176:
1177: `C-M-n' and `C-M-p' stay at the same level in parentheses, when that's
1178: possible. To move up one (or N) levels, use `C-M-u' (`backward-up-list').
1179: `C-M-u' moves backward up past one unmatched opening delimiter. A positive
1180: argument serves as a repeat count; a negative argument reverses direction
1181: of motion and also requests repetition, so it moves forward and up one or
1182: more levels.
1183:
1184: To move down in list structure, use `C-M-d' (`down-list'). In Lisp mode,
1185: where `(' is the only opening delimiter, this is nearly the same as
1186: searching for a `('. An argument specifies the number of levels
1187: of parentheses to go down.
1188:
1189: A somewhat random-sounding command which is nevertheless easy to use is
1190: `C-M-t' (`transpose-sexps'), which drags the previous sexp across
1191: the next one. An argument serves as a repeat count, and a negative
1192: argument drags backwards (thus canceling out the effect of `C-M-t' with
1193: a positive argument). An argument of zero, rather than doing nothing,
1194: transposes the sexps ending after point and the mark.
1195:
1196: To make the region be the next sexp in the buffer, use `C-M-@'
1197: (`mark-sexp') which sets mark at the same place that `C-M-f' would
1198: move to. `C-M-@' takes arguments like `C-M-f'. In particular, a
1199: negative argument is useful for putting the mark at the beginning of the
1200: previous sexp.
1201:
1202: The list and sexp commands' understanding of syntax is completely
1203: controlled by the syntax table. Any character can, for example, be
1204: declared to be an opening delimiter and act like an open parenthesis.
1205: *Note Syntax::.
1206:
1207:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.