XEmacs 21.2-b1
[chise/xemacs-chise.git.1] / man / xemacs / regs.texi
1
2 @node Registers, Display, Rectangles, Top
3 @chapter Registers
4 @cindex registers
5
6   Emacs @dfn{registers} are places in which you can save text or
7 positions for later use.  Text saved in a register can be copied into
8 the buffer once or many times; a position saved in a register is used by
9 moving point to that position.  Rectangles can also be copied into and
10 out of registers (@pxref{Rectangles}).
11
12   Each register has a name, which is a single character.  A register can
13 store either a piece of text, a position, or a rectangle, but only one
14 thing at any given time.  Whatever you store in a register remains
15 there until you store something else in that register.
16
17 @menu
18 * RegPos::    Saving positions in registers.
19 * RegText::   Saving text in registers.
20 * RegRect::   Saving rectangles in registers.
21 @end menu
22
23 @table @kbd
24 @item M-x view-register @key{RET} @var{r}
25 Display a description of what register @var{r} contains.
26 @end table
27
28 @findex view-register
29   @kbd{M-x view-register} reads a register name as an argument and then
30 displays the contents of the specified register.
31
32 @node RegPos, RegText, Registers, Registers
33 @section Saving Positions in Registers
34
35   Saving a position records a spot in a buffer so you can move
36 back there later.  Moving to a saved position re-selects the buffer
37 and moves point to the spot.
38
39 @table @kbd
40 @item C-x r SPC @var{r}
41 Save the location of point in register @var{r} (@code{point-to-register}).
42 @item C-x r j @var{r}
43 Jump to the location saved in register @var{r} (@code{register-to-point}).
44 @end table
45
46 @kindex C-x r SPC
47 @findex point-to-register
48   To save the current location of point in a register, choose a name
49 @var{r} and type @kbd{C-x r SPC @var{r}}.  The register @var{r} retains
50 the location thus saved until you store something else in that
51 register.@refill
52
53 @kindex C-x r j
54 @findex register-to-point
55   The command @kbd{C-x r j @var{r}} moves point to the location recorded
56 in register @var{r}.  The register is not affected; it continues to
57 record the same location.  You can jump to the same position using the
58 same register as often as you want.
59
60 @node RegText, RegRect, RegPos, Registers
61 @section Saving Text in Registers
62
63   When you want to insert a copy of the same piece of text many times, it
64 can be impractical to use the kill ring, since each subsequent kill moves
65 the piece of text further down on the ring.  It becomes hard to keep
66 track of the argument needed to retrieve the same text with @kbd{C-y}.  An
67 alternative is to store the text in a register with @kbd{C-x r s}
68 (@code{copy-to-register}) and then retrieve it with @kbd{C-x r g}
69 (@code{insert-register}).
70
71 @table @kbd
72 @item C-x r s @var{r}
73 Copy region into register @var{r} (@code{copy-to-register}).
74 @item C-x r g @var{r}
75 Insert text contents of register @var{r} (@code{insert-register}).
76 @end table
77
78 @kindex C-x r s
79 @kindex C-x r g
80 @findex copy-to-register
81 @findex insert-register
82   @kbd{C-x r s @var{r}} stores a copy of the text of the region into the
83 register named @var{r}.  Given a numeric argument, @kbd{C-x r s} deletes the
84 text from the buffer as well.
85
86   @kbd{C-x r g @var{r}} inserts the text from register @var{r} in the buffer.
87 By default it leaves point before the text and places the mark after it. 
88 With a numeric argument, it puts point after the text and the mark
89 before it.
90
91 @node RegRect,, RegText, Registers
92 @section Saving Rectangles in Registers
93 @cindex rectangle
94 @findex copy-region-to-rectangle
95
96   A register can contain a rectangle instead of lines of text.  The rectangle
97 is represented as a list of strings.  @xref{Rectangles}, for basic
98 information on rectangles and how to specify rectangles in a buffer.
99
100 @table @kbd
101 @item C-x r r @var{r}
102 Copy the region-rectangle into register @var{r}(@code{copy-rectangle-to-register}).
103 With a numeric argument, delete it as well.
104 @item C-x r g @var{r}
105 Insert the rectangle stored in register @var{r} (if it contains a
106 rectangle) (@code{insert-register}).
107 @end table
108
109   The @kbd{C-x r g} command inserts linear text if the register contains
110 that, or inserts a rectangle if the register contains one.