aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-10-11 17:35:20 +0000
committerChong Yidong2008-10-11 17:35:20 +0000
commitea146ed84a034cdd601178a183b631fa6757a911 (patch)
treed510d7f2c31a732c5c6e947a7bb770c43ed8846c
parent89774b5f39bda0b0dc55e5d2b8f669390ae0bc95 (diff)
downloademacs-ea146ed84a034cdd601178a183b631fa6757a911.tar.gz
emacs-ea146ed84a034cdd601178a183b631fa6757a911.zip
(Buffers): Add xrefs to Mode Line and Lisp Interaction.
(Select Buffer): Mention use of minibuffer history. Describe default value of default-major-mode. Mention that C-x 4 b selects the other window. (List Buffers): Document CRM indicators in the order they appear. (Kill Buffer): Document new command kill-matching buffers. (Several Buffers): Move explanation of the relationship between buffer list and buffer menu to the top. (Indirect Buffers): Document new variable clone-indirect-buffer-hook.
-rw-r--r--doc/emacs/buffers.texi246
1 files changed, 119 insertions, 127 deletions
diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi
index 4d8fa5ad51e..e16e1c93133 100644
--- a/doc/emacs/buffers.texi
+++ b/doc/emacs/buffers.texi
@@ -13,32 +13,31 @@ directory listing. If you send a message with @kbd{C-x m}, a buffer named
13@samp{*mail*} is used to hold the text of the message. When you ask for a 13@samp{*mail*} is used to hold the text of the message. When you ask for a
14command's documentation, that appears in a buffer called @samp{*Help*}. 14command's documentation, that appears in a buffer called @samp{*Help*}.
15 15
16 Each buffer has a unique name, which can be of any length. When a
17buffer is displayed in a window, its name is shown in the mode line
18(@pxref{Mode Line}). The distinction between upper and lower case
19matters in buffer names. Most buffers are made by visiting files, and
20their names are derived from the files' names; however, you can also
21create an empty buffer with any name you want. A newly started Emacs
22has a buffer named @samp{*scratch*}, which is not associated with any
23file and can be used for evaluating Lisp expressions in Emacs
24(@pxref{Lisp Interaction}).
25
16@cindex selected buffer 26@cindex selected buffer
17@cindex current buffer 27@cindex current buffer
18 At any time, one and only one buffer is @dfn{current}. It is also 28 At any time, one and only one buffer is @dfn{current}. This is also
19called the @dfn{selected buffer}. Often we say that a command operates on 29called the @dfn{selected buffer}. We often say that a command
20``the buffer'' as if there were only one; but really this means that the 30operates on ``the buffer''; this really means that the command
21command operates on the current buffer (most commands do). 31operates on the current buffer (most commands do). When there is only
22 32one Emacs window, the buffer displayed in that window is current.
23 When Emacs has multiple windows, each window has its own chosen 33When there are multiple windows present, the buffer displayed in the
24buffer and displays it; at any time, only one of the windows is 34@dfn{selected window} is current. @xref{Windows}.
25selected, and its chosen buffer is the current buffer. Each window's 35
26mode line normally displays the name of the window's chosen buffer 36 Each buffer records individually what file it is visiting (if any),
27(@pxref{Windows}). 37whether it is modified, and what major mode and minor modes are in
28 38effect (@pxref{Major Modes}). Any Emacs variable can be made
29 Each buffer has a name, which can be of any length, and you can select 39@dfn{local to} a particular buffer, meaning its value in that buffer
30any buffer by giving its name. Most buffers are made by visiting files, 40can be different from the value in other buffers. @xref{Locals}.
31and their names are derived from the files' names. But you can also create
32an empty buffer with any name you want. A newly started Emacs has a buffer
33named @samp{*scratch*} which can be used for evaluating Lisp expressions in
34Emacs. The distinction between upper and lower case matters in buffer
35names.
36
37 Each buffer records individually what file it is visiting, whether it is
38modified, and what major mode and minor modes are in effect in it
39(@pxref{Major Modes}). Any Emacs variable can be made @dfn{local to} a
40particular buffer, meaning its value in that buffer can be different from
41the value in other buffers. @xref{Locals}.
42 41
43@cindex buffer size, maximum 42@cindex buffer size, maximum
44 A buffer's size cannot be larger than some maximum, which is defined 43 A buffer's size cannot be larger than some maximum, which is defined
@@ -85,13 +84,22 @@ selected buffer other than the current buffer.
85 84
86@kindex C-x b 85@kindex C-x b
87@findex switch-to-buffer 86@findex switch-to-buffer
88 To select the buffer named @var{bufname}, type @kbd{C-x b @var{bufname} 87 To select the buffer named @var{bufname}, type @kbd{C-x b
89@key{RET}}. This runs the command @code{switch-to-buffer} with argument 88@var{bufname} @key{RET}}. This runs the command
90@var{bufname}. You can use completion to enter the buffer 89@code{switch-to-buffer} with argument @var{bufname}. While entering
91name (@pxref{Completion}). An empty argument to @kbd{C-x b} 90the buffer name, you can use the usual minibuffer completion and
92specifies the buffer that was current most recently among those not 91history commands (@pxref{Minibuffer}). An empty argument to @kbd{C-x
92b} specifies the buffer that was current most recently among those not
93now displayed in any window. 93now displayed in any window.
94 94
95 If you specify a buffer that does not exist, @kbd{C-x b} creates a
96new, empty buffer that is not visiting any file, and selects it for
97editing. You can use such a buffer for making temporary notes. If
98you try to save it, you are asked for the file name to use. The new
99buffer's major mode is determined by the variable
100@code{default-major-mode}; the default value is Fundamental mode.
101@xref{Major Modes}.
102
95@kindex C-x @key{LEFT} 103@kindex C-x @key{LEFT}
96@kindex C-x @key{RIGHT} 104@kindex C-x @key{RIGHT}
97@findex next-buffer 105@findex next-buffer
@@ -106,19 +114,23 @@ of most recent selection in the current frame), while @kbd{C-x @key{LEFT}}
106@findex switch-to-buffer-other-window 114@findex switch-to-buffer-other-window
107@vindex even-window-heights 115@vindex even-window-heights
108 To select a buffer in a window other than the current one, type 116 To select a buffer in a window other than the current one, type
109@kbd{C-x 4 b @var{bufname} @key{RET}}. This runs the command 117@kbd{C-x 4 b} (@code{switch-to-buffer-other-window}). This prompts
110@code{switch-to-buffer-other-window} which displays the buffer 118for a buffer name using the minibuffer, displays that buffer in
111@var{bufname} in another window. By default, if displaying the buffer 119another window, and selects that window. By default, if displaying
112causes two vertically adjacent windows to be displayed, the heights of 120the buffer causes two vertically adjacent windows to be displayed, the
113those windows are evened out; to countermand that and preserve the 121heights of those windows are evened out; to countermand that and
114window configuration, set the variable @code{even-window-heights} to 122preserve the window configuration, set the variable
115@code{nil}. 123@code{even-window-heights} to @code{nil}.
116 124
117@kindex C-x 5 b 125@kindex C-x 5 b
118@findex switch-to-buffer-other-frame 126@findex switch-to-buffer-other-frame
119 Similarly, @kbd{C-x 5 b @var{buffer} @key{RET}} runs the command 127 Similarly, @kbd{C-x 5 b} (@code{switch-to-buffer-other-frame})
120@code{switch-to-buffer-other-frame} which selects a buffer in another 128prompts for a buffer name, displays that buffer in another frame, and
121frame. 129selects that frame.
130
131 In addition, @kbd{C-x C-f}, and any other command for visiting a
132file, can also be used to switch to an existing file-visiting buffer.
133@xref{Visiting}.
122 134
123@vindex display-buffer-reuse-frames 135@vindex display-buffer-reuse-frames
124 You can control how certain buffers are handled by these commands by 136 You can control how certain buffers are handled by these commands by
@@ -130,31 +142,18 @@ addition, if the value of @code{display-buffer-reuse-frames} is
130non-@code{nil}, and the buffer you want to switch to is already 142non-@code{nil}, and the buffer you want to switch to is already
131displayed in some frame, Emacs will just raise that frame. 143displayed in some frame, Emacs will just raise that frame.
132 144
133 Most buffers are created by visiting files, or by Emacs commands that 145 @kbd{C-u M-g M-g}, that is @code{goto-line} with a plain prefix
134want to display some text, but you can also create a buffer explicitly 146argument, reads a number @var{n} using the minibuffer, selects the
135by typing @kbd{C-x b @var{bufname} @key{RET}}. This makes a new, empty 147most recently selected buffer other than the current buffer in another
136buffer that is not visiting any file, and selects it for editing. Such 148window, and then moves point to the beginning of line number @var{n}
137buffers are used for making notes to yourself. If you try to save one, 149in that buffer. This is mainly useful in a buffer that refers to line
138you are asked for the file name to use. The new buffer's major mode is 150numbers in another buffer: if point is on or just after a number,
139determined by the value of @code{default-major-mode} (@pxref{Major 151@code{goto-line} uses that number as the default for @var{n}. Note
140Modes}). 152that prefix arguments other than just @kbd{C-u} behave differently.
141 153@kbd{C-u 4 M-g M-g} goes to line 4 in the @emph{current} buffer,
142 Note that @kbd{C-x C-f}, and any other command for visiting a file, 154without reading a number from the minibuffer. (Remember that @kbd{M-g
143can also be used to switch to an existing file-visiting buffer. 155M-g} without prefix argument reads a number @var{n} and then moves to
144@xref{Visiting}. 156line number @var{n} in the current buffer. @xref{Moving Point}.)
145
146 @kbd{C-u M-g M-g}, that is @code{goto-line} with a prefix argument
147of just @kbd{C-u}, reads a number @var{n} using the minibuffer,
148selects the most recently selected buffer other than the current
149buffer in another window, and then moves point to the beginning of
150line number @var{n} in that buffer. This is mainly useful in a buffer
151that refers to line numbers in another buffer: if point is on or just
152after a number, @code{goto-line} uses that number as the default for
153@var{n}. Note that prefix arguments other than just @kbd{C-u} behave
154differently. @kbd{C-u 4 M-g M-g} goes to line 4 in the @emph{current}
155buffer, without reading a number from the minibuffer. (Remember that
156@kbd{M-g M-g} without prefix argument reads a number @var{n} and then
157moves to line number @var{n} in the current buffer.)
158 157
159 Emacs uses buffer names that start with a space for internal purposes. 158 Emacs uses buffer names that start with a space for internal purposes.
160It treats these buffers specially in minor ways---for example, by 159It treats these buffers specially in minor ways---for example, by
@@ -177,11 +176,11 @@ line in the list shows one buffer's name, major mode and visited file.
177The buffers are listed in the order that they were current; the 176The buffers are listed in the order that they were current; the
178buffers that were current most recently come first. 177buffers that were current most recently come first.
179 178
180 @samp{*} in the first field of a line indicates the buffer is 179 @samp{.} in the first field of a line indicates that the buffer is
181``modified.'' If several buffers are modified, it may be time to save 180current. @samp{%} indicates a read-only buffer. @samp{*} indicates
182some with @kbd{C-x s} (@pxref{Save Commands}). @samp{%} indicates a 181that the buffer is ``modified.'' If several buffers are modified, it
183read-only buffer. @samp{.} marks the current buffer. Here is an 182may be time to save some with @kbd{C-x s} (@pxref{Save Commands}).
184example of a buffer list:@refill 183Here is an example of a buffer list:
185 184
186@smallexample 185@smallexample
187CRM Buffer Size Mode File 186CRM Buffer Size Mode File
@@ -197,16 +196,15 @@ CRM Buffer Size Mode File
197@end smallexample 196@end smallexample
198 197
199@noindent 198@noindent
200Note that the buffer @samp{*Help*} was made by a help request; it is 199The buffer @samp{*Help*} was made by a help request (@pxref{Help}); it
201not visiting any file. The buffer @code{src} was made by Dired on the 200is not visiting any file. The buffer @code{src} was made by Dired on
202directory @file{~/cvs/emacs/src/}. You can list only buffers that are 201the directory @file{~/cvs/emacs/src/}. You can list only buffers that
203visiting files by giving the command a prefix argument, as in 202are visiting files by giving the command a prefix argument, as in
204@kbd{C-u C-x C-b}. 203@kbd{C-u C-x C-b}.
205 204
206 @code{list-buffers} omits buffers whose names begin with a space, 205 @code{list-buffers} omits buffers whose names begin with a space,
207unless they visit files: such buffers are used internally by Emacs. 206unless they visit files: such buffers are used internally by Emacs.
208 207
209@need 2000
210@node Misc Buffer 208@node Misc Buffer
211@section Miscellaneous Buffer Operations 209@section Miscellaneous Buffer Operations
212 210
@@ -291,28 +289,37 @@ programs can use it. Here are some commands for killing buffers:
291Kill buffer @var{bufname} (@code{kill-buffer}). 289Kill buffer @var{bufname} (@code{kill-buffer}).
292@item M-x kill-some-buffers 290@item M-x kill-some-buffers
293Offer to kill each buffer, one by one. 291Offer to kill each buffer, one by one.
292@item M-x kill-matching-buffers
293Offer to kill all buffers matching a regular expression.
294@end table 294@end table
295 295
296@findex kill-buffer 296@findex kill-buffer
297@findex kill-some-buffers
298@kindex C-x k 297@kindex C-x k
299
300 @kbd{C-x k} (@code{kill-buffer}) kills one buffer, whose name you 298 @kbd{C-x k} (@code{kill-buffer}) kills one buffer, whose name you
301specify in the minibuffer. The default, used if you type just 299specify in the minibuffer. The default, used if you type just
302@key{RET} in the minibuffer, is to kill the current buffer. If you 300@key{RET} in the minibuffer, is to kill the current buffer. If you
303kill the current buffer, another buffer becomes current: one that was 301kill the current buffer, another buffer becomes current: one that was
304current in the recent past but is not displayed in any window now. If 302current in the recent past but is not displayed in any window now. If
305you ask to kill a file-visiting buffer that is modified (has unsaved 303you ask to kill a file-visiting buffer that is modified, then you must
306editing), then you must confirm with @kbd{yes} before the buffer is 304confirm with @kbd{yes} before the buffer is killed.
307killed.
308
309 The command @kbd{M-x kill-some-buffers} asks about each buffer, one by
310one. An answer of @kbd{y} means to kill the buffer. Killing the current
311buffer or a buffer containing unsaved changes selects a new buffer or asks
312for confirmation just like @code{kill-buffer}.
313 305
314 The buffer menu feature (@pxref{Several Buffers}) is also convenient 306@findex kill-some-buffers
315for killing various buffers. 307 The command @kbd{M-x kill-some-buffers} asks about each buffer, one
308by one. An answer of @kbd{y} means to kill the buffer, just like
309@code{kill-buffer}. This command ignores buffers whose names begin
310with a space, which are used internally by Emacs.
311
312@findex kill-matching-buffers
313 The command @kbd{M-x kill-matching-buffers} prompts for a regular
314expression and kills all buffers whose names match that expression.
315@xref{Regexps}. Like @code{kill-some-buffers}, it asks for
316confirmation before each kill. This command normally ignores buffers
317whose names begin with a space, which are used internally by Emacs.
318To kill internal buffers as well, call @code{kill-matching-buffers}
319with a prefix argument.
320
321 The buffer menu feature is also convenient for killing various
322buffers. @xref{Several Buffers}.
316 323
317@vindex kill-buffer-hook 324@vindex kill-buffer-hook
318 If you want to do something special every time a buffer is killed, you 325 If you want to do something special every time a buffer is killed, you
@@ -332,24 +339,17 @@ for a mere hour.
332@vindex midnight-mode 339@vindex midnight-mode
333@vindex midnight-hook 340@vindex midnight-hook
334 You can also have this buffer purging done for you, every day at 341 You can also have this buffer purging done for you, every day at
335midnight, by enabling Midnight mode. Midnight mode operates each day at 342midnight, by enabling Midnight mode. Midnight mode operates each day
336midnight; at that time, it runs @code{clean-buffer-list}, or whichever 343at midnight; at that time, it runs @code{clean-buffer-list}, or
337functions you have placed in the normal hook @code{midnight-hook} 344whichever functions you have placed in the normal hook
338(@pxref{Hooks}). 345@code{midnight-hook} (@pxref{Hooks}). To enable Midnight mode, use
339 346the Customization buffer to set the variable @code{midnight-mode} to
340 To enable Midnight mode, use the Customization buffer to set the 347@code{t}. @xref{Easy Customization}.
341variable @code{midnight-mode} to @code{t}. @xref{Easy Customization}.
342 348
343@node Several Buffers 349@node Several Buffers
344@section Operating on Several Buffers 350@section Operating on Several Buffers
345@cindex buffer menu 351@cindex buffer menu
346 352
347 The @dfn{buffer-menu} facility is like a ``Dired for buffers''; it allows
348you to request operations on various Emacs buffers by editing an Emacs
349buffer containing a list of them. You can save buffers, kill them
350(here called @dfn{deleting} them, for consistency with Dired), or display
351them.
352
353@table @kbd 353@table @kbd
354@item M-x buffer-menu 354@item M-x buffer-menu
355Begin editing a buffer listing all Emacs buffers. 355Begin editing a buffer listing all Emacs buffers.
@@ -357,19 +357,24 @@ Begin editing a buffer listing all Emacs buffers.
357Similar, but do it in another window. 357Similar, but do it in another window.
358@end table 358@end table
359 359
360 The @dfn{buffer menu} opened by @kbd{C-x C-b} (@pxref{List Buffers})
361does not merely list buffers. It also allows you to perform various
362operations on buffers, through an interface similar to Dired
363(@pxref{Dired}). You can save buffers, kill them (here called
364@dfn{deleting} them, for consistency with Dired), or display them.
365
360@findex buffer-menu 366@findex buffer-menu
361@findex buffer-menu-other-window 367@findex buffer-menu-other-window
362 The command @code{buffer-menu} writes a list of all Emacs 368 To use the buffer menu, type @kbd{C-x C-b} and switch to the window
363buffers@footnote{Buffers which don't visit files and whose names begin 369displaying the @samp{*Buffer List*} buffer. You can also type
364with a space are omitted: these are used internally by Emacs.} into the 370@kbd{M-x buffer-menu} to open the buffer menu in the selected window.
365buffer @samp{*Buffer List*}, and selects that buffer in Buffer Menu 371Alternatively, the command @kbd{M-x buffer-menu-other-window} opens
366mode. 372the buffer menu in another window, and selects that window.
367 373
368 The buffer is read-only, and can be 374 The buffer menu is a read-only buffer, and can be changed only
369changed only through the special commands described in this section. 375through the special commands described in this section. The usual
370The usual Emacs cursor motion commands can be used in the @samp{*Buffer 376Emacs cursor motion commands can be used in this buffer. The
371List*} buffer. The following commands apply to the buffer described on 377following commands apply to the buffer described on the current line:
372the current line.
373 378
374@table @kbd 379@table @kbd
375@item d 380@item d
@@ -460,16 +465,6 @@ there. You can reselect the @samp{*Buffer List*} buffer later, to
460perform the operations already requested, or you can kill it, or pay 465perform the operations already requested, or you can kill it, or pay
461no further attention to it. 466no further attention to it.
462 467
463 The list in the @samp{*Buffer List*} buffer looks exactly like the
464buffer list described in @ref{List Buffers}, because they really are
465the same. The only difference between @code{buffer-menu} and
466@code{list-buffers} is that @code{buffer-menu} switches to the
467@samp{*Buffer List*} buffer in the selected window;
468@code{list-buffers} displays the same buffer in another window. If
469you run @code{list-buffers} (that is, type @kbd{C-x C-b}) and select
470the buffer list manually, you can use all of the commands described
471here.
472
473 Normally, the buffer @samp{*Buffer List*} is not updated 468 Normally, the buffer @samp{*Buffer List*} is not updated
474automatically when buffers are created and killed; its contents are 469automatically when buffers are created and killed; its contents are
475just text. If you have created, deleted or renamed buffers, the way 470just text. If you have created, deleted or renamed buffers, the way
@@ -486,11 +481,6 @@ Auto Revert mode applies to the @samp{*Buffer List*} buffer only if
486@xref{Autorevert, global-auto-revert-non-file-buffers}, for details. 481@xref{Autorevert, global-auto-revert-non-file-buffers}, for details.
487@end ifnottex 482@end ifnottex
488 483
489
490 The command @code{buffer-menu-other-window} works the same as
491@code{buffer-menu}, except that it displays the buffers list in
492another window.
493
494@node Indirect Buffers 484@node Indirect Buffers
495@section Indirect Buffers 485@section Indirect Buffers
496@cindex indirect buffer 486@cindex indirect buffer
@@ -518,7 +508,7 @@ select it in another window (@code{clone-indirect-buffer-other-window}).
518 The text of the indirect buffer is always identical to the text of its 508 The text of the indirect buffer is always identical to the text of its
519base buffer; changes made by editing either one are visible immediately 509base buffer; changes made by editing either one are visible immediately
520in the other. But in all other respects, the indirect buffer and its 510in the other. But in all other respects, the indirect buffer and its
521base buffer are completely separate. They have different names, 511base buffer are completely separate. They can have different names,
522different values of point, different narrowing, different markers, 512different values of point, different narrowing, different markers,
523different major modes, and different local variables. 513different major modes, and different local variables.
524 514
@@ -530,6 +520,7 @@ buffer, but killing an indirect buffer has no effect on its base buffer.
530 One way to use indirect buffers is to display multiple views of an 520 One way to use indirect buffers is to display multiple views of an
531outline. @xref{Outline Views}. 521outline. @xref{Outline Views}.
532 522
523@vindex clone-indirect-buffer-hook
533 A quick and handy way to make an indirect buffer is with the command 524 A quick and handy way to make an indirect buffer is with the command
534@kbd{M-x clone-indirect-buffer}. It creates and selects an indirect 525@kbd{M-x clone-indirect-buffer}. It creates and selects an indirect
535buffer whose base buffer is the current buffer. With a numeric 526buffer whose base buffer is the current buffer. With a numeric
@@ -537,7 +528,8 @@ argument, it prompts for the name of the indirect buffer; otherwise it
537uses the name of the current buffer, with a @samp{<@var{n}>} suffix 528uses the name of the current buffer, with a @samp{<@var{n}>} suffix
538added. @kbd{C-x 4 c} (@code{clone-indirect-buffer-other-window}) 529added. @kbd{C-x 4 c} (@code{clone-indirect-buffer-other-window})
539works like @kbd{M-x clone-indirect-buffer}, but it selects the new 530works like @kbd{M-x clone-indirect-buffer}, but it selects the new
540buffer in another window. 531buffer in another window. These functions run the hook
532@code{clone-indirect-buffer-hook} after creating the indirect buffer.
541 533
542 The more general way to make an indirect buffer is with the command 534 The more general way to make an indirect buffer is with the command
543@kbd{M-x make-indirect-buffer}. It creates an indirect buffer from 535@kbd{M-x make-indirect-buffer}. It creates an indirect buffer from