root/branches/2.1/info/emacs-5

Revision 3212, 48.9 kB (checked in by miyoshi, 5 years ago)

Sync up with Emacs-21.3.

Line 
1 This is ../info/emacs, produced by makeinfo version 4.3 from emacs.texi.
2
3    This is the Fourteenth edition of the `GNU Emacs Manual', updated
4 for Emacs version 21.3.
5
6 INFO-DIR-SECTION Emacs
7 START-INFO-DIR-ENTRY
8 * Emacs: (emacs).       The extensible self-documenting text editor.
9 END-INFO-DIR-ENTRY
10
11    Published by the Free Software Foundation 59 Temple Place, Suite 330
12 Boston, MA  02111-1307 USA
13
14    Copyright (C)
15 1985,1986,1987,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002
16 Free Software Foundation, Inc.
17
18    Permission is granted to copy, distribute and/or modify this document
19 under the terms of the GNU Free Documentation License, Version 1.1 or
20 any later version published by the Free Software Foundation; with the
21 Invariant Sections being "The GNU Manifesto", "Distribution" and "GNU
22 GENERAL PUBLIC LICENSE", with the Front-Cover texts being "A GNU
23 Manual," and with the Back-Cover Texts as in (a) below.  A copy of the
24 license is included in the section entitled "GNU Free Documentation
25 License."
26
27    (a) The FSF's Back-Cover Text is: "You have freedom to copy and
28 modify this GNU Manual, like GNU software.  Copies published by the Free
29 Software Foundation raise funds for GNU development."
30
31 
32 File: emacs,  Node: Library Keywords,  Next: Language Help,  Prev: Apropos,  Up: Help
33
34 Keyword Search for Lisp Libraries
35 =================================
36
37    The `C-h p' command lets you search the standard Emacs Lisp
38 libraries by topic keywords.  Here is a partial list of keywords you can
39 use:
40
41      abbrev --- abbreviation handling, typing shortcuts, macros.
42      bib --- support for the bibliography processor `bib'.
43      c --- C and C++ language support.
44      calendar --- calendar and time management support.
45      comm --- communications, networking, remote access to files.
46      data --- support for editing files of data.
47      docs --- support for Emacs documentation.
48      emulations --- emulations of other editors.
49      extensions --- Emacs Lisp language extensions.
50      faces --- support for using faces (fonts and colors; *note Faces::).
51      frames --- support for Emacs frames and window systems.
52      games --- games, jokes and amusements.
53      hardware --- support for interfacing with exotic hardware.
54      help --- support for on-line help systems.
55      hypermedia --- support for links within text, or other media types.
56      i18n --- internationalization and alternate character-set support.
57      internal --- code for Emacs internals, build process, defaults.
58      languages --- specialized modes for editing programming languages.
59      lisp --- support for using Lisp (including Emacs Lisp).
60      local --- libraries local to your site.
61      maint --- maintenance aids for the Emacs development group.
62      mail --- modes for electronic-mail handling.
63      matching --- searching and matching.
64      news --- support for netnews reading and posting.
65      non-text --- support for editing files that are not ordinary text.
66      oop --- support for object-oriented programming.
67      outlines --- hierarchical outlining.
68      processes --- process, subshell, compilation, and job control support.
69      terminals --- support for terminal types.
70      tex --- support for the TeX formatter.
71      tools --- programming tools.
72      unix --- front-ends/assistants for, or emulators of, system features.
73      vms --- support code for VMS.
74      wp --- word processing.
75
76 
77 File: emacs,  Node: Language Help,  Next: Help Mode,  Prev: Library Keywords,  Up: Help
78
79 Help for International Language Support
80 =======================================
81
82    You can use the command `C-h L' (`describe-language-environment') to
83 find out information about the support for a specific language
84 environment.  *Note Language Environments::.  This tells you which
85 languages this language environment is useful for, and lists the
86 character sets, coding systems, and input methods that go with it.  It
87 also shows some sample text to illustrate scripts.
88
89    The command `C-h h' (`view-hello-file') displays the file
90 `etc/HELLO', which shows how to say "hello" in many languages.
91
92    The command `C-h I' (`describe-input-method') describes information
93 about input methods--either a specified input method, or by default the
94 input method in use.  *Note Input Methods::.
95
96    The command `C-h C' (`describe-coding-system') describes information
97 about coding systems--either a specified coding system, or the ones
98 currently in use.  *Note Coding Systems::.
99
100 
101 File: emacs,  Node: Help Mode,  Next: Misc Help,  Prev: Language Help,  Up: Help
102
103 Help Mode Commands
104 ==================
105
106    Help buffers provide the same commands as View mode (*note Misc File
107 Ops::), plus a few special commands of their own.
108
109 `<SPC>'
110      Scroll forward.
111
112 `<DEL>'
113 `<BS>'
114      Scroll backward.  On some keyboards, this key is known as <BS> or
115      <backspace>.
116
117 `<RET>'
118      Follow a cross reference at point.
119
120 `<TAB>'
121      Move point forward to the next cross reference.
122
123 `S-<TAB>'
124      Move point back to the previous cross reference.
125
126 `Mouse-2'
127      Follow a cross reference that you click on.
128
129    When a command name (*note Running Commands by Name: M-x.) or
130 variable name (*note Variables::) appears in the documentation, it
131 normally appears inside paired single-quotes.  You can click on the name
132 with `Mouse-2', or move point there and type <RET>, to view the
133 documentation of that command or variable.  Use `C-c C-b' to retrace
134 your steps.
135
136    There are convenient commands for moving point to cross references in
137 the help text.  <TAB> (`help-next-ref') moves point down to the next
138 cross reference.  Use `S-<TAB>' to move point up to the previous cross
139 reference (`help-previous-ref').
140
141 
142 File: emacs,  Node: Misc Help,  Next: Help Echo,  Prev: Help Mode,  Up: Help
143
144 Other Help Commands
145 ===================
146
147    `C-h i' (`info') runs the Info program, which is used for browsing
148 through structured documentation files.  The entire Emacs manual is
149 available within Info.  Eventually all the documentation of the GNU
150 system will be available.  Type `h' after entering Info to run a
151 tutorial on using Info.
152
153    If you specify a numeric argument, `C-h i' prompts for the name of a
154 documentation file.  This way, you can browse a file which doesn't have
155 an entry in the top-level Info menu.  It is also handy when you need to
156 get to the documentation quickly, and you know the exact name of the
157 file.
158
159    There are two special help commands for accessing Emacs documentation
160 through Info.  `C-h C-f FUNCTION <RET>' enters Info and goes straight
161 to the documentation of the Emacs function FUNCTION.  `C-h C-k KEY'
162 enters Info and goes straight to the documentation of the key KEY.
163 These two keys run the commands `Info-goto-emacs-command-node' and
164 `Info-goto-emacs-key-command-node'.  You can use `C-h C-k' to find the
165 documentation of a menu item: just select that menu item when `C-h C-k'
166 prompts for a key.
167
168    `C-h C-f' and `C-h C-k' know about commands and keys described in
169 manuals other than the Emacs manual.  Thus, they make it easier to find
170 the documentation of commands and keys when you are not sure which
171 manual describes them, like when using some specialized mode.
172
173    When editing a program, if you have an Info version of the manual for
174 the programming language, you can use the command `C-h C-i' to refer to
175 the manual documentation for a symbol (keyword, function or variable).
176 The details of how this command works depend on the major mode.
177
178    If something surprising happens, and you are not sure what commands
179 you typed, use `C-h l' (`view-lossage').  `C-h l' displays the last 100
180 command characters you typed in.  If you see commands that you don't
181 know, you can use `C-h c' to find out what they do.
182
183    Emacs has numerous major modes, each of which redefines a few keys
184 and makes a few other changes in how editing works.  `C-h m'
185 (`describe-mode') displays documentation on the current major mode,
186 which normally describes all the commands that are changed in this mode.
187
188    `C-h b' (`describe-bindings') and `C-h s' (`describe-syntax')
189 present other information about the current Emacs mode.  `C-h b'
190 displays a list of all the key bindings now in effect, showing the
191 local bindings defined by the current minor modes first, then the local
192 bindings defined by the current major mode, and finally the global
193 bindings (*note Key Bindings::).  `C-h s' displays the contents of the
194 syntax table, with explanations of each character's syntax (*note
195 Syntax::).
196
197    You can get a similar list for a particular prefix key by typing
198 `C-h' after the prefix key.  (There are a few prefix keys for which
199 this does not work--those that provide their own bindings for `C-h'.
200 One of these is <ESC>, because `<ESC> C-h' is actually `C-M-h', which
201 marks a defun.)
202
203    The other `C-h' options display various files containing useful
204 information.  `C-h C-w' displays the full details on the complete
205 absence of warranty for GNU Emacs.  `C-h n' (`view-emacs-news')
206 displays the file `emacs/etc/NEWS', which contains documentation on
207 Emacs changes arranged chronologically.  `C-h F' (`view-emacs-FAQ')
208 displays the Emacs frequently-answered-questions list.  `C-h t'
209 (`help-with-tutorial') displays the learn-by-doing Emacs tutorial.
210 `C-h C-c' (`describe-copying') displays the file `emacs/etc/COPYING',
211 which tells you the conditions you must obey in distributing copies of
212 Emacs.  `C-h C-d' (`describe-distribution') displays the file
213 `emacs/etc/DISTRIB', which tells you how you can order a copy of the
214 latest version of Emacs.  `C-h C-p' (`describe-project') displays
215 general information about the GNU Project.  `C-h P'
216 (`view-emacs-problems') displays the file `emacs/etc/PROBLEMS', which
217 lists known problems with Emacs in various situations with solutions or
218 workarounds in many cases.
219
220 
221 File: emacs,  Node: Help Echo,  Prev: Misc Help,  Up: Help
222
223 Help on Active Text and Tooltips
224 ================================
225
226    When a region of text is "active," so that you can select it with
227 the mouse or a key like `RET', it often has associated help text.
228 Areas of the mode line are examples.  This help will normally be shown
229 in the echo area when you move point into the active text.  In a window
230 system you can display the help text as a "tooltip" (sometimes known as
231 "balloon help").  *Note Tooltips::.
232
233 
234 File: emacs,  Node: Mark,  Next: Killing,  Prev: Help,  Up: Top
235
236 The Mark and the Region
237 ***********************
238
239    Many Emacs commands operate on an arbitrary contiguous part of the
240 current buffer.  To specify the text for such a command to operate on,
241 you set "the mark" at one end of it, and move point to the other end.
242 The text between point and the mark is called "the region".  Emacs
243 highlights the region whenever there is one, if you enable Transient
244 Mark mode (*note Transient Mark::).
245
246    Certain Emacs commands set the mark; other editing commands do not
247 affect it, so the mark remains where you set it last.  Each Emacs
248 buffer has its own mark, and setting the mark in one buffer has no
249 effect on other buffers' marks.  When you return to a buffer that was
250 current earlier, its mark is at the same place as before.
251
252    The ends of the region are always point and the mark.  It doesn't
253 matter which of them was put in its current place first, or which one
254 comes earlier in the text--the region starts from point or the mark
255 (whichever comes first), and ends at point or the mark (whichever comes
256 last).  Every time you move point, or set the mark in a new place, the
257 region changes.
258
259    Many commands that insert text, such as `C-y' (`yank') and `M-x
260 insert-buffer', position point and the mark at opposite ends of the
261 inserted text, so that the region consists of the text just inserted.
262
263    Aside from delimiting the region, the mark is also useful for
264 remembering a spot that you may want to go back to.  To make this
265 feature more useful, each buffer remembers 16 previous locations of the
266 mark in the "mark ring".
267
268 * Menu:
269
270 * Setting Mark::        Commands to set the mark.
271 * Transient Mark::      How to make Emacs highlight the region--
272                           when there is one.
273 * Using Region::        Summary of ways to operate on contents of the region.
274 * Marking Objects::     Commands to put region around textual units.
275 * Mark Ring::           Previous mark positions saved so you can go back there.
276 * Global Mark Ring::    Previous mark positions in various buffers.
277
278 
279 File: emacs,  Node: Setting Mark,  Next: Transient Mark,  Up: Mark
280
281 Setting the Mark
282 ================
283
284    Here are some commands for setting the mark:
285
286 `C-<SPC>'
287      Set the mark where point is (`set-mark-command').
288
289 `C-@'
290      The same.
291
292 `C-x C-x'
293      Interchange mark and point (`exchange-point-and-mark').
294
295 `Drag-Mouse-1'
296      Set point and the mark around the text you drag across.
297
298 `Mouse-3'
299      Set the mark where point is, then move point to where you click
300      (`mouse-save-then-kill').
301
302    For example, suppose you wish to convert part of the buffer to upper
303 case, using the `C-x C-u' (`upcase-region') command, which operates on
304 the text in the region.  You can first go to the beginning of the text
305 to be capitalized, type `C-<SPC>' to put the mark there, move to the
306 end, and then type `C-x C-u'.  Or, you can set the mark at the end of
307 the text, move to the beginning, and then type `C-x C-u'.
308
309    The most common way to set the mark is with the `C-<SPC>' command
310 (`set-mark-command').  This sets the mark where point is.  Then you can
311 move point away, leaving the mark behind.
312
313    There are two ways to set the mark with the mouse.  You can drag
314 mouse button one across a range of text; that puts point where you
315 release the mouse button, and sets the mark at the other end of that
316 range.  Or you can click mouse button three, which sets the mark at
317 point (like `C-<SPC>') and then moves point (like `Mouse-1').  Both of
318 these methods copy the region into the kill ring in addition to setting
319 the mark; that gives behavior consistent with other window-driven
320 applications, but if you don't want to modify the kill ring, you must
321 use keyboard commands to set the mark.  *Note Mouse Commands::.
322
323    Ordinary terminals have only one cursor, so there is no way for Emacs
324 to show you where the mark is located.  You have to remember.  The usual
325 solution to this problem is to set the mark and then use it soon, before
326 you forget where it is.  Alternatively, you can see where the mark is
327 with the command `C-x C-x' (`exchange-point-and-mark') which puts the
328 mark where point was and point where the mark was.  The extent of the
329 region is unchanged, but the cursor and point are now at the previous
330 position of the mark.  In Transient Mark mode, this command reactivates
331 the mark.
332
333    `C-x C-x' is also useful when you are satisfied with the position of
334 point but want to move the other end of the region (where the mark is);
335 do `C-x C-x' to put point at that end of the region, and then move it.
336 Using `C-x C-x' a second time, if necessary, puts the mark at the new
337 position with point back at its original position.
338
339    For more facilities that allow you to go to previously set marks, see
340 *Note Mark Ring::.
341
342    There is no such character as `C-<SPC>' in ASCII; when you type
343 <SPC> while holding down <CTRL>, what you get on most ordinary
344 terminals is the character `C-@'.  This key is actually bound to
345 `set-mark-command'.  But unless you are unlucky enough to have a
346 terminal where typing `C-<SPC>' does not produce `C-@', you might as
347 well think of this character as `C-<SPC>'.  Under X, `C-<SPC>' is
348 actually a distinct character, but its binding is still
349 `set-mark-command'.
350
351 
352 File: emacs,  Node: Transient Mark,  Next: Using Region,  Prev: Setting Mark,  Up: Mark
353
354 Transient Mark Mode
355 ===================
356
357    On a terminal that supports colors, Emacs can highlight the current
358 region.  But normally it does not.  Why not?
359
360    Highlighting the region whenever it exists would not be desirable in
361 Emacs, because once you have set a mark, there is _always_ a region (in
362 that buffer).  And highlighting the region all the time would be a
363 nuisance.  So normally Emacs highlights the region only immediately
364 after you have selected one with the mouse.
365
366    You can turn on region highlighting by enabling Transient Mark mode.
367 This is a more rigid mode of operation in which the region "lasts" only
368 temporarily, so you must set up a region for each command that uses
369 one.  In Transient Mark mode, most of the time there is no region;
370 therefore, highlighting the region when it exists is useful and not
371 annoying.
372
373    To enable Transient Mark mode, type `M-x transient-mark-mode'.  This
374 command toggles the mode, so you can repeat the command to turn off the
375 mode.
376
377    Here are the details of Transient Mark mode:
378
379    * To set the mark, type `C-<SPC>' (`set-mark-command').  This makes
380      the mark active and thus begins highlighting of the region.  As
381      you move point, you will see the highlighted region grow and
382      shrink.
383
384    * The mouse commands for specifying the mark also make it active.
385      So do keyboard commands whose purpose is to specify a region,
386      including `M-@', `C-M-@', `M-h', `C-M-h', `C-x C-p', and `C-x h'.
387
388    * When the mark is active, you can execute commands that operate on
389      the region, such as killing, indenting, or writing to a file.
390
391    * Any change to the buffer, such as inserting or deleting a
392      character, deactivates the mark.  This means any subsequent
393      command that operates on a region will get an error and refuse to
394      operate.  You can make the region active again by typing `C-x C-x'.
395
396    * Commands like `M->' and `C-s', that "leave the mark behind" in
397      addition to some other primary purpose, do not activate the new
398      mark.  You can activate the new region by executing `C-x C-x'
399      (`exchange-point-and-mark').
400
401    * `C-s' when the mark is active does not alter the mark.
402
403    * Quitting with `C-g' deactivates the mark.
404
405    * Some commands operate on the region whenever it is active.  For
406      instance, `C-x u' in Transient Mark mode operates on the region
407      when there is a region.  Outside Transient Mark mode, you must type
408      `C-u C-x u' if you want it to operate on the region.  *Note
409      Undo::.   Other commands that act this way are identified in their
410      own documentation.
411
412    The highlighting of the region uses the `region' face; you can
413 customize the appearance of the highlighted region by changing this
414 face.  *Note Face Customization::.
415
416    When multiple windows show the same buffer, they can have different
417 regions, because they can have different values of point (though they
418 all share one common mark position).  Ordinarily, only the selected
419 window highlights its region (*note Windows::).  However, if the
420 variable `highlight-nonselected-windows' is non-`nil', then each window
421 highlights its own region (provided that Transient Mark mode is enabled
422 and the mark in the window's buffer is active).
423
424    When Transient Mark mode is not enabled, every command that sets the
425 mark also activates it, and nothing ever deactivates it.
426
427    If the variable `mark-even-if-inactive' is non-`nil' in Transient
428 Mark mode, then commands can use the mark and the region even when it
429 is inactive.  Region highlighting appears and disappears just as it
430 normally does in Transient Mark mode, but the mark doesn't really go
431 away when the highlighting disappears.
432
433    Transient Mark mode is also sometimes known as "Zmacs mode" because
434 the Zmacs editor on the MIT Lisp Machine handled the mark in a similar
435 way.
436
437 
438 File: emacs,  Node: Using Region,  Next: Marking Objects,  Prev: Transient Mark,  Up: Mark
439
440 Operating on the Region
441 =======================
442
443    Once you have a region and the mark is active, here are some of the
444 ways you can operate on the region:
445
446    * Kill it with `C-w' (*note Killing::).
447
448    * Save it in a register with `C-x r s' (*note Registers::).
449
450    * Save it in a buffer or a file (*note Accumulating Text::).
451
452    * Convert case with `C-x C-l' or `C-x C-u' (*note Case::).
453
454    * Indent it with `C-x <TAB>' or `C-M-\' (*note Indentation::).
455
456    * Fill it as text with `M-x fill-region' (*note Filling::).
457
458    * Print hardcopy with `M-x print-region' (*note Hardcopy::).
459
460    * Evaluate it as Lisp code with `M-x eval-region' (*note Lisp
461      Eval::).
462
463    Most commands that operate on the text in the region have the word
464 `region' in their names.
465
466 
467 File: emacs,  Node: Marking Objects,  Next: Mark Ring,  Prev: Using Region,  Up: Mark
468
469 Commands to Mark Textual Objects
470 ================================
471
472    Here are the commands for placing point and the mark around a textual
473 object such as a word, list, paragraph or page.
474
475 `M-@'
476      Set mark after end of next word (`mark-word').  This command and
477      the following one do not move point.
478
479 `C-M-@'
480      Set mark after end of following balanced expression (`mark-sexp').
481
482 `M-h'
483      Put region around current paragraph (`mark-paragraph').
484
485 `C-M-h'
486      Put region around current defun (`mark-defun').
487
488 `C-x h'
489      Put region around the entire buffer (`mark-whole-buffer').
490
491 `C-x C-p'
492      Put region around current page (`mark-page').
493
494    `M-@' (`mark-word') puts the mark at the end of the next word, while
495 `C-M-@' (`mark-sexp') puts it at the end of the next balanced
496 expression (*note Expressions::).  These commands handle arguments just
497 like `M-f' and `C-M-f'.
498
499    Other commands set both point and mark, to delimit an object in the
500 buffer.  For example, `M-h' (`mark-paragraph') moves point to the
501 beginning of the paragraph that surrounds or follows point, and puts
502 the mark at the end of that paragraph (*note Paragraphs::).  It prepares
503 the region so you can indent, case-convert, or kill a whole paragraph.
504
505    `C-M-h' (`mark-defun') similarly puts point before, and the mark
506 after, the current (or following) major top-level definition, or defun
507 (*note Moving by Defuns::).  `C-x C-p' (`mark-page') puts point before
508 the current page, and mark at the end (*note Pages::).  The mark goes
509 after the terminating page delimiter (to include it in the region),
510 while point goes after the preceding page delimiter (to exclude it).  A
511 numeric argument specifies a later page (if positive) or an earlier
512 page (if negative) instead of the current page.
513
514    Finally, `C-x h' (`mark-whole-buffer') sets up the entire buffer as
515 the region, by putting point at the beginning and the mark at the end.
516
517    In Transient Mark mode, all of these commands activate the mark.
518
519 
520 File: emacs,  Node: Mark Ring,  Next: Global Mark Ring,  Prev: Marking Objects,  Up: Mark
521
522 The Mark Ring
523 =============
524
525    Aside from delimiting the region, the mark is also useful for
526 remembering a spot that you may want to go back to.  To make this
527 feature more useful, each buffer remembers 16 previous locations of the
528 mark, in the "mark ring".  Commands that set the mark also push the old
529 mark onto this ring.  To return to a marked location, use `C-u C-<SPC>'
530 (or `C-u C-@'); this is the command `set-mark-command' given a numeric
531 argument.  It moves point to where the mark was, and restores the mark
532 from the ring of former marks.  Thus, repeated use of this command
533 moves point to all of the old marks on the ring, one by one.  The mark
534 positions you move through in this way are not lost; they go to the end
535 of the ring.
536
537    Each buffer has its own mark ring.  All editing commands use the
538 current buffer's mark ring.  In particular, `C-u C-<SPC>' always stays
539 in the same buffer.
540
541    Many commands that can move long distances, such as `M-<'
542 (`beginning-of-buffer'), start by setting the mark and saving the old
543 mark on the mark ring.  This is to make it easier for you to move back
544 later.  Searches set the mark if they move point.  You can tell when a
545 command sets the mark because it displays `Mark set' in the echo area.
546
547    If you want to move back to the same place over and over, the mark
548 ring may not be convenient enough.  If so, you can record the position
549 in a register for later retrieval (*note Saving Positions in Registers:
550 RegPos.).
551
552    The variable `mark-ring-max' specifies the maximum number of entries
553 to keep in the mark ring.  If that many entries exist and another one
554 is pushed, the earliest one in the list is discarded.  Repeating `C-u
555 C-<SPC>' cycles through the positions currently in the ring.
556
557    The variable `mark-ring' holds the mark ring itself, as a list of
558 marker objects, with the most recent first.  This variable is local in
559 every buffer.
560
561 
562 File: emacs,  Node: Global Mark Ring,  Prev: Mark Ring,  Up: Mark
563
564 The Global Mark Ring
565 ====================
566
567    In addition to the ordinary mark ring that belongs to each buffer,
568 Emacs has a single "global mark ring".  It records a sequence of
569 buffers in which you have recently set the mark, so you can go back to
570 those buffers.
571
572    Setting the mark always makes an entry on the current buffer's mark
573 ring.  If you have switched buffers since the previous mark setting, the
574 new mark position makes an entry on the global mark ring also.  The
575 result is that the global mark ring records a sequence of buffers that
576 you have been in, and, for each buffer, a place where you set the mark.
577
578    The command `C-x C-<SPC>' (`pop-global-mark') jumps to the buffer
579 and position of the latest entry in the global ring.  It also rotates
580 the ring, so that successive uses of `C-x C-<SPC>' take you to earlier
581 and earlier buffers.
582
583 
584 File: emacs,  Node: Killing,  Next: Yanking,  Prev: Mark,  Up: Top
585
586 Deletion and Killing
587 ====================
588
589    Most commands which erase text from the buffer save it in the kill
590 ring so that you can move or copy it to other parts of the buffer.
591 These commands are known as "kill" commands.  The rest of the commands
592 that erase text do not save it in the kill ring; they are known as
593 "delete" commands.  (This distinction is made only for erasure of text
594 in the buffer.)  If you do a kill or delete command by mistake, you can
595 use the `C-x u' (`undo') command to undo it (*note Undo::).
596
597    You cannot kill read-only text, since such text does not allow any
598 kind of modification.  But some users like to use the kill commands to
599 copy read-only text into the kill ring, without actually changing it.
600 If you set the variable `kill-read-only-ok' to a non-`nil' value, the
601 kill commands work specially in a read-only buffer: they move over
602 text, and copy it to the kill ring, without actually deleting it from
603 the buffer.  When this happens, a message in the echo area tells you
604 what is happening.
605
606    The delete commands include `C-d' (`delete-char') and <DEL>
607 (`delete-backward-char'), which delete only one character at a time,
608 and those commands that delete only spaces or newlines.  Commands that
609 can destroy significant amounts of nontrivial data generally do a kill
610 operation instead.  The commands' names and individual descriptions use
611 the words `kill' and `delete' to say which kind of operation they
612 perform.
613
614    Many window systems follow the convention that insertion while text
615 is selected deletes the selected text.  You can make Emacs behave this
616 way by enabling Delete Selection mode, with `M-x
617 delete-selection-mode', or using Custom.  Another effect of this mode
618 is that <DEL>, `C-d' and some other keys, when a selection exists, will
619 kill the whole selection.  It also enables Transient Mark mode (*note
620 Transient Mark::).
621
622 * Menu:
623
624 * Deletion::            Commands for deleting small amounts of text and
625                           blank areas.
626 * Killing by Lines::    How to kill entire lines of text at one time.
627 * Other Kill Commands:: Commands to kill large regions of text and
628                           syntactic units such as words and sentences.
629
630 
631 File: emacs,  Node: Deletion,  Next: Killing by Lines,  Up: Killing
632
633 Deletion
634 --------
635
636    Deletion means erasing text and not saving it in the kill ring.  For
637 the most part, the Emacs commands that delete text are those that erase
638 just one character or only whitespace.
639
640 `C-d'
641 `<Delete>'
642      Delete next character (`delete-char').  If your keyboard has a
643      <Delete> function key (usually located in the edit keypad), Emacs
644      binds it to `delete-char' as well.
645
646 `<DEL>'
647 `<BS>'
648      Delete previous character (`delete-backward-char').  Some keyboards
649      refer to this key as a "backspace key" and label it with a left
650      arrow.
651
652 `M-\'
653      Delete spaces and tabs around point (`delete-horizontal-space').
654
655 `M-<SPC>'
656      Delete spaces and tabs around point, leaving one space
657      (`just-one-space').
658
659 `C-x C-o'
660      Delete blank lines around the current line (`delete-blank-lines').
661
662 `M-^'
663      Join two lines by deleting the intervening newline, along with any
664      indentation following it (`delete-indentation').
665
666    The most basic delete commands are `C-d' (`delete-char') and <DEL>
667 (`delete-backward-char').  `C-d' deletes the character after point, the
668 one the cursor is "on top of."  This doesn't move point.  <DEL> deletes
669 the character before the cursor, and moves point back.  You can delete
670 newlines like any other characters in the buffer; deleting a newline
671 joins two lines.  Actually, `C-d' and <DEL> aren't always delete
672 commands; when given arguments, they kill instead, since they can erase
673 more than one character this way.
674
675    Every keyboard has a large key, labeled <DEL>, <BACKSPACE>, <BS> or
676 <DELETE>, which is a short distance above the <RET> or <ENTER> key and
677 is normally used for erasing what you have typed.  Regardless of the
678 actual name on the key, in Emacs it is equivalent to <DEL>--or it
679 should be.
680
681    Many keyboards (including standard PC keyboards) have a <BACKSPACE>
682 key a short ways above <RET> or <ENTER>, and a <DELETE> key elsewhere.
683 In that case, the <BACKSPACE> key is <DEL>, and the <DELETE> key is
684 equivalent to `C-d'--or it should be.
685
686    Why do we say "or it should be"?  When Emacs starts up using a
687 window system, it determines automatically which key or keys should be
688 equivalent to <DEL>.  As a result, <BACKSPACE> and/or <DELETE> keys
689 normally do the right things.  But in some unusual cases Emacs gets the
690 wrong information from the system.  If these keys don't do what they
691 ought to do, you need to tell Emacs which key to use for <DEL>.  *Note
692 DEL Does Not Delete::, for how to do this.
693
694    On most text-only terminals, Emacs cannot tell which keys the
695 keyboard really has, so it follows a uniform plan which may or may not
696 fit your keyboard.  The uniform plan is that the ASCII <DEL> character
697 deletes, and the ASCII <BS> (backspace) character asks for help (it is
698 the same as `C-h').  If this is not right for your keyboard, such as if
699 you find that the key which ought to delete backwards enters Help
700 instead, see *Note DEL Does Not Delete::.
701
702    The other delete commands are those which delete only whitespace
703 characters: spaces, tabs and newlines.  `M-\'
704 (`delete-horizontal-space') deletes all the spaces and tab characters
705 before and after point.  `M-<SPC>' (`just-one-space') does likewise but
706 leaves a single space after point, regardless of the number of spaces
707 that existed previously (even if there were none before).
708
709    `C-x C-o' (`delete-blank-lines') deletes all blank lines after the
710 current line.  If the current line is blank, it deletes all blank lines
711 preceding the current line as well (leaving one blank line, the current
712 line).
713
714    `M-^' (`delete-indentation') joins the current line and the previous
715 line, by deleting a newline and all surrounding spaces, usually leaving
716 a single space.  *Note M-^: Indentation.
717
718 
719 File: emacs,  Node: Killing by Lines,  Next: Other Kill Commands,  Prev: Deletion,  Up: Killing
720
721 Killing by Lines
722 ----------------
723
724 `C-k'
725      Kill rest of line or one or more lines (`kill-line').
726
727    The simplest kill command is `C-k'.  If given at the beginning of a
728 line, it kills all the text on the line, leaving it blank.  When used
729 on a blank line, it kills the whole line including its newline.  To kill
730 an entire non-blank line, go to the beginning and type `C-k' twice.
731
732    More generally, `C-k' kills from point up to the end of the line,
733 unless it is at the end of a line.  In that case it kills the newline
734 following point, thus merging the next line into the current one.
735 Spaces and tabs that you can't see at the end of the line are ignored
736 when deciding which case applies, so if point appears to be at the end
737 of the line, you can be sure `C-k' will kill the newline.
738
739    When `C-k' is given a positive argument, it kills that many lines
740 and the newlines that follow them (however, text on the current line
741 before point is not killed).  With a negative argument -N, it kills N
742 lines preceding the current line (together with the text on the current
743 line before point).  Thus, `C-u - 2 C-k' at the front of a line kills
744 the two previous lines.
745
746    `C-k' with an argument of zero kills the text before point on the
747 current line.
748
749    If the variable `kill-whole-line' is non-`nil', `C-k' at the very
750 beginning of a line kills the entire line including the following
751 newline.  This variable is normally `nil'.
752
753 
754 File: emacs,  Node: Other Kill Commands,  Prev: Killing by Lines,  Up: Killing
755
756 Other Kill Commands
757 -------------------
758
759 `C-w'
760      Kill region (from point to the mark) (`kill-region').
761
762 `M-d'
763      Kill word (`kill-word').  *Note Words::.
764
765 `M-<DEL>'
766      Kill word backwards (`backward-kill-word').
767
768 `C-x <DEL>'
769      Kill back to beginning of sentence (`backward-kill-sentence').
770      *Note Sentences::.
771
772 `M-k'
773      Kill to end of sentence (`kill-sentence').
774
775 `C-M-k'
776      Kill the following balanced expression (`kill-sexp').  *Note
777      Expressions::.
778
779 `M-z CHAR'
780      Kill through the next occurrence of CHAR (`zap-to-char').
781
782    A kill command which is very general is `C-w' (`kill-region'), which
783 kills everything between point and the mark.  With this command, you
784 can kill any contiguous sequence of characters, if you first set the
785 region around them.
786
787    A convenient way of killing is combined with searching: `M-z'
788 (`zap-to-char') reads a character and kills from point up to (and
789 including) the next occurrence of that character in the buffer.  A
790 numeric argument acts as a repeat count.  A negative argument means to
791 search backward and kill text before point.
792
793    Other syntactic units can be killed: words, with `M-<DEL>' and `M-d'
794 (*note Words::); balanced expressions, with `C-M-k' (*note
795 Expressions::); and sentences, with `C-x <DEL>' and `M-k' (*note
796 Sentences::).
797
798    You can use kill commands in read-only buffers.  They don't actually
799 change the buffer, and they beep to warn you of that, but they do copy
800 the text you tried to kill into the kill ring, so you can yank it into
801 other buffers.  Most of the kill commands move point across the text
802 they copy in this way, so that successive kill commands build up a
803 single kill ring entry as usual.
804
805 
806 File: emacs,  Node: Yanking,  Next: Accumulating Text,  Prev: Killing,  Up: Top
807
808 Yanking
809 =======
810
811    "Yanking" means reinserting text previously killed.  This is what
812 some systems call "pasting."  The usual way to move or copy text is to
813 kill it and then yank it elsewhere one or more times.
814
815 `C-y'
816      Yank last killed text (`yank').
817
818 `M-y'
819      Replace text just yanked with an earlier batch of killed text
820      (`yank-pop').
821
822 `M-w'
823      Save region as last killed text without actually killing it
824      (`kill-ring-save').
825
826 `C-M-w'
827      Append next kill to last batch of killed text (`append-next-kill').
828
829 * Menu:
830
831 * Kill Ring::           Where killed text is stored.  Basic yanking.
832 * Appending Kills::     Several kills in a row all yank together.
833 * Earlier Kills::       Yanking something killed some time ago.
834
835 
836 File: emacs,  Node: Kill Ring,  Next: Appending Kills,  Up: Yanking
837
838 The Kill Ring
839 -------------
840
841    All killed text is recorded in the "kill ring", a list of blocks of
842 text that have been killed.  There is only one kill ring, shared by all
843 buffers, so you can kill text in one buffer and yank it in another
844 buffer.  This is the usual way to move text from one file to another.
845 (*Note Accumulating Text::, for some other ways.)
846
847    The command `C-y' (`yank') reinserts the text of the most recent
848 kill.  It leaves the cursor at the end of the text.  It sets the mark at
849 the beginning of the text.  *Note Mark::.
850
851    `C-u C-y' leaves the cursor in front of the text, and sets the mark
852 after it.  This happens only if the argument is specified with just a
853 `C-u', precisely.  Any other sort of argument, including `C-u' and
854 digits, specifies an earlier kill to yank (*note Earlier Kills::).
855
856    To copy a block of text, you can use `M-w' (`kill-ring-save'), which
857 copies the region into the kill ring without removing it from the
858 buffer.  This is approximately equivalent to `C-w' followed by `C-x u',
859 except that `M-w' does not alter the undo history and does not
860 temporarily change the screen.
861
862 
863 File: emacs,  Node: Appending Kills,  Next: Earlier Kills,  Prev: Kill Ring,  Up: Yanking
864
865 Appending Kills
866 ---------------
867
868    Normally, each kill command pushes a new entry onto the kill ring.
869 However, two or more kill commands in a row combine their text into a
870 single entry, so that a single `C-y' yanks all the text as a unit, just
871 as it was before it was killed.
872
873    Thus, if you want to yank text as a unit, you need not kill all of it
874 with one command; you can keep killing line after line, or word after
875 word, until you have killed it all, and you can still get it all back at
876 once.
877
878    Commands that kill forward from point add onto the end of the
879 previous killed text.  Commands that kill backward from point add text
880 onto the beginning.  This way, any sequence of mixed forward and
881 backward kill commands puts all the killed text into one entry without
882 rearrangement.  Numeric arguments do not break the sequence of
883 appending kills.  For example, suppose the buffer contains this text:
884
885      This is a line -!-of sample text.
886
887 with point shown by -!-.  If you type `M-d M-<DEL> M-d M-<DEL>',
888 killing alternately forward and backward, you end up with `a line of
889 sample' as one entry in the kill ring, and `This is  text.' in the
890 buffer.  (Note the double space between `is' and `text', which you can
891 clean up with `M-<SPC>' or `M-q'.)
892
893    Another way to kill the same text is to move back two words with
894 `M-b M-b', then kill all four words forward with `C-u M-d'.  This
895 produces exactly the same results in the buffer and in the kill ring.
896 `M-f M-f C-u M-<DEL>' kills the same text, all going backward; once
897 again, the result is the same.  The text in the kill ring entry always
898 has the same order that it had in the buffer before you killed it.
899
900    If a kill command is separated from the last kill command by other
901 commands (not just numeric arguments), it starts a new entry on the kill
902 ring.  But you can force it to append by first typing the command
903 `C-M-w' (`append-next-kill') right before it.  The `C-M-w' tells the
904 following command, if it is a kill command, to append the text it kills
905 to the last killed text, instead of starting a new entry.  With
906 `C-M-w', you can kill several separated pieces of text and accumulate
907 them to be yanked back in one place.
908
909    A kill command following `M-w' does not append to the text that
910 `M-w' copied into the kill ring.
911
912 
913 File: emacs,  Node: Earlier Kills,  Prev: Appending Kills,  Up: Yanking
914
915 Yanking Earlier Kills
916 ---------------------
917
918    To recover killed text that is no longer the most recent kill, use
919 the `M-y' command (`yank-pop').  It takes the text previously yanked
920 and replaces it with the text from an earlier kill.  So, to recover the
921 text of the next-to-the-last kill, first use `C-y' to yank the last
922 kill, and then use `M-y' to replace it with the previous kill.  `M-y'
923 is allowed only after a `C-y' or another `M-y'.
924
925    You can understand `M-y' in terms of a "last yank" pointer which
926 points at an entry in the kill ring.  Each time you kill, the "last
927 yank" pointer moves to the newly made entry at the front of the ring.
928 `C-y' yanks the entry which the "last yank" pointer points to.  `M-y'
929 moves the "last yank" pointer to a different entry, and the text in the
930 buffer changes to match.  Enough `M-y' commands can move the pointer to
931 any entry in the ring, so you can get any entry into the buffer.
932 Eventually the pointer reaches the end of the ring; the next `M-y'
933 loops back around to the first entry again.
934
935    `M-y' moves the "last yank" pointer around the ring, but it does not
936 change the order of the entries in the ring, which always runs from the
937 most recent kill at the front to the oldest one still remembered.
938
939    `M-y' can take a numeric argument, which tells it how many entries
940 to advance the "last yank" pointer by.  A negative argument moves the
941 pointer toward the front of the ring; from the front of the ring, it
942 moves "around" to the last entry and continues forward from there.
943
944    Once the text you are looking for is brought into the buffer, you can
945 stop doing `M-y' commands and it will stay there.  It's just a copy of
946 the kill ring entry, so editing it in the buffer does not change what's
947 in the ring.  As long as no new killing is done, the "last yank"
948 pointer remains at the same place in the kill ring, so repeating `C-y'
949 will yank another copy of the same previous kill.
950
951    If you know how many `M-y' commands it would take to find the text
952 you want, you can yank that text in one step using `C-y' with a numeric
953 argument.  `C-y' with an argument restores the text from the specified
954 kill ring entry, counting back from the most recent as 1.  Thus, `C-u 2
955 C-y' gets the next-to-the-last block of killed text--it is equivalent
956 to `C-y M-y'.  `C-y' with a numeric argument starts counting from the
957 "last yank" pointer, and sets the "last yank" pointer to the entry that
958 it yanks.
959
960    The length of the kill ring is controlled by the variable
961 `kill-ring-max'; no more than that many blocks of killed text are saved.
962
963    The actual contents of the kill ring are stored in a variable named
964 `kill-ring'; you can view the entire contents of the kill ring with the
965 command `C-h v kill-ring'.
966
967 
968 File: emacs,  Node: Accumulating Text,  Next: Rectangles,  Prev: Yanking,  Up: Top
969
970 Accumulating Text
971 =================
972
973    Usually we copy or move text by killing it and yanking it, but there
974 are other methods convenient for copying one block of text in many
975 places, or for copying many scattered blocks of text into one place.  To
976 copy one block to many places, store it in a register (*note
977 Registers::).  Here we describe the commands to accumulate scattered
978 pieces of text into a buffer or into a file.
979
980 `M-x append-to-buffer'
981      Append region to the contents of a specified buffer.
982
983 `M-x prepend-to-buffer'
984      Prepend region to the contents of a specified buffer.
985
986 `M-x copy-to-buffer'
987      Copy region into a specified buffer, deleting that buffer's old
988      contents.
989
990 `M-x insert-buffer'
991      Insert the contents of a specified buffer into current buffer at
992      point.
993
994 `M-x append-to-file'
995      Append region to the contents of a specified file, at the end.
996
997    To accumulate text into a buffer, use `M-x append-to-buffer'.  This
998 reads a buffer name, then inserts a copy of the region into the buffer
999 specified.  If you specify a nonexistent buffer, `append-to-buffer'
1000 creates the buffer.  The text is inserted wherever point is in that
1001 buffer.  If you have been using the buffer for editing, the copied text
1002 goes into the middle of the text of the buffer, starting from wherever
1003 point happens to be at that moment.
1004
1005    Point in that buffer is left at the end of the copied text, so
1006 successive uses of `append-to-buffer' accumulate the text in the
1007 specified buffer in the same order as they were copied.  Strictly
1008 speaking, `append-to-buffer' does not always append to the text already
1009 in the buffer--it appends only if point in that buffer is at the end.
1010 However, if `append-to-buffer' is the only command you use to alter a
1011 buffer, then point is always at the end.
1012
1013    `M-x prepend-to-buffer' is just like `append-to-buffer' except that
1014 point in the other buffer is left before the copied text, so successive
1015 prependings add text in reverse order.  `M-x copy-to-buffer' is
1016 similar, except that any existing text in the other buffer is deleted,
1017 so the buffer is left containing just the text newly copied into it.
1018
1019    To retrieve the accumulated text from another buffer, use the
1020 command `M-x insert-buffer'; this too takes BUFFERNAME as an argument.
1021 It inserts a copy of the whole text in buffer BUFFERNAME into the
1022 current buffer at point, and sets the mark after the inserted text.
1023 Alternatively, you can select the other buffer for editing, then copy
1024 text from it by killing.  *Note Buffers::, for background information
1025 on buffers.
1026
1027    Instead of accumulating text within Emacs, in a buffer, you can
1028 append text directly into a file with `M-x append-to-file', which takes
1029 FILENAME as an argument.  It adds the text of the region to the end of
1030 the specified file.  The file is changed immediately on disk.
1031
1032    You should use `append-to-file' only with files that are _not_ being
1033 visited in Emacs.  Using it on a file that you are editing in Emacs
1034 would change the file behind Emacs's back, which can lead to losing
1035 some of your editing.
1036
1037 
1038 File: emacs,  Node: Rectangles,  Next: Registers,  Prev: Accumulating Text,  Up: Top
1039
1040 Rectangles
1041 ==========
1042
1043    The rectangle commands operate on rectangular areas of the text: all
1044 the characters between a certain pair of columns, in a certain range of
1045 lines.  Commands are provided to kill rectangles, yank killed
1046 rectangles, clear them out, fill them with blanks or text, or delete
1047 them.  Rectangle commands are useful with text in multicolumn formats,
1048 and for changing text into or out of such formats.
1049
1050    When you must specify a rectangle for a command to work on, you do it
1051 by putting the mark at one corner and point at the opposite corner.  The
1052 rectangle thus specified is called the "region-rectangle" because you
1053 control it in much the same way as the region is controlled.  But
1054 remember that a given combination of point and mark values can be
1055 interpreted either as a region or as a rectangle, depending on the
1056 command that uses them.
1057
1058    If point and the mark are in the same column, the rectangle they
1059 delimit is empty.  If they are in the same line, the rectangle is one
1060 line high.  This asymmetry between lines and columns comes about
1061 because point (and likewise the mark) is between two columns, but within
1062 a line.
1063
1064 `C-x r k'
1065      Kill the text of the region-rectangle, saving its contents as the
1066      "last killed rectangle" (`kill-rectangle').
1067
1068 `C-x r d'
1069      Delete the text of the region-rectangle (`delete-rectangle').
1070
1071 `C-x r y'
1072      Yank the last killed rectangle with its upper left corner at point
1073      (`yank-rectangle').
1074
1075 `C-x r o'
1076      Insert blank space to fill the space of the region-rectangle
1077      (`open-rectangle').  This pushes the previous contents of the
1078      region-rectangle rightward.
1079
1080 `M-x clear-rectangle'
1081      Clear the region-rectangle by replacing its contents with spaces.
1082
1083 `M-x delete-whitespace-rectangle'
1084      Delete whitespace in each of the lines on the specified rectangle,
1085      starting from the left edge column of the rectangle.
1086
1087 `C-x r t STRING <RET>'
1088      Replace rectangle contents with STRING on each line.
1089      (`string-rectangle').
1090
1091 `M-x string-insert-rectangle <RET> STRING <RET>'
1092      Insert STRING on each line of the rectangle.
1093
1094    The rectangle operations fall into two classes: commands for
1095 deleting and inserting rectangles, and commands for blank rectangles.
1096
1097    There are two ways to get rid of the text in a rectangle: you can
1098 discard the text (delete it) or save it as the "last killed" rectangle.
1099 The commands for these two ways are `C-x r d' (`delete-rectangle') and
1100 `C-x r k' (`kill-rectangle').  In either case, the portion of each line
1101 that falls inside the rectangle's boundaries is deleted, causing any
1102 following text on the line to move left into the gap.
1103
1104    Note that "killing" a rectangle is not killing in the usual sense;
1105 the rectangle is not stored in the kill ring, but in a special place
1106 that can only record the most recent rectangle killed.  This is because
1107 yanking a rectangle is so different from yanking linear text that
1108 different yank commands have to be used and yank-popping is hard to
1109 make sense of.
1110
1111    To yank the last killed rectangle, type `C-x r y'
1112 (`yank-rectangle').  Yanking a rectangle is the opposite of killing
1113 one.  Point specifies where to put the rectangle's upper left corner.
1114 The rectangle's first line is inserted there, the rectangle's second
1115 line is inserted at the same horizontal position, but one line
1116 vertically down, and so on.  The number of lines affected is determined
1117 by the height of the saved rectangle.
1118
1119    You can convert single-column lists into double-column lists using
1120 rectangle killing and yanking; kill the second half of the list as a
1121 rectangle and then yank it beside the first line of the list.  *Note
1122 Two-Column::, for another way to edit multi-column text.
1123
1124    You can also copy rectangles into and out of registers with `C-x r r
1125 R' and `C-x r i R'.  *Note Rectangle Registers: RegRect.
1126
1127    There are two commands you can use for making blank rectangles: `M-x
1128 clear-rectangle' which blanks out existing text, and `C-x r o'
1129 (`open-rectangle') which inserts a blank rectangle.  Clearing a
1130 rectangle is equivalent to deleting it and then inserting a blank
1131 rectangle of the same size.
1132
1133    The command `M-x delete-whitespace-rectangle' deletes horizontal
1134 whi