Mercurial > emacs
comparison lispref/buffers.texi @ 54862:8de44f69312c
Various changes in addition to:
(Buffer File Name): Add `find-buffer-visiting'.
(Buffer Modification): Mention optional ARG to `not-modified'.
(Indirect Buffers): Mention optional CLONE argument to `make-indirect-buffer'.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Wed, 14 Apr 2004 02:47:18 +0000 |
parents | 1ba2429172a9 |
children | 07ceecd3e471 |
comparison
equal
deleted
inserted
replaced
54861:5af1398ad8e2 | 54862:8de44f69312c |
---|---|
213 exit from @code{save-current-buffer}, then it is not made current again, | 213 exit from @code{save-current-buffer}, then it is not made current again, |
214 of course. Instead, whichever buffer was current just before exit | 214 of course. Instead, whichever buffer was current just before exit |
215 remains current. | 215 remains current. |
216 @end defspec | 216 @end defspec |
217 | 217 |
218 @defmac with-current-buffer buffer body... | 218 @defmac with-current-buffer buffer-or-name body... |
219 The @code{with-current-buffer} macro saves the identity of the current | 219 The @code{with-current-buffer} macro saves the identity of the current |
220 buffer, makes @var{buffer} current, evaluates the @var{body} forms, and | 220 buffer, makes @var{buffer-or-name} current, evaluates the @var{body} |
221 finally restores the buffer. The return value is the value of the last | 221 forms, and finally restores the buffer. The return value is the value |
222 form in @var{body}. The current buffer is restored even in case of an | 222 of the last form in @var{body}. The current buffer is restored even |
223 abnormal exit via @code{throw} or error (@pxref{Nonlocal Exits}). | 223 in case of an abnormal exit via @code{throw} or error (@pxref{Nonlocal |
224 Exits}). | |
225 | |
226 An error is signaled if @var{buffer-or-name} does not identify an | |
227 existing buffer. | |
224 @end defmac | 228 @end defmac |
225 | 229 |
226 @anchor{Definition of with-temp-buffer} | 230 @anchor{Definition of with-temp-buffer} |
227 @defmac with-temp-buffer body... | 231 @defmac with-temp-buffer body... |
228 The @code{with-temp-buffer} macro evaluates the @var{body} forms | 232 The @code{with-temp-buffer} macro evaluates the @var{body} forms |
235 return the contents of the temporary buffer by using | 239 return the contents of the temporary buffer by using |
236 @code{(buffer-string)} as the last form. | 240 @code{(buffer-string)} as the last form. |
237 | 241 |
238 The current buffer is restored even in case of an abnormal exit via | 242 The current buffer is restored even in case of an abnormal exit via |
239 @code{throw} or error (@pxref{Nonlocal Exits}). | 243 @code{throw} or error (@pxref{Nonlocal Exits}). |
244 | |
245 See also @code{with-temp-file} in @ref{Definition of with-temp-file,, | |
246 Writing to Files}. | |
240 @end defmac | 247 @end defmac |
241 | |
242 See also @code{with-temp-file} in @ref{Writing to Files}. | |
243 | 248 |
244 @node Buffer Names | 249 @node Buffer Names |
245 @section Buffer Names | 250 @section Buffer Names |
246 @cindex buffer names | 251 @cindex buffer names |
247 | 252 |
291 @end example | 296 @end example |
292 @end defun | 297 @end defun |
293 | 298 |
294 @deffn Command rename-buffer newname &optional unique | 299 @deffn Command rename-buffer newname &optional unique |
295 This function renames the current buffer to @var{newname}. An error | 300 This function renames the current buffer to @var{newname}. An error |
296 is signaled if @var{newname} is not a string, or if there is already a | 301 is signaled if @var{newname} is not a string. |
297 buffer with that name. The function returns @var{newname}. | |
298 | 302 |
299 @c Emacs 19 feature | 303 @c Emacs 19 feature |
300 Ordinarily, @code{rename-buffer} signals an error if @var{newname} is | 304 Ordinarily, @code{rename-buffer} signals an error if @var{newname} is |
301 already in use. However, if @var{unique} is non-@code{nil}, it modifies | 305 already in use. However, if @var{unique} is non-@code{nil}, it modifies |
302 @var{newname} to make a name that is not in use. Interactively, you can | 306 @var{newname} to make a name that is not in use. Interactively, you can |
303 make @var{unique} non-@code{nil} with a numeric prefix argument. | 307 make @var{unique} non-@code{nil} with a numeric prefix argument. |
304 (This is how the command @code{rename-uniquely} is implemented.) | 308 (This is how the command @code{rename-uniquely} is implemented.) |
309 | |
310 This function returns the name actually given to the buffer. | |
305 @end deffn | 311 @end deffn |
306 | 312 |
307 @defun get-buffer buffer-or-name | 313 @defun get-buffer buffer-or-name |
308 This function returns the buffer specified by @var{buffer-or-name}. | 314 This function returns the buffer specified by @var{buffer-or-name}. |
309 If @var{buffer-or-name} is a string and there is no buffer with that | 315 If @var{buffer-or-name} is a string and there is no buffer with that |
328 | 334 |
329 See also the function @code{get-buffer-create} in @ref{Creating Buffers}. | 335 See also the function @code{get-buffer-create} in @ref{Creating Buffers}. |
330 @end defun | 336 @end defun |
331 | 337 |
332 @c Emacs 19 feature | 338 @c Emacs 19 feature |
333 @defun generate-new-buffer-name starting-name &rest ignore | 339 @defun generate-new-buffer-name starting-name &optional ignore |
334 This function returns a name that would be unique for a new buffer---but | 340 This function returns a name that would be unique for a new buffer---but |
335 does not create the buffer. It starts with @var{starting-name}, and | 341 does not create the buffer. It starts with @var{starting-name}, and |
336 produces a name not currently in use for any buffer by appending a | 342 produces a name not currently in use for any buffer by appending a |
337 number inside of @samp{<@dots{}>}. | 343 number inside of @samp{<@dots{}>}. It starts at 2 and keeps |
344 incrementing the number until it is not the name of an existing buffer. | |
338 | 345 |
339 If the optional second argument @var{ignore} is non-@code{nil}, it | 346 If the optional second argument @var{ignore} is non-@code{nil}, it |
340 should be a string; it makes a difference if it is a name in the | 347 should be a string; it makes a difference if it is a name in the |
341 sequence of names to be tried. That name will be considered acceptable, | 348 sequence of names to be tried. That name will be considered acceptable, |
342 if it is tried, even if a buffer with that name exists. Thus, if | 349 if it is tried, even if a buffer with that name exists. Thus, if |
402 are not strictly necessary, but others are essential to avoid confusing | 409 are not strictly necessary, but others are essential to avoid confusing |
403 Emacs. | 410 Emacs. |
404 @end defvar | 411 @end defvar |
405 | 412 |
406 @defvar buffer-file-truename | 413 @defvar buffer-file-truename |
407 This buffer-local variable holds the truename of the file visited in the | 414 This buffer-local variable holds the abbreviated truename of the file |
408 current buffer, or @code{nil} if no file is visited. It is a permanent | 415 visited in the current buffer, or @code{nil} if no file is visited. |
409 local, unaffected by @code{kill-all-local-variables}. @xref{Truenames}. | 416 It is a permanent local, unaffected by |
417 @code{kill-all-local-variables}. @xref{Truenames}, and | |
418 @ref{Definition of abbreviate-file-name}. | |
410 @end defvar | 419 @end defvar |
411 | 420 |
412 @defvar buffer-file-number | 421 @defvar buffer-file-number |
413 This buffer-local variable holds the file number and directory device | 422 This buffer-local variable holds the file number and directory device |
414 number of the file visited in the current buffer, or @code{nil} if no | 423 number of the file visited in the current buffer, or @code{nil} if no |
418 The value is normally a list of the form @code{(@var{filenum} | 427 The value is normally a list of the form @code{(@var{filenum} |
419 @var{devnum})}. This pair of numbers uniquely identifies the file among | 428 @var{devnum})}. This pair of numbers uniquely identifies the file among |
420 all files accessible on the system. See the function | 429 all files accessible on the system. See the function |
421 @code{file-attributes}, in @ref{File Attributes}, for more information | 430 @code{file-attributes}, in @ref{File Attributes}, for more information |
422 about them. | 431 about them. |
432 | |
433 If @code{buffer-file-name} is the name of a symbolic link, then both | |
434 numbers refer to the recursive target. | |
423 @end defvar | 435 @end defvar |
424 | 436 |
425 @defun get-file-buffer filename | 437 @defun get-file-buffer filename |
426 This function returns the buffer visiting file @var{filename}. If | 438 This function returns the buffer visiting file @var{filename}. If |
427 there is no such buffer, it returns @code{nil}. The argument | 439 there is no such buffer, it returns @code{nil}. The argument |
428 @var{filename}, which must be a string, is expanded (@pxref{File Name | 440 @var{filename}, which must be a string, is expanded (@pxref{File Name |
429 Expansion}), then compared against the visited file names of all live | 441 Expansion}), then compared against the visited file names of all live |
430 buffers. | 442 buffers. Note that the buffer's @code{buffer-file-name} must match |
443 the expansion of @var{filename} exactly. This function will not | |
444 recognize other names for the same file. | |
431 | 445 |
432 @example | 446 @example |
433 @group | 447 @group |
434 (get-file-buffer "buffers.texi") | 448 (get-file-buffer "buffers.texi") |
435 @result{} #<buffer buffers.texi> | 449 @result{} #<buffer buffers.texi> |
437 @end example | 451 @end example |
438 | 452 |
439 In unusual circumstances, there can be more than one buffer visiting | 453 In unusual circumstances, there can be more than one buffer visiting |
440 the same file name. In such cases, this function returns the first | 454 the same file name. In such cases, this function returns the first |
441 such buffer in the buffer list. | 455 such buffer in the buffer list. |
456 @end defun | |
457 | |
458 @defun find-buffer-visiting filename &optional predicate | |
459 This is like @code{get-file-buffer}, except that it can return any | |
460 buffer visiting the file @emph{possibly under a different name}. That | |
461 is, the buffer's @code{buffer-file-name} does not need to match the | |
462 expansion of @var{filename} exactly, it only needs to refer to the | |
463 same file. If @var{predicate} is non-@code{nil}, it should be a | |
464 function of one argument, a buffer visiting @var{filename}. The | |
465 buffer is only considered a suitable return value if @var{predicate} | |
466 returns non-@code{nil}. If it can not find a suitable buffer to | |
467 return, @code{find-buffer-visiting} returns @code{nil}. | |
442 @end defun | 468 @end defun |
443 | 469 |
444 @deffn Command set-visited-file-name filename &optional no-query along-with-file | 470 @deffn Command set-visited-file-name filename &optional no-query along-with-file |
445 If @var{filename} is a non-empty string, this function changes the | 471 If @var{filename} is a non-empty string, this function changes the |
446 name of the file visited in the current buffer to @var{filename}. (If the | 472 name of the file visited in the current buffer to @var{filename}. (If the |
453 correspond to the new file name, unless the new name is already in | 479 correspond to the new file name, unless the new name is already in |
454 use. | 480 use. |
455 | 481 |
456 If @var{filename} is @code{nil} or the empty string, that stands for | 482 If @var{filename} is @code{nil} or the empty string, that stands for |
457 ``no visited file''. In this case, @code{set-visited-file-name} marks | 483 ``no visited file''. In this case, @code{set-visited-file-name} marks |
458 the buffer as having no visited file. | 484 the buffer as having no visited file, without changing the buffer's |
459 | 485 modified flag. |
460 Normally, this function asks the user for confirmation if the specified | 486 |
461 file already exists. If @var{no-query} is non-@code{nil}, that prevents | 487 Normally, this function asks the user for confirmation if there |
462 asking this question. | 488 already is a buffer visiting @var{filename}. If @var{no-query} is |
463 | 489 non-@code{nil}, that prevents asking this question. If there already |
464 If @var{along-with-file} is non-@code{nil}, that means to assume that the | 490 is a buffer visiting @var{filename}, and the user confirms or |
465 former visited file has been renamed to @var{filename}. | 491 @var{query} is non-@code{nil}, this function makes the new buffer name |
492 unique by appending a number inside of @samp{<@dots{}>} to @var{filename}. | |
493 | |
494 If @var{along-with-file} is non-@code{nil}, that means to assume that | |
495 the former visited file has been renamed to @var{filename}. In this | |
496 case, the command does not change the buffer's modified flag, nor the | |
497 buffer's recorded last file modification time as reported by | |
498 @code{visited-file-modtime} (@pxref{Modification Time}). If | |
499 @var{along-with-file} is @code{nil}, this function clears the recorded | |
500 last file modification time, after which @code{visited-file-modtime} | |
501 returns zero. | |
466 | 502 |
467 @c Wordy to avoid overfull hbox. --rjc 16mar92 | 503 @c Wordy to avoid overfull hbox. --rjc 16mar92 |
468 When the function @code{set-visited-file-name} is called interactively, it | 504 When the function @code{set-visited-file-name} is called interactively, it |
469 prompts for @var{filename} in the minibuffer. | 505 prompts for @var{filename} in the minibuffer. |
470 @end deffn | 506 @end deffn |
521 @defun restore-buffer-modified-p flag | 557 @defun restore-buffer-modified-p flag |
522 Like @code{set-buffer-modified-p}, but does not force redisplay | 558 Like @code{set-buffer-modified-p}, but does not force redisplay |
523 of mode lines. | 559 of mode lines. |
524 @end defun | 560 @end defun |
525 | 561 |
526 @deffn Command not-modified | 562 @deffn Command not-modified &optional arg |
527 This command marks the current buffer as unmodified, and not needing to | 563 This command marks the current buffer as unmodified, and not needing |
528 be saved. With prefix arg, it marks the buffer as modified, so that it | 564 to be saved. If @var{arg} is non-@code{nil}, it marks the buffer as |
529 will be saved at the next suitable occasion. | 565 modified, so that it will be saved at the next suitable occasion. |
566 Interactively, @var{arg} is the prefix argument. | |
530 | 567 |
531 Don't use this function in programs, since it prints a message in the | 568 Don't use this function in programs, since it prints a message in the |
532 echo area; use @code{set-buffer-modified-p} (above) instead. | 569 echo area; use @code{set-buffer-modified-p} (above) instead. |
533 @end deffn | 570 @end deffn |
534 | 571 |
535 @c Emacs 19 feature | 572 @c Emacs 19 feature |
536 @defun buffer-modified-tick &optional buffer | 573 @defun buffer-modified-tick &optional buffer |
537 This function returns @var{buffer}'s modification-count. This is a | 574 This function returns @var{buffer}'s modification-count. This is a |
538 counter that increments every time the buffer is modified. If | 575 counter that increments every time the buffer is modified. If |
539 @var{buffer} is @code{nil} (or omitted), the current buffer is used. | 576 @var{buffer} is @code{nil} (or omitted), the current buffer is used. |
577 The counter can wrap around occasionally. | |
540 @end defun | 578 @end defun |
541 | 579 |
542 @node Modification Time | 580 @node Modification Time |
543 @comment node-name, next, previous, up | 581 @comment node-name, next, previous, up |
544 @section Comparison of Modification Time | 582 @section Comparison of Modification Time |
559 the same unless some other process has written the file since Emacs | 597 the same unless some other process has written the file since Emacs |
560 visited or saved it. | 598 visited or saved it. |
561 | 599 |
562 The function returns @code{t} if the last actual modification time and | 600 The function returns @code{t} if the last actual modification time and |
563 Emacs's recorded modification time are the same, @code{nil} otherwise. | 601 Emacs's recorded modification time are the same, @code{nil} otherwise. |
602 It also returns @code{t} if the buffer has no recorded last | |
603 modification time, that is if @code{visited-file-modtime} would return | |
604 zero. | |
605 | |
606 It always returns @code{t} for buffers that are not visiting a file, | |
607 even if @code{visited-file-modtime} returns a non-zero value. For | |
608 instance, it always returns @code{t} for dired buffers. It returns | |
609 @code{t} for buffers that are visiting a file that does not exist and | |
610 never existed, but @code{nil} for file-visiting buffers whose file has | |
611 been deleted. | |
564 @end defun | 612 @end defun |
565 | 613 |
566 @defun clear-visited-file-modtime | 614 @defun clear-visited-file-modtime |
567 This function clears out the record of the last modification time of | 615 This function clears out the record of the last modification time of |
568 the file being visited by the current buffer. As a result, the next | 616 the file being visited by the current buffer. As a result, the next |
574 file should not be done. | 622 file should not be done. |
575 @end defun | 623 @end defun |
576 | 624 |
577 @c Emacs 19 feature | 625 @c Emacs 19 feature |
578 @defun visited-file-modtime | 626 @defun visited-file-modtime |
579 This function returns the buffer's recorded last file modification time, | 627 This function returns the current buffer's recorded last file |
580 as a list of the form @code{(@var{high} . @var{low})}. (This is the | 628 modification time, as a list of the form @code{(@var{high} . |
581 same format that @code{file-attributes} uses to return time values; see | 629 @var{low})}. (This is the same format that @code{file-attributes} |
582 @ref{File Attributes}.) | 630 uses to return time values; see @ref{File Attributes}.) |
631 | |
632 The function returns zero if the buffer has no recorded last | |
633 modification time, which can happen, for instance, if the record has | |
634 been explicitly cleared by @code{clear-visited-file-modtime} or if the | |
635 buffer is not visiting a file. Note, however, that | |
636 @code{visited-file-modtime} can return a non-zero value for some | |
637 buffers that are not visiting files, but are nevertheless closely | |
638 associated with a file. This happens, for instance, with dired | |
639 buffers listing a directory. For such buffers, | |
640 @code{visited-file-modtime} returns the last modification time of that | |
641 directory, as recorded by dired. | |
642 | |
643 For a new buffer visiting a not yet existing file, @var{high} is | |
644 @minus{}1 and @var{low} is 65535, that is, | |
645 @ifnottex | |
646 @w{2**16 - 1.} | |
647 @end ifnottex | |
648 @tex | |
649 @math{2^{16}-1}. | |
650 @end tex | |
583 @end defun | 651 @end defun |
584 | 652 |
585 @c Emacs 19 feature | 653 @c Emacs 19 feature |
586 @defun set-visited-file-modtime &optional time | 654 @defun set-visited-file-modtime &optional time |
587 This function updates the buffer's record of the last modification time | 655 This function updates the buffer's record of the last modification time |
588 of the visited file, to the value specified by @var{time} if @var{time} | 656 of the visited file, to the value specified by @var{time} if @var{time} |
589 is not @code{nil}, and otherwise to the last modification time of the | 657 is not @code{nil}, and otherwise to the last modification time of the |
590 visited file. | 658 visited file. |
591 | 659 |
592 If @var{time} is not @code{nil}, it should have the form | 660 If @var{time} is neither @code{nil} nor zero, it should have the form |
593 @code{(@var{high} . @var{low})} or @code{(@var{high} @var{low})}, in | 661 @code{(@var{high} . @var{low})} or @code{(@var{high} @var{low})}, in |
594 either case containing two integers, each of which holds 16 bits of the | 662 either case containing two integers, each of which holds 16 bits of the |
595 time. | 663 time. |
596 | 664 |
597 This function is useful if the buffer was not read from the file | 665 This function is useful if the buffer was not read from the file |
653 This buffer-local variable specifies whether the buffer is read-only. | 721 This buffer-local variable specifies whether the buffer is read-only. |
654 The buffer is read-only if this variable is non-@code{nil}. | 722 The buffer is read-only if this variable is non-@code{nil}. |
655 @end defvar | 723 @end defvar |
656 | 724 |
657 @defvar inhibit-read-only | 725 @defvar inhibit-read-only |
658 If this variable is non-@code{nil}, then read-only buffers and read-only | 726 If this variable is non-@code{nil}, then read-only buffers and, |
659 characters may be modified. Read-only characters in a buffer are those | 727 depending on the actual value, some or all read-only characters may be |
660 that have non-@code{nil} @code{read-only} properties (either text | 728 modified. Read-only characters in a buffer are those that have |
661 properties or overlay properties). @xref{Special Properties}, for more | 729 non-@code{nil} @code{read-only} properties (either text properties or |
662 information about text properties. @xref{Overlays}, for more | 730 overlay properties). @xref{Special Properties}, for more information |
663 information about overlays and their properties. | 731 about text properties. @xref{Overlays}, for more information about |
732 overlays and their properties. | |
664 | 733 |
665 If @code{inhibit-read-only} is @code{t}, all @code{read-only} character | 734 If @code{inhibit-read-only} is @code{t}, all @code{read-only} character |
666 properties have no effect. If @code{inhibit-read-only} is a list, then | 735 properties have no effect. If @code{inhibit-read-only} is a list, then |
667 @code{read-only} character properties have no effect if they are members | 736 @code{read-only} character properties have no effect if they are members |
668 of the list (comparison is done with @code{eq}). | 737 of the list (comparison is done with @code{eq}). |
814 @code{with-output-to-temp-buffer} (@pxref{Temporary Displays}) and | 883 @code{with-output-to-temp-buffer} (@pxref{Temporary Displays}) and |
815 @code{create-file-buffer} (@pxref{Visiting Files}). Starting a | 884 @code{create-file-buffer} (@pxref{Visiting Files}). Starting a |
816 subprocess can also create a buffer (@pxref{Processes}). | 885 subprocess can also create a buffer (@pxref{Processes}). |
817 | 886 |
818 @defun get-buffer-create name | 887 @defun get-buffer-create name |
819 This function returns a buffer named @var{name}. It returns an existing | 888 This function returns a buffer named @var{name}. It returns a live |
820 buffer with that name, if one exists; otherwise, it creates a new | 889 buffer with that name, if one exists; otherwise, it creates a new |
821 buffer. The buffer does not become the current buffer---this function | 890 buffer. The buffer does not become the current buffer---this function |
822 does not change which buffer is current. | 891 does not change which buffer is current. |
823 | 892 |
824 An error is signaled if @var{name} is not a string. | 893 If @var{name} is a buffer instead of a string, it is returned, even if |
894 it is dead. An error is signaled if @var{name} is neither a string | |
895 nor a buffer. | |
825 | 896 |
826 @example | 897 @example |
827 @group | 898 @group |
828 (get-buffer-create "foo") | 899 (get-buffer-create "foo") |
829 @result{} #<buffer foo> | 900 @result{} #<buffer foo> |
830 @end group | 901 @end group |
831 @end example | 902 @end example |
832 | 903 |
833 The major mode for the new buffer is set to Fundamental mode. The | 904 The major mode for a newly created buffer is set to Fundamental mode. |
834 variable @code{default-major-mode} is handled at a higher level. | 905 The variable @code{default-major-mode} is handled at a higher level. |
835 @xref{Auto Major Mode}. | 906 @xref{Auto Major Mode}. |
836 @end defun | 907 @end defun |
837 | 908 |
838 @defun generate-new-buffer name | 909 @defun generate-new-buffer name |
839 This function returns a newly created, empty buffer, but does not make | 910 This function returns a newly created, empty buffer, but does not make |
903 @end group | 974 @end group |
904 @end example | 975 @end example |
905 | 976 |
906 @deffn Command kill-buffer buffer-or-name | 977 @deffn Command kill-buffer buffer-or-name |
907 This function kills the buffer @var{buffer-or-name}, freeing all its | 978 This function kills the buffer @var{buffer-or-name}, freeing all its |
908 memory for other uses or to be returned to the operating system. It | 979 memory for other uses or to be returned to the operating system. If |
909 returns @code{nil}. | 980 @var{buffer-or-name} is @code{nil}, it kills the current buffer. |
910 | 981 |
911 Any processes that have this buffer as the @code{process-buffer} are | 982 Any processes that have this buffer as the @code{process-buffer} are |
912 sent the @code{SIGHUP} signal, which normally causes them to terminate. | 983 sent the @code{SIGHUP} signal, which normally causes them to terminate. |
913 (The basic meaning of @code{SIGHUP} is that a dialup line has been | 984 (The basic meaning of @code{SIGHUP} is that a dialup line has been |
914 disconnected.) @xref{Signals to Processes}. | 985 disconnected.) @xref{Signals to Processes}. |
919 for confirmation, clear the modified flag before calling | 990 for confirmation, clear the modified flag before calling |
920 @code{kill-buffer}. @xref{Buffer Modification}. | 991 @code{kill-buffer}. @xref{Buffer Modification}. |
921 | 992 |
922 Killing a buffer that is already dead has no effect. | 993 Killing a buffer that is already dead has no effect. |
923 | 994 |
995 This function returns @code{t} if it actually killed the buffer. It | |
996 returns @code{nil} if the user refuses to confirm or if | |
997 @var{buffer-or-name} was already dead. | |
998 | |
924 @smallexample | 999 @smallexample |
925 (kill-buffer "foo.unchanged") | 1000 (kill-buffer "foo.unchanged") |
926 @result{} nil | 1001 @result{} t |
927 (kill-buffer "foo.changed") | 1002 (kill-buffer "foo.changed") |
928 | 1003 |
929 ---------- Buffer: Minibuffer ---------- | 1004 ---------- Buffer: Minibuffer ---------- |
930 Buffer foo.changed modified; kill anyway? (yes or no) @kbd{yes} | 1005 Buffer foo.changed modified; kill anyway? (yes or no) @kbd{yes} |
931 ---------- Buffer: Minibuffer ---------- | 1006 ---------- Buffer: Minibuffer ---------- |
932 | 1007 |
933 @result{} nil | 1008 @result{} t |
934 @end smallexample | 1009 @end smallexample |
935 @end deffn | 1010 @end deffn |
936 | 1011 |
937 @defvar kill-buffer-query-functions | 1012 @defvar kill-buffer-query-functions |
938 After confirming unsaved changes, @code{kill-buffer} calls the functions | 1013 After confirming unsaved changes, @code{kill-buffer} calls the functions |
951 is not cleared by changing major modes. | 1026 is not cleared by changing major modes. |
952 @end defvar | 1027 @end defvar |
953 | 1028 |
954 @defvar buffer-offer-save | 1029 @defvar buffer-offer-save |
955 This variable, if non-@code{nil} in a particular buffer, tells | 1030 This variable, if non-@code{nil} in a particular buffer, tells |
956 @code{save-buffers-kill-emacs} and @code{save-some-buffers} to offer to | 1031 @code{save-buffers-kill-emacs} and @code{save-some-buffers} (if the |
957 save that buffer, just as they offer to save file-visiting buffers. The | 1032 second optional argument to that function is @code{t}) to offer to |
958 variable @code{buffer-offer-save} automatically becomes buffer-local | 1033 save that buffer, just as they offer to save file-visiting buffers. |
959 when set for any reason. @xref{Buffer-Local Variables}. | 1034 @xref{Definition of save-some-buffers}. The variable |
1035 @code{buffer-offer-save} automatically becomes buffer-local when set | |
1036 for any reason. @xref{Buffer-Local Variables}. | |
960 @end defvar | 1037 @end defvar |
961 | 1038 |
962 @defun buffer-live-p buffer | 1039 @defun buffer-live-p object |
963 This function returns @code{t} if @var{object} is a buffer which has | 1040 This function returns @code{t} if @var{object} is a buffer which has |
964 not been killed, @code{nil} otherwise. | 1041 not been killed, @code{nil} otherwise. |
965 @end defun | 1042 @end defun |
966 | 1043 |
967 @node Indirect Buffers | 1044 @node Indirect Buffers |
992 | 1069 |
993 Killing an indirect buffer has no effect on its base buffer. Killing | 1070 Killing an indirect buffer has no effect on its base buffer. Killing |
994 the base buffer effectively kills the indirect buffer in that it cannot | 1071 the base buffer effectively kills the indirect buffer in that it cannot |
995 ever again be the current buffer. | 1072 ever again be the current buffer. |
996 | 1073 |
997 @deffn Command make-indirect-buffer base-buffer name | 1074 @deffn Command make-indirect-buffer base-buffer name &optional clone |
998 This creates an indirect buffer named @var{name} whose base buffer | 1075 This creates and returns an indirect buffer named @var{name} whose |
999 is @var{base-buffer}. The argument @var{base-buffer} may be a buffer | 1076 base buffer is @var{base-buffer}. The argument @var{base-buffer} may |
1000 or a string. | 1077 be a live buffer or the name (a string) of an existing buffer. If |
1078 @var{name} is the name of an existing buffer, an error is signaled. | |
1079 | |
1080 If @var{clone} is non-@code{nil}, then the indirect buffer originally | |
1081 shares the ``state'' of @var{base-buffer} such as major mode, minor | |
1082 modes, buffer local variables and so on. If @var{clone} is omitted | |
1083 or @code{nil} the indirect buffer's state is set to the default state | |
1084 for new buffers. | |
1001 | 1085 |
1002 If @var{base-buffer} is an indirect buffer, its base buffer is used as | 1086 If @var{base-buffer} is an indirect buffer, its base buffer is used as |
1003 the base for the new buffer. | 1087 the base for the new buffer. If, in addition, @var{clone} is |
1088 non-@code{nil}, the initial state is copied from the actual base | |
1089 buffer, not from @var{base-buffer}. | |
1004 @end deffn | 1090 @end deffn |
1005 | 1091 |
1006 @defun buffer-base-buffer buffer | 1092 @defun buffer-base-buffer &optional buffer |
1007 This function returns the base buffer of @var{buffer}. If @var{buffer} | 1093 This function returns the base buffer of @var{buffer}, which defaults |
1008 is not indirect, the value is @code{nil}. Otherwise, the value is | 1094 to the current buffer. If @var{buffer} is not indirect, the value is |
1009 another buffer, which is never an indirect buffer. | 1095 @code{nil}. Otherwise, the value is another buffer, which is never an |
1096 indirect buffer. | |
1010 @end defun | 1097 @end defun |
1011 | 1098 |
1012 @node Buffer Gap | 1099 @node Buffer Gap |
1013 @section The Buffer Gap | 1100 @section The Buffer Gap |
1014 | 1101 |