Mercurial > emacs
annotate man/regs.texi @ 60489:7d03f539a034
Fix last change.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Mon, 07 Mar 2005 13:43:34 +0000 |
parents | 13d3a7544d29 |
children | 3723093a21fd 3ebd9bdb4fe5 |
rev | line source |
---|---|
25829 | 1 @c This is part of the Emacs manual. |
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc. | |
3 @c See file emacs.texi for copying conditions. | |
4 @node Registers, Display, Rectangles, Top | |
5 @chapter Registers | |
6 @cindex registers | |
7 | |
37313 | 8 Emacs @dfn{registers} are compartments where you can save text, |
9 rectangles, positions, and other things for later use. Once you save | |
10 text or a rectangle in a register, you can copy it into the buffer | |
38129 | 11 once, or many times; you can move point to a position saved in a |
12 register once, or many times. | |
25829 | 13 |
14 @findex view-register | |
59952
13d3a7544d29
(Registers): Registers can hold numbers, too.
Richard M. Stallman <rms@gnu.org>
parents:
56655
diff
changeset
|
15 Each register has a name, which consists of a single character. A |
13d3a7544d29
(Registers): Registers can hold numbers, too.
Richard M. Stallman <rms@gnu.org>
parents:
56655
diff
changeset
|
16 register can store a number, a piece of text, a rectangle, a position, |
13d3a7544d29
(Registers): Registers can hold numbers, too.
Richard M. Stallman <rms@gnu.org>
parents:
56655
diff
changeset
|
17 a window configuration, or a file name, but only one thing at any |
13d3a7544d29
(Registers): Registers can hold numbers, too.
Richard M. Stallman <rms@gnu.org>
parents:
56655
diff
changeset
|
18 given time. Whatever you store in a register remains there until you |
13d3a7544d29
(Registers): Registers can hold numbers, too.
Richard M. Stallman <rms@gnu.org>
parents:
56655
diff
changeset
|
19 store something else in that register. To see what a register @var{r} |
13d3a7544d29
(Registers): Registers can hold numbers, too.
Richard M. Stallman <rms@gnu.org>
parents:
56655
diff
changeset
|
20 contains, use @kbd{M-x view-register}. |
25829 | 21 |
22 @table @kbd | |
23 @item M-x view-register @key{RET} @var{r} | |
24 Display a description of what register @var{r} contains. | |
25 @end table | |
26 | |
27 @menu | |
28 * Position: RegPos. Saving positions in registers. | |
29 * Text: RegText. Saving text in registers. | |
30 * Rectangle: RegRect. Saving rectangles in registers. | |
31 * Configurations: RegConfig. Saving window configurations in registers. | |
56655
3a8fa7f090da
(RegNumbers): Mention `C-x r i' binding for `insert-register', instead
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
32 * Numbers: RegNumbers. Numbers in registers. |
25829 | 33 * Files: RegFiles. File names in registers. |
34 * Bookmarks:: Bookmarks are like registers, but persistent. | |
35 @end menu | |
36 | |
37 @node RegPos | |
38 @section Saving Positions in Registers | |
40267
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
39 @cindex saving position in a register |
25829 | 40 |
41 Saving a position records a place in a buffer so that you can move | |
42 back there later. Moving to a saved position switches to that buffer | |
43 and moves point to that place in it. | |
44 | |
45 @table @kbd | |
46 @item C-x r @key{SPC} @var{r} | |
47 Save position of point in register @var{r} (@code{point-to-register}). | |
48 @item C-x r j @var{r} | |
49 Jump to the position saved in register @var{r} (@code{jump-to-register}). | |
50 @end table | |
51 | |
52 @kindex C-x r SPC | |
53 @findex point-to-register | |
54 To save the current position of point in a register, choose a name | |
55 @var{r} and type @kbd{C-x r @key{SPC} @var{r}}. The register @var{r} | |
56 retains the position thus saved until you store something else in that | |
57 register. | |
58 | |
59 @kindex C-x r j | |
60 @findex jump-to-register | |
61 The command @kbd{C-x r j @var{r}} moves point to the position recorded | |
62 in register @var{r}. The register is not affected; it continues to | |
38129 | 63 hold the same position. You can jump to the saved position any number |
25829 | 64 of times. |
65 | |
66 If you use @kbd{C-x r j} to go to a saved position, but the buffer it | |
67 was saved from has been killed, @kbd{C-x r j} tries to create the buffer | |
68 again by visiting the same file. Of course, this works only for buffers | |
69 that were visiting files. | |
70 | |
71 @node RegText | |
72 @section Saving Text in Registers | |
40267
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
73 @cindex saving text in a register |
25829 | 74 |
75 When you want to insert a copy of the same piece of text several | |
76 times, it may be inconvenient to yank it from the kill ring, since each | |
77 subsequent kill moves that entry further down the ring. An alternative | |
78 is to store the text in a register and later retrieve it. | |
79 | |
80 @table @kbd | |
81 @item C-x r s @var{r} | |
82 Copy region into register @var{r} (@code{copy-to-register}). | |
83 @item C-x r i @var{r} | |
84 Insert text from register @var{r} (@code{insert-register}). | |
40267
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
85 @item M-x append-to-register @key{RET} @var{r} |
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
86 Append region to text in register @var{r}. |
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
87 @item M-x prepend-to-register @key{RET} @var{r} |
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
88 Prepend region to text in register @var{r}. |
25829 | 89 @end table |
90 | |
91 @kindex C-x r s | |
92 @kindex C-x r i | |
93 @findex copy-to-register | |
94 @findex insert-register | |
38129 | 95 @kbd{C-x r s @var{r}} stores a copy of the text of the region into |
96 the register named @var{r}. @kbd{C-u C-x r s @var{r}}, the same | |
97 command with a numeric argument, deletes the text from the buffer as | |
38954 | 98 well; you can think of this as ``moving'' the region text into the register. |
25829 | 99 |
40267
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
100 @findex append-to-register |
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
101 @findex prepend-to-register |
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
102 @kbd{M-x append-to-register @key{RET} @var{r}} appends the copy of |
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
103 the text in the region to the text already stored in the register |
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
104 named @var{r}. If invoked with a numeric argument, it deletes the |
40415
ac85b3ae7a59
(RegText): Fix the wording in the last change. From Richard Stallman.
Eli Zaretskii <eliz@gnu.org>
parents:
40267
diff
changeset
|
105 region after appending it to the register. The command |
ac85b3ae7a59
(RegText): Fix the wording in the last change. From Richard Stallman.
Eli Zaretskii <eliz@gnu.org>
parents:
40267
diff
changeset
|
106 @code{prepend-to-register} is similar, except that it @emph{prepends} |
ac85b3ae7a59
(RegText): Fix the wording in the last change. From Richard Stallman.
Eli Zaretskii <eliz@gnu.org>
parents:
40267
diff
changeset
|
107 the region text to the text in the register, rather than |
ac85b3ae7a59
(RegText): Fix the wording in the last change. From Richard Stallman.
Eli Zaretskii <eliz@gnu.org>
parents:
40267
diff
changeset
|
108 @emph{appending} it. |
40267
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
109 |
25829 | 110 @kbd{C-x r i @var{r}} inserts in the buffer the text from register |
111 @var{r}. Normally it leaves point before the text and places the mark | |
112 after, but with a numeric argument (@kbd{C-u}) it puts point after the | |
113 text and the mark before. | |
114 | |
115 @node RegRect | |
116 @section Saving Rectangles in Registers | |
40267
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
117 @cindex saving rectangle in a register |
25829 | 118 |
119 A register can contain a rectangle instead of linear text. The | |
120 rectangle is represented as a list of strings. @xref{Rectangles}, for | |
121 basic information on how to specify a rectangle in the buffer. | |
122 | |
123 @table @kbd | |
124 @findex copy-rectangle-to-register | |
125 @kindex C-x r r | |
126 @item C-x r r @var{r} | |
127 Copy the region-rectangle into register @var{r} | |
128 (@code{copy-rectangle-to-register}). With numeric argument, delete it as | |
129 well. | |
130 @item C-x r i @var{r} | |
131 Insert the rectangle stored in register @var{r} (if it contains a | |
132 rectangle) (@code{insert-register}). | |
133 @end table | |
134 | |
135 The @kbd{C-x r i @var{r}} command inserts a text string if the | |
136 register contains one, and inserts a rectangle if the register contains | |
137 one. | |
138 | |
139 See also the command @code{sort-columns}, which you can think of | |
140 as sorting a rectangle. @xref{Sorting}. | |
141 | |
142 @node RegConfig | |
143 @section Saving Window Configurations in Registers | |
40267
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
144 @cindex saving window configuration in a register |
25829 | 145 |
146 @findex window-configuration-to-register | |
147 @findex frame-configuration-to-register | |
148 @kindex C-x r w | |
149 @kindex C-x r f | |
150 You can save the window configuration of the selected frame in a | |
151 register, or even the configuration of all windows in all frames, and | |
152 restore the configuration later. | |
153 | |
154 @table @kbd | |
155 @item C-x r w @var{r} | |
156 Save the state of the selected frame's windows in register @var{r} | |
157 (@code{window-configuration-to-register}). | |
158 @item C-x r f @var{r} | |
159 Save the state of all frames, including all their windows, in register | |
160 @var{r} (@code{frame-configuration-to-register}). | |
161 @end table | |
162 | |
163 Use @kbd{C-x r j @var{r}} to restore a window or frame configuration. | |
164 This is the same command used to restore a cursor position. When you | |
165 restore a frame configuration, any existing frames not included in the | |
166 configuration become invisible. If you wish to delete these frames | |
167 instead, use @kbd{C-u C-x r j @var{r}}. | |
168 | |
169 @node RegNumbers | |
170 @section Keeping Numbers in Registers | |
40267
dca37162945a
(RegText): Document append-to-register and prepend-to-register.
Eli Zaretskii <eliz@gnu.org>
parents:
38954
diff
changeset
|
171 @cindex saving number in a register |
25829 | 172 |
173 There are commands to store a number in a register, to insert | |
174 the number in the buffer in decimal, and to increment it. These commands | |
175 can be useful in keyboard macros (@pxref{Keyboard Macros}). | |
176 | |
177 @table @kbd | |
37313 | 178 @item C-u @var{number} C-x r n @var{r} |
25829 | 179 @kindex C-x r n |
180 @findex number-to-register | |
37313 | 181 Store @var{number} into register @var{r} (@code{number-to-register}). |
182 @item C-u @var{number} C-x r + @var{r} | |
25829 | 183 @kindex C-x r + |
184 @findex increment-register | |
37313 | 185 Increment the number in register @var{r} by @var{number} |
25829 | 186 (@code{increment-register}). |
56655
3a8fa7f090da
(RegNumbers): Mention `C-x r i' binding for `insert-register', instead
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
187 @item C-x r i @var{r} |
37313 | 188 Insert the number from register @var{r} into the buffer. |
25829 | 189 @end table |
190 | |
56655
3a8fa7f090da
(RegNumbers): Mention `C-x r i' binding for `insert-register', instead
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
191 @kbd{C-x r i} is the same command used to insert any other sort of |
37313 | 192 register contents into the buffer. @kbd{C-x r +} with no numeric |
193 argument increments the register value by 1; @kbd{C-x r n} with no | |
194 numeric argument stores zero in the register. | |
25829 | 195 |
196 @node RegFiles | |
197 @section Keeping File Names in Registers | |
48700 | 198 @cindex saving file name in a register |
25829 | 199 |
200 If you visit certain file names frequently, you can visit them more | |
201 conveniently if you put their names in registers. Here's the Lisp code | |
202 used to put a file name in a register: | |
203 | |
204 @smallexample | |
205 (set-register ?@var{r} '(file . @var{name})) | |
206 @end smallexample | |
207 | |
208 @need 3000 | |
209 @noindent | |
210 For example, | |
211 | |
212 @smallexample | |
213 (set-register ?z '(file . "/gd/gnu/emacs/19.0/src/ChangeLog")) | |
214 @end smallexample | |
215 | |
216 @noindent | |
217 puts the file name shown in register @samp{z}. | |
218 | |
219 To visit the file whose name is in register @var{r}, type @kbd{C-x r j | |
220 @var{r}}. (This is the same command used to jump to a position or | |
221 restore a frame configuration.) | |
222 | |
223 @node Bookmarks | |
224 @section Bookmarks | |
225 @cindex bookmarks | |
226 | |
227 @dfn{Bookmarks} are somewhat like registers in that they record | |
228 positions you can jump to. Unlike registers, they have long names, and | |
229 they persist automatically from one Emacs session to the next. The | |
230 prototypical use of bookmarks is to record ``where you were reading'' in | |
231 various files. | |
232 | |
233 @table @kbd | |
234 @item C-x r m @key{RET} | |
235 Set the bookmark for the visited file, at point. | |
236 | |
237 @item C-x r m @var{bookmark} @key{RET} | |
238 @findex bookmark-set | |
239 Set the bookmark named @var{bookmark} at point (@code{bookmark-set}). | |
240 | |
241 @item C-x r b @var{bookmark} @key{RET} | |
242 @findex bookmark-jump | |
243 Jump to the bookmark named @var{bookmark} (@code{bookmark-jump}). | |
244 | |
245 @item C-x r l | |
246 @findex list-bookmarks | |
247 List all bookmarks (@code{list-bookmarks}). | |
248 | |
249 @item M-x bookmark-save | |
250 @findex bookmark-save | |
251 Save all the current bookmark values in the default bookmark file. | |
252 @end table | |
253 | |
254 @kindex C-x r m | |
255 @findex bookmark-set | |
256 @kindex C-x r b | |
257 @findex bookmark-jump | |
258 The prototypical use for bookmarks is to record one current position | |
259 in each of several files. So the command @kbd{C-x r m}, which sets a | |
260 bookmark, uses the visited file name as the default for the bookmark | |
261 name. If you name each bookmark after the file it points to, then you | |
262 can conveniently revisit any of those files with @kbd{C-x r b}, and move | |
263 to the position of the bookmark at the same time. | |
264 | |
265 @kindex C-x r l | |
266 To display a list of all your bookmarks in a separate buffer, type | |
267 @kbd{C-x r l} (@code{list-bookmarks}). If you switch to that buffer, | |
268 you can use it to edit your bookmark definitions or annotate the | |
38954 | 269 bookmarks. Type @kbd{C-h m} in the bookmark buffer for more |
270 information about its special editing commands. | |
25829 | 271 |
272 When you kill Emacs, Emacs offers to save your bookmark values in your | |
273 default bookmark file, @file{~/.emacs.bmk}, if you have changed any | |
274 bookmark values. You can also save the bookmarks at any time with the | |
275 @kbd{M-x bookmark-save} command. The bookmark commands load your | |
276 default bookmark file automatically. This saving and loading is how | |
277 bookmarks persist from one Emacs session to the next. | |
278 | |
279 @vindex bookmark-save-flag | |
280 If you set the variable @code{bookmark-save-flag} to 1, then each | |
281 command that sets a bookmark will also save your bookmarks; this way, | |
282 you don't lose any bookmark values even if Emacs crashes. (The value, | |
283 if a number, says how many bookmark modifications should go by between | |
284 saving.) | |
285 | |
286 @vindex bookmark-search-size | |
287 Bookmark position values are saved with surrounding context, so that | |
288 @code{bookmark-jump} can find the proper position even if the file is | |
289 modified slightly. The variable @code{bookmark-search-size} says how | |
38048
bd45e6c57fba
Proofreading fixes from Danny Colascione <qtmstr@optonline.net>.
Eli Zaretskii <eliz@gnu.org>
parents:
37313
diff
changeset
|
290 many characters of context to record on each side of the bookmark's |
25829 | 291 position. |
292 | |
293 Here are some additional commands for working with bookmarks: | |
294 | |
295 @table @kbd | |
296 @item M-x bookmark-load @key{RET} @var{filename} @key{RET} | |
297 @findex bookmark-load | |
298 Load a file named @var{filename} that contains a list of bookmark | |
299 values. You can use this command, as well as @code{bookmark-write}, to | |
300 work with other files of bookmark values in addition to your default | |
301 bookmark file. | |
302 | |
303 @item M-x bookmark-write @key{RET} @var{filename} @key{RET} | |
304 @findex bookmark-write | |
305 Save all the current bookmark values in the file @var{filename}. | |
306 | |
307 @item M-x bookmark-delete @key{RET} @var{bookmark} @key{RET} | |
308 @findex bookmark-delete | |
309 Delete the bookmark named @var{bookmark}. | |
310 | |
311 @item M-x bookmark-insert-location @key{RET} @var{bookmark} @key{RET} | |
312 @findex bookmark-insert-location | |
313 Insert in the buffer the name of the file that bookmark @var{bookmark} | |
314 points to. | |
315 | |
316 @item M-x bookmark-insert @key{RET} @var{bookmark} @key{RET} | |
317 @findex bookmark-insert | |
318 Insert in the buffer the @emph{contents} of the file that bookmark | |
319 @var{bookmark} points to. | |
320 @end table | |
52401 | 321 |
322 @ignore | |
323 arch-tag: b00af991-ebc3-4b3a-8e82-a3ac81ff2e64 | |
324 @end ignore |