aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2004-04-14 02:48:08 +0000
committerLuc Teirlinck2004-04-14 02:48:08 +0000
commit619fb950d62377bf562f597ff81264d3386cc502 (patch)
tree504e37e03898c8d5c552f6f452ac3d1dbf0e5484
parent19efcb46346e5eb24211348c6b04bc89f68ed74a (diff)
downloademacs-619fb950d62377bf562f597ff81264d3386cc502.tar.gz
emacs-619fb950d62377bf562f597ff81264d3386cc502.zip
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'.
-rw-r--r--lispref/ChangeLog17
-rw-r--r--lispref/buffers.texi207
2 files changed, 164 insertions, 60 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index aa20df10307..47a987fdb75 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,20 @@
12004-04-13 Luc Teirlinck <teirllm@auburn.edu>
2
3 * buffers.texi: Various changes in addition to:
4 (Buffer File Name): Add `find-buffer-visiting'.
5 (Buffer Modification): Mention optional ARG to `not-modified'.
6 (Indirect Buffers): Mention optional CLONE argument to
7 `make-indirect-buffer'.
8
9 * files.texi: Various changes in addition to:
10 (Visiting Functions): `find-file-hook' is now a normal hook.
11 (File Name Expansion): Explain difference between the way that
12 `expand-file-name' and `file-truename' treat `..'.
13 (Contents of Directories): Mention optional ID-FORMAT argument to
14 `directory-files-and-attributes'.
15 (Format Conversion): Mention new optional CONFIRM argument to
16 `format-write-file'.
17
12004-04-12 Miles Bader <miles@gnu.org> 182004-04-12 Miles Bader <miles@gnu.org>
2 19
3 * macros.texi (Expansion): Add description of `macroexpand-all'. 20 * macros.texi (Expansion): Add description of `macroexpand-all'.
diff --git a/lispref/buffers.texi b/lispref/buffers.texi
index 4ca375a5c26..0eee01d980d 100644
--- a/lispref/buffers.texi
+++ b/lispref/buffers.texi
@@ -215,12 +215,16 @@ of course. Instead, whichever buffer was current just before exit
215remains current. 215remains 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...
219The @code{with-current-buffer} macro saves the identity of the current 219The @code{with-current-buffer} macro saves the identity of the current
220buffer, makes @var{buffer} current, evaluates the @var{body} forms, and 220buffer, makes @var{buffer-or-name} current, evaluates the @var{body}
221finally restores the buffer. The return value is the value of the last 221forms, and finally restores the buffer. The return value is the value
222form in @var{body}. The current buffer is restored even in case of an 222of the last form in @var{body}. The current buffer is restored even
223abnormal exit via @code{throw} or error (@pxref{Nonlocal Exits}). 223in case of an abnormal exit via @code{throw} or error (@pxref{Nonlocal
224Exits}).
225
226An error is signaled if @var{buffer-or-name} does not identify an
227existing buffer.
224@end defmac 228@end defmac
225 229
226@anchor{Definition of with-temp-buffer} 230@anchor{Definition of with-temp-buffer}
@@ -237,9 +241,10 @@ return the contents of the temporary buffer by using
237 241
238The current buffer is restored even in case of an abnormal exit via 242The 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}).
240@end defmac
241 244
242See also @code{with-temp-file} in @ref{Writing to Files}. 245See also @code{with-temp-file} in @ref{Definition of with-temp-file,,
246Writing to Files}.
247@end defmac
243 248
244@node Buffer Names 249@node Buffer Names
245@section Buffer Names 250@section Buffer Names
@@ -293,8 +298,7 @@ foo
293 298
294@deffn Command rename-buffer newname &optional unique 299@deffn Command rename-buffer newname &optional unique
295This function renames the current buffer to @var{newname}. An error 300This function renames the current buffer to @var{newname}. An error
296is signaled if @var{newname} is not a string, or if there is already a 301is signaled if @var{newname} is not a string.
297buffer with that name. The function returns @var{newname}.
298 302
299@c Emacs 19 feature 303@c Emacs 19 feature
300Ordinarily, @code{rename-buffer} signals an error if @var{newname} is 304Ordinarily, @code{rename-buffer} signals an error if @var{newname} is
@@ -302,6 +306,8 @@ 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
303make @var{unique} non-@code{nil} with a numeric prefix argument. 307make @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
310This 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
@@ -330,11 +336,12 @@ 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
334This function returns a name that would be unique for a new buffer---but 340This function returns a name that would be unique for a new buffer---but
335does not create the buffer. It starts with @var{starting-name}, and 341does not create the buffer. It starts with @var{starting-name}, and
336produces a name not currently in use for any buffer by appending a 342produces a name not currently in use for any buffer by appending a
337number inside of @samp{<@dots{}>}. 343number inside of @samp{<@dots{}>}. It starts at 2 and keeps
344incrementing the number until it is not the name of an existing buffer.
338 345
339If the optional second argument @var{ignore} is non-@code{nil}, it 346If the optional second argument @var{ignore} is non-@code{nil}, it
340should be a string; it makes a difference if it is a name in the 347should be a string; it makes a difference if it is a name in the
@@ -404,9 +411,11 @@ Emacs.
404@end defvar 411@end defvar
405 412
406@defvar buffer-file-truename 413@defvar buffer-file-truename
407This buffer-local variable holds the truename of the file visited in the 414This buffer-local variable holds the abbreviated truename of the file
408current buffer, or @code{nil} if no file is visited. It is a permanent 415visited in the current buffer, or @code{nil} if no file is visited.
409local, unaffected by @code{kill-all-local-variables}. @xref{Truenames}. 416It 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
@@ -420,6 +429,9 @@ The value is normally a list of the form @code{(@var{filenum}
420all files accessible on the system. See the function 429all 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
422about them. 431about them.
432
433If @code{buffer-file-name} is the name of a symbolic link, then both
434numbers 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
@@ -427,7 +439,9 @@ This function returns the buffer visiting file @var{filename}. If
427there is no such buffer, it returns @code{nil}. The argument 439there 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
429Expansion}), then compared against the visited file names of all live 441Expansion}), then compared against the visited file names of all live
430buffers. 442buffers. Note that the buffer's @code{buffer-file-name} must match
443the expansion of @var{filename} exactly. This function will not
444recognize other names for the same file.
431 445
432@example 446@example
433@group 447@group
@@ -441,6 +455,18 @@ the same file name. In such cases, this function returns the first
441such buffer in the buffer list. 455such buffer in the buffer list.
442@end defun 456@end defun
443 457
458@defun find-buffer-visiting filename &optional predicate
459This is like @code{get-file-buffer}, except that it can return any
460buffer visiting the file @emph{possibly under a different name}. That
461is, the buffer's @code{buffer-file-name} does not need to match the
462expansion of @var{filename} exactly, it only needs to refer to the
463same file. If @var{predicate} is non-@code{nil}, it should be a
464function of one argument, a buffer visiting @var{filename}. The
465buffer is only considered a suitable return value if @var{predicate}
466returns non-@code{nil}. If it can not find a suitable buffer to
467return, @code{find-buffer-visiting} returns @code{nil}.
468@end defun
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
445If @var{filename} is a non-empty string, this function changes the 471If @var{filename} is a non-empty string, this function changes the
446name of the file visited in the current buffer to @var{filename}. (If the 472name of the file visited in the current buffer to @var{filename}. (If the
@@ -455,14 +481,24 @@ use.
455 481
456If @var{filename} is @code{nil} or the empty string, that stands for 482If @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
458the buffer as having no visited file. 484the buffer as having no visited file, without changing the buffer's
459 485modified flag.
460Normally, this function asks the user for confirmation if the specified 486
461file already exists. If @var{no-query} is non-@code{nil}, that prevents 487Normally, this function asks the user for confirmation if there
462asking this question. 488already is a buffer visiting @var{filename}. If @var{no-query} is
463 489non-@code{nil}, that prevents asking this question. If there already
464If @var{along-with-file} is non-@code{nil}, that means to assume that the 490is a buffer visiting @var{filename}, and the user confirms or
465former visited file has been renamed to @var{filename}. 491@var{query} is non-@code{nil}, this function makes the new buffer name
492unique by appending a number inside of @samp{<@dots{}>} to @var{filename}.
493
494If @var{along-with-file} is non-@code{nil}, that means to assume that
495the former visited file has been renamed to @var{filename}. In this
496case, the command does not change the buffer's modified flag, nor the
497buffer'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
500last file modification time, after which @code{visited-file-modtime}
501returns zero.
466 502
467@c Wordy to avoid overfull hbox. --rjc 16mar92 503@c Wordy to avoid overfull hbox. --rjc 16mar92
468When the function @code{set-visited-file-name} is called interactively, it 504When the function @code{set-visited-file-name} is called interactively, it
@@ -523,10 +559,11 @@ Like @code{set-buffer-modified-p}, but does not force redisplay
523of mode lines. 559of mode lines.
524@end defun 560@end defun
525 561
526@deffn Command not-modified 562@deffn Command not-modified &optional arg
527This command marks the current buffer as unmodified, and not needing to 563This command marks the current buffer as unmodified, and not needing
528be saved. With prefix arg, it marks the buffer as modified, so that it 564to be saved. If @var{arg} is non-@code{nil}, it marks the buffer as
529will be saved at the next suitable occasion. 565modified, so that it will be saved at the next suitable occasion.
566Interactively, @var{arg} is the prefix argument.
530 567
531Don't use this function in programs, since it prints a message in the 568Don't use this function in programs, since it prints a message in the
532echo area; use @code{set-buffer-modified-p} (above) instead. 569echo area; use @code{set-buffer-modified-p} (above) instead.
@@ -537,6 +574,7 @@ echo area; use @code{set-buffer-modified-p} (above) instead.
537This function returns @var{buffer}'s modification-count. This is a 574This function returns @var{buffer}'s modification-count. This is a
538counter that increments every time the buffer is modified. If 575counter 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.
577The counter can wrap around occasionally.
540@end defun 578@end defun
541 579
542@node Modification Time 580@node Modification Time
@@ -561,6 +599,16 @@ visited or saved it.
561 599
562The function returns @code{t} if the last actual modification time and 600The function returns @code{t} if the last actual modification time and
563Emacs's recorded modification time are the same, @code{nil} otherwise. 601Emacs's recorded modification time are the same, @code{nil} otherwise.
602It also returns @code{t} if the buffer has no recorded last
603modification time, that is if @code{visited-file-modtime} would return
604zero.
605
606It always returns @code{t} for buffers that are not visiting a file,
607even if @code{visited-file-modtime} returns a non-zero value. For
608instance, 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
610never existed, but @code{nil} for file-visiting buffers whose file has
611been deleted.
564@end defun 612@end defun
565 613
566@defun clear-visited-file-modtime 614@defun clear-visited-file-modtime
@@ -576,10 +624,30 @@ file should not be done.
576 624
577@c Emacs 19 feature 625@c Emacs 19 feature
578@defun visited-file-modtime 626@defun visited-file-modtime
579This function returns the buffer's recorded last file modification time, 627This function returns the current buffer's recorded last file
580as a list of the form @code{(@var{high} . @var{low})}. (This is the 628modification time, as a list of the form @code{(@var{high} .
581same 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}.) 630uses to return time values; see @ref{File Attributes}.)
631
632The function returns zero if the buffer has no recorded last
633modification time, which can happen, for instance, if the record has
634been explicitly cleared by @code{clear-visited-file-modtime} or if the
635buffer is not visiting a file. Note, however, that
636@code{visited-file-modtime} can return a non-zero value for some
637buffers that are not visiting files, but are nevertheless closely
638associated with a file. This happens, for instance, with dired
639buffers listing a directory. For such buffers,
640@code{visited-file-modtime} returns the last modification time of that
641directory, as recorded by dired.
642
643For 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
@@ -589,7 +657,7 @@ of the visited file, to the value specified by @var{time} if @var{time}
589is not @code{nil}, and otherwise to the last modification time of the 657is not @code{nil}, and otherwise to the last modification time of the
590visited file. 658visited file.
591 659
592If @var{time} is not @code{nil}, it should have the form 660If @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
594either case containing two integers, each of which holds 16 bits of the 662either case containing two integers, each of which holds 16 bits of the
595time. 663time.
@@ -655,12 +723,13 @@ 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
658If this variable is non-@code{nil}, then read-only buffers and read-only 726If this variable is non-@code{nil}, then read-only buffers and,
659characters may be modified. Read-only characters in a buffer are those 727depending on the actual value, some or all read-only characters may be
660that have non-@code{nil} @code{read-only} properties (either text 728modified. Read-only characters in a buffer are those that have
661properties or overlay properties). @xref{Special Properties}, for more 729non-@code{nil} @code{read-only} properties (either text properties or
662information about text properties. @xref{Overlays}, for more 730overlay properties). @xref{Special Properties}, for more information
663information about overlays and their properties. 731about text properties. @xref{Overlays}, for more information about
732overlays and their properties.
664 733
665If @code{inhibit-read-only} is @code{t}, all @code{read-only} character 734If @code{inhibit-read-only} is @code{t}, all @code{read-only} character
666properties have no effect. If @code{inhibit-read-only} is a list, then 735properties have no effect. If @code{inhibit-read-only} is a list, then
@@ -816,12 +885,14 @@ buffer and gives it a unique name.
816subprocess can also create a buffer (@pxref{Processes}). 885subprocess can also create a buffer (@pxref{Processes}).
817 886
818@defun get-buffer-create name 887@defun get-buffer-create name
819This function returns a buffer named @var{name}. It returns an existing 888This function returns a buffer named @var{name}. It returns a live
820buffer with that name, if one exists; otherwise, it creates a new 889buffer with that name, if one exists; otherwise, it creates a new
821buffer. The buffer does not become the current buffer---this function 890buffer. The buffer does not become the current buffer---this function
822does not change which buffer is current. 891does not change which buffer is current.
823 892
824An error is signaled if @var{name} is not a string. 893If @var{name} is a buffer instead of a string, it is returned, even if
894it is dead. An error is signaled if @var{name} is neither a string
895nor a buffer.
825 896
826@example 897@example
827@group 898@group
@@ -830,8 +901,8 @@ An error is signaled if @var{name} is not a string.
830@end group 901@end group
831@end example 902@end example
832 903
833The major mode for the new buffer is set to Fundamental mode. The 904The major mode for a newly created buffer is set to Fundamental mode.
834variable @code{default-major-mode} is handled at a higher level. 905The 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
@@ -905,8 +976,8 @@ this feature to test whether a buffer has been killed:
905 976
906@deffn Command kill-buffer buffer-or-name 977@deffn Command kill-buffer buffer-or-name
907This function kills the buffer @var{buffer-or-name}, freeing all its 978This function kills the buffer @var{buffer-or-name}, freeing all its
908memory for other uses or to be returned to the operating system. It 979memory for other uses or to be returned to the operating system. If
909returns @code{nil}. 980@var{buffer-or-name} is @code{nil}, it kills the current buffer.
910 981
911Any processes that have this buffer as the @code{process-buffer} are 982Any processes that have this buffer as the @code{process-buffer} are
912sent the @code{SIGHUP} signal, which normally causes them to terminate. 983sent the @code{SIGHUP} signal, which normally causes them to terminate.
@@ -921,16 +992,20 @@ for confirmation, clear the modified flag before calling
921 992
922Killing a buffer that is already dead has no effect. 993Killing a buffer that is already dead has no effect.
923 994
995This function returns @code{t} if it actually killed the buffer. It
996returns @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 ----------
930Buffer foo.changed modified; kill anyway? (yes or no) @kbd{yes} 1005Buffer 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
@@ -953,13 +1028,15 @@ is not cleared by changing major modes.
953 1028
954@defvar buffer-offer-save 1029@defvar buffer-offer-save
955This variable, if non-@code{nil} in a particular buffer, tells 1030This 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
957save that buffer, just as they offer to save file-visiting buffers. The 1032second optional argument to that function is @code{t}) to offer to
958variable @code{buffer-offer-save} automatically becomes buffer-local 1033save that buffer, just as they offer to save file-visiting buffers.
959when 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
1036for 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
963This function returns @code{t} if @var{object} is a buffer which has 1040This function returns @code{t} if @var{object} is a buffer which has
964not been killed, @code{nil} otherwise. 1041not been killed, @code{nil} otherwise.
965@end defun 1042@end defun
@@ -994,19 +1071,29 @@ buffer.
994the base buffer effectively kills the indirect buffer in that it cannot 1071the base buffer effectively kills the indirect buffer in that it cannot
995ever again be the current buffer. 1072ever 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
998This creates an indirect buffer named @var{name} whose base buffer 1075This creates and returns an indirect buffer named @var{name} whose
999is @var{base-buffer}. The argument @var{base-buffer} may be a buffer 1076base buffer is @var{base-buffer}. The argument @var{base-buffer} may
1000or a string. 1077be 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
1080If @var{clone} is non-@code{nil}, then the indirect buffer originally
1081shares the ``state'' of @var{base-buffer} such as major mode, minor
1082modes, buffer local variables and so on. If @var{clone} is omitted
1083or @code{nil} the indirect buffer's state is set to the default state
1084for new buffers.
1001 1085
1002If @var{base-buffer} is an indirect buffer, its base buffer is used as 1086If @var{base-buffer} is an indirect buffer, its base buffer is used as
1003the base for the new buffer. 1087the base for the new buffer. If, in addition, @var{clone} is
1088non-@code{nil}, the initial state is copied from the actual base
1089buffer, 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
1007This function returns the base buffer of @var{buffer}. If @var{buffer} 1093This function returns the base buffer of @var{buffer}, which defaults
1008is not indirect, the value is @code{nil}. Otherwise, the value is 1094to the current buffer. If @var{buffer} is not indirect, the value is
1009another buffer, which is never an indirect buffer. 1095@code{nil}. Otherwise, the value is another buffer, which is never an
1096indirect buffer.
1010@end defun 1097@end defun
1011 1098
1012@node Buffer Gap 1099@node Buffer Gap