aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-02-27 15:26:13 +0800
committerChong Yidong2012-02-27 15:26:13 +0800
commit431ee44bbe15fa0b5d67cfb70df29e5d45039850 (patch)
tree45c2df8c33bafc0f79019f4792fe5897ff954566
parent9c62cd0479bdd7ab1bb2849cc44e705d274c401c (diff)
downloademacs-431ee44bbe15fa0b5d67cfb70df29e5d45039850.tar.gz
emacs-431ee44bbe15fa0b5d67cfb70df29e5d45039850.zip
More updates for Buffers and Files chapters of Lisp manual.
* doc/emacs/buffers.texi (Creating Buffers): Clarify that generate-new-buffer uses generate-new-buffer-names. (Killing Buffers): Remove bogus example duplicating buffer-live-p. * doc/emacs/files.texi (Directory Names): Index entry for file name abbreviations. (Relative File Names, File Name Expansion): Refer to it. (Locating Files): Move locate-user-emacs-file documentation to Standard File Names. (Standard File Names): Add locate-user-emacs-file; update examples.
-rw-r--r--admin/FOR-RELEASE2
-rw-r--r--doc/lispref/ChangeLog12
-rw-r--r--doc/lispref/buffers.texi61
-rw-r--r--doc/lispref/files.texi152
4 files changed, 115 insertions, 112 deletions
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE
index 1401bad10d2..beb60eb93d6 100644
--- a/admin/FOR-RELEASE
+++ b/admin/FOR-RELEASE
@@ -185,7 +185,7 @@ advice.texi cyd
185anti.texi 185anti.texi
186back.texi 186back.texi
187backups.texi cyd 187backups.texi cyd
188buffers.texi 188buffers.texi cyd
189commands.texi cyd 189commands.texi cyd
190compile.texi cyd 190compile.texi cyd
191control.texi cyd 191control.texi cyd
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 09a32de0547..a3ddc5b1cff 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,15 @@
12012-02-27 Chong Yidong <cyd@gnu.org>
2
3 * buffers.texi (Creating Buffers): Clarify that
4 generate-new-buffer uses generate-new-buffer-names.
5 (Killing Buffers): Remove bogus example duplicating buffer-live-p.
6
7 * files.texi (Directory Names): Index entry for file name abbreviations.
8 (Relative File Names, File Name Expansion): Refer to it.
9 (Locating Files): Move locate-user-emacs-file documentation to
10 Standard File Names.
11 (Standard File Names): Add locate-user-emacs-file; update examples.
12
12012-02-26 Michael Albinus <michael.albinus@gmx.de> 132012-02-26 Michael Albinus <michael.albinus@gmx.de>
2 14
3 * files.texi (Magic File Names): Add files-equal-p and file-subdir-of-p. 15 * files.texi (Magic File Names): Add files-equal-p and file-subdir-of-p.
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index c2e792cd585..125a886ecb2 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -417,7 +417,7 @@ This buffer-local variable holds the abbreviated truename of the file
417visited in the current buffer, or @code{nil} if no file is visited. 417visited in the current buffer, or @code{nil} if no file is visited.
418It is a permanent local, unaffected by 418It is a permanent local, unaffected by
419@code{kill-all-local-variables}. @xref{Truenames}, and 419@code{kill-all-local-variables}. @xref{Truenames}, and
420@ref{Definition of abbreviate-file-name}. 420@ref{abbreviate-file-name}.
421@end defvar 421@end defvar
422 422
423@defvar buffer-file-number 423@defvar buffer-file-number
@@ -502,9 +502,8 @@ buffer's recorded last file modification time as reported by
502last file modification time, after which @code{visited-file-modtime} 502last file modification time, after which @code{visited-file-modtime}
503returns zero. 503returns zero.
504 504
505@c Wordy to avoid overfull hbox. --rjc 16mar92 505When the function @code{set-visited-file-name} is called
506When the function @code{set-visited-file-name} is called interactively, it 506interactively, it prompts for @var{filename} in the minibuffer.
507prompts for @var{filename} in the minibuffer.
508@end deffn 507@end deffn
509 508
510@defvar list-buffers-directory 509@defvar list-buffers-directory
@@ -913,7 +912,7 @@ To replace a buffer in all the windows that display it, use
913This command switches to the last buffer in the local buffer list of 912This command switches to the last buffer in the local buffer list of
914the selected frame. More precisely, it calls the function 913the selected frame. More precisely, it calls the function
915@code{switch-to-buffer} (@pxref{Switching Buffers}), to display the 914@code{switch-to-buffer} (@pxref{Switching Buffers}), to display the
916buffer returned by @code{last-buffer}, see above, in the selected 915buffer returned by @code{last-buffer} (see above), in the selected
917window. 916window.
918@end deffn 917@end deffn
919 918
@@ -959,11 +958,12 @@ buffer initially disables undo information recording (@pxref{Undo}).
959 958
960@defun generate-new-buffer name 959@defun generate-new-buffer name
961This function returns a newly created, empty buffer, but does not make 960This function returns a newly created, empty buffer, but does not make
962it current. If there is no buffer named @var{name}, then that is the 961it current. The name of the buffer is generated by passing @var{name}
963name of the new buffer. If that name is in use, this function adds 962to the function @code{generate-new-buffer-name} (@pxref{Buffer
964suffixes of the form @samp{<@var{n}>} to @var{name}, where @var{n} is an 963Names}). Thus, if there is no buffer named @var{name}, then that is
965integer. It tries successive integers starting with 2 until it finds an 964the name of the new buffer; if that name is in use, a suffix of the
966available name. 965form @samp{<@var{n}>}, where @var{n} is an integer, is appended to
966@var{name}.
967 967
968An error is signaled if @var{name} is not a string. 968An error is signaled if @var{name} is not a string.
969 969
@@ -985,9 +985,6 @@ An error is signaled if @var{name} is not a string.
985The major mode for the new buffer is set to Fundamental mode. The default 985The major mode for the new buffer is set to Fundamental mode. The default
986value of the variable @code{major-mode} is handled at a higher level. 986value of the variable @code{major-mode} is handled at a higher level.
987@xref{Auto Major Mode}. 987@xref{Auto Major Mode}.
988
989See the related function @code{generate-new-buffer-name} in @ref{Buffer
990Names}.
991@end defun 988@end defun
992 989
993@node Killing Buffers 990@node Killing Buffers
@@ -1005,25 +1002,26 @@ their identity, however; if you kill two distinct buffers, they remain
1005distinct according to @code{eq} although both are dead. 1002distinct according to @code{eq} although both are dead.
1006 1003
1007 If you kill a buffer that is current or displayed in a window, Emacs 1004 If you kill a buffer that is current or displayed in a window, Emacs
1008automatically selects or displays some other buffer instead. This means 1005automatically selects or displays some other buffer instead. This
1009that killing a buffer can in general change the current buffer. 1006means that killing a buffer can change the current buffer. Therefore,
1010Therefore, when you kill a buffer, you should also take the precautions 1007when you kill a buffer, you should also take the precautions
1011associated with changing the current buffer (unless you happen to know 1008associated with changing the current buffer (unless you happen to know
1012that the buffer being killed isn't current). @xref{Current Buffer}. 1009that the buffer being killed isn't current). @xref{Current Buffer}.
1013 1010
1014 If you kill a buffer that is the base buffer of one or more indirect 1011 If you kill a buffer that is the base buffer of one or more indirect
1015buffers, the indirect buffers are automatically killed as well. 1012@iftex
1016 1013buffers,
1017 The @code{buffer-name} of a killed buffer is @code{nil}. You can use 1014@end iftex
1018this feature to test whether a buffer has been killed: 1015@ifnottex
1016buffers (@pxref{Indirect Buffers}),
1017@end ifnottex
1018the indirect buffers are automatically killed as well.
1019 1019
1020@example 1020@cindex live buffer
1021@group 1021 The @code{buffer-name} of a buffer is @code{nil} if, and only if,
1022(defun buffer-killed-p (buffer) 1022the buffer is killed. A buffer that has not been killed is called a
1023 "Return t if BUFFER is killed." 1023@dfn{live} buffer. To test whether a buffer is live or killed, use
1024 (not (buffer-name buffer))) 1024the function @code{buffer-live-p} (see below).
1025@end group
1026@end example
1027 1025
1028@deffn Command kill-buffer &optional buffer-or-name 1026@deffn Command kill-buffer &optional buffer-or-name
1029This function kills the buffer @var{buffer-or-name}, freeing all its 1027This function kills the buffer @var{buffer-or-name}, freeing all its
@@ -1032,9 +1030,8 @@ memory for other uses or to be returned to the operating system. If
1032buffer. 1030buffer.
1033 1031
1034Any processes that have this buffer as the @code{process-buffer} are 1032Any processes that have this buffer as the @code{process-buffer} are
1035sent the @code{SIGHUP} signal, which normally causes them to terminate. 1033sent the @code{SIGHUP} (``hangup'') signal, which normally causes them
1036(The basic meaning of @code{SIGHUP} is that a dialup line has been 1034to terminate. @xref{Signals to Processes}.
1037disconnected.) @xref{Signals to Processes}.
1038 1035
1039If the buffer is visiting a file and contains unsaved changes, 1036If the buffer is visiting a file and contains unsaved changes,
1040@code{kill-buffer} asks the user to confirm before the buffer is killed. 1037@code{kill-buffer} asks the user to confirm before the buffer is killed.
@@ -1099,8 +1096,8 @@ automatically becomes buffer-local when set for any reason.
1099@end defvar 1096@end defvar
1100 1097
1101@defun buffer-live-p object 1098@defun buffer-live-p object
1102This function returns @code{t} if @var{object} is a buffer which has 1099This function returns @code{t} if @var{object} is a live buffer (a
1103not been killed, @code{nil} otherwise. 1100buffer which has not been killed), @code{nil} otherwise.
1104@end defun 1101@end defun
1105 1102
1106@node Indirect Buffers 1103@node Indirect Buffers
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index bc62e9b1a49..cffaef37988 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -1360,8 +1360,10 @@ support, then the return value is @code{(nil nil nil nil)}.
1360 1360
1361 This section explains how to search for a file in a list of 1361 This section explains how to search for a file in a list of
1362directories (a @dfn{path}), or for an executable file in the standard 1362directories (a @dfn{path}), or for an executable file in the standard
1363list of executable file directories, or for an Emacs-specific user 1363list of executable file directories.
1364configuration file. 1364
1365 To search for a user-specific configuration file, @xref{Standard
1366File Names}, for the @code{locate-user-emacs-file} function.
1365 1367
1366@defun locate-file filename path &optional suffixes predicate 1368@defun locate-file filename path &optional suffixes predicate
1367This function searches for a file whose name is @var{filename} in a 1369This function searches for a file whose name is @var{filename} in a
@@ -1408,32 +1410,6 @@ in @code{exec-path}, and tries all the file-name extensions in
1408@code{exec-suffixes} (@pxref{Subprocess Creation}). 1410@code{exec-suffixes} (@pxref{Subprocess Creation}).
1409@end defun 1411@end defun
1410 1412
1411@defun locate-user-emacs-file base-name &optional old-name
1412This function returns an absolute file name for an Emacs-specific
1413configuration or data file. The argument @file{base-name} should be a
1414relative file name. The return value is the absolute name of a file
1415in the directory specified by @code{user-emacs-directory}; if that
1416directory does not exist, this function creates it.
1417
1418If the optional argument @var{old-name} is non-@code{nil}, it
1419specifies a file in the user's home directory,
1420@file{~/@var{old-name}}. If such a file exists, the return value is
1421the absolute name of that file, instead of the file specified by
1422@var{base-name}. This argument is intended to be used by Emacs
1423packages to provide backward compatibility. For instance, prior to
1424the introduction of @code{user-emacs-directory}, the abbrev file was
1425located in @file{~/.abbrev_defs}, so the definition of
1426@code{abbrev-file-name} is
1427
1428@example
1429(defcustom abbrev-file-name
1430 (locate-user-emacs-file "abbrev_defs" ".abbrev_defs")
1431 "Default name of file from which to read abbrevs."
1432 @dots{}
1433 :type 'file)
1434@end example
1435@end defun
1436
1437@node Changing Files 1413@node Changing Files
1438@section Changing File Names and Attributes 1414@section Changing File Names and Attributes
1439@c @cindex renaming files Duplicates rename-file 1415@c @cindex renaming files Duplicates rename-file
@@ -1880,14 +1856,15 @@ not an extension.
1880 1856
1881 All the directories in the file system form a tree starting at the 1857 All the directories in the file system form a tree starting at the
1882root directory. A file name can specify all the directory names 1858root directory. A file name can specify all the directory names
1883starting from the root of the tree; then it is called an @dfn{absolute} 1859starting from the root of the tree; then it is called an
1884file name. Or it can specify the position of the file in the tree 1860@dfn{absolute} file name. Or it can specify the position of the file
1885relative to a default directory; then it is called a @dfn{relative} file 1861in the tree relative to a default directory; then it is called a
1886name. On Unix and GNU/Linux, an absolute file name starts with a slash 1862@dfn{relative} file name. On Unix and GNU/Linux, an absolute file
1887or a tilde (@samp{~}), and a relative one does not. On MS-DOS and 1863name starts with a @samp{/} or a @samp{~}
1888MS-Windows, an absolute file name starts with a slash or a backslash, or 1864(@pxref{abbreviate-file-name}), and a relative one does not. On
1889with a drive specification @samp{@var{x}:/}, where @var{x} is the 1865MS-DOS and MS-Windows, an absolute file name starts with a slash or a
1890@dfn{drive letter}. 1866backslash, or with a drive specification @samp{@var{x}:/}, where
1867@var{x} is the @dfn{drive letter}.
1891 1868
1892@defun file-name-absolute-p filename 1869@defun file-name-absolute-p filename
1893This function returns @code{t} if file @var{filename} is an absolute 1870This function returns @code{t} if file @var{filename} is an absolute
@@ -2023,8 +2000,10 @@ because this is not portable. Always use
2023 To convert a directory name to its abbreviation, use this 2000 To convert a directory name to its abbreviation, use this
2024function: 2001function:
2025 2002
2003@cindex file name abbreviations
2004@cindex abbreviated file names
2026@defun abbreviate-file-name filename 2005@defun abbreviate-file-name filename
2027@anchor{Definition of abbreviate-file-name} 2006@anchor{abbreviate-file-name}
2028This function returns an abbreviated form of @var{filename}. It 2007This function returns an abbreviated form of @var{filename}. It
2029applies the abbreviations specified in @code{directory-abbrev-alist} 2008applies the abbreviations specified in @code{directory-abbrev-alist}
2030(@pxref{File Aliases,,File Aliases, emacs, The GNU Emacs Manual}), 2009(@pxref{File Aliases,,File Aliases, emacs, The GNU Emacs Manual}),
@@ -2042,11 +2021,15 @@ because it recognizes abbreviations even as part of the name.
2042@subsection Functions that Expand Filenames 2021@subsection Functions that Expand Filenames
2043@cindex expansion of file names 2022@cindex expansion of file names
2044 2023
2045 @dfn{Expansion} of a file name means converting a relative file name 2024 @dfn{Expanding} a file name means converting a relative file name to
2046to an absolute one. Since this is done relative to a default directory, 2025an absolute one. Since this is done relative to a default directory,
2047you must specify the default directory name as well as the file name to 2026you must specify the default directory name as well as the file name
2048be expanded. Expansion also simplifies file names by eliminating 2027to be expanded. It also involves expanding abbreviations like
2049redundancies such as @file{./} and @file{@var{name}/../}. 2028@file{~/}
2029@ifnottex
2030(@pxref{abbreviate-file-name}),
2031@end ifnottex
2032and eliminating redundancies like @file{./} and @file{@var{name}/../}.
2050 2033
2051@defun expand-file-name filename &optional directory 2034@defun expand-file-name filename &optional directory
2052This function converts @var{filename} to an absolute file name. If 2035This function converts @var{filename} to an absolute file name. If
@@ -2411,49 +2394,60 @@ filter out a directory named @file{foo.elc}.
2411@node Standard File Names 2394@node Standard File Names
2412@subsection Standard File Names 2395@subsection Standard File Names
2413 2396
2414 Most of the file names used in Lisp programs are entered by the user. 2397 Sometimes, an Emacs Lisp program needs to specify a standard file
2415But occasionally a Lisp program needs to specify a standard file name 2398name for a particular use---typically, to hold configuration data
2416for a particular use---typically, to hold customization information 2399specified by the current user. Usually, such files should be located
2417about each user. For example, abbrev definitions are stored (by 2400in the directory specified by @code{user-emacs-directory}, which is
2418default) in the file @file{~/.abbrev_defs}; the @code{completion} 2401@file{~/.emacs.d} by default (@pxref{Init File}). For example, abbrev
2419package stores completions in the file @file{~/.completions}. These are 2402definitions are stored by default in @file{~/.emacs.d/abbrev_defs}.
2420two of the many standard file names used by parts of Emacs for certain 2403The easiest way to specify such a file name is to use the function
2421purposes. 2404@code{locate-user-emacs-file}.
2422
2423 Various operating systems have their own conventions for valid file
2424names and for which file names to use for user profile data. A Lisp
2425program which reads a file using a standard file name ought to use, on
2426each type of system, a file name suitable for that system. The function
2427@code{convert-standard-filename} makes this easy to do.
2428 2405
2429@defun convert-standard-filename filename 2406@defun locate-user-emacs-file base-name &optional old-name
2430This function alters the file name @var{filename} to fit the conventions 2407This function returns an absolute file name for an Emacs-specific
2431of the operating system in use, and returns the result as a new string. 2408configuration or data file. The argument @file{base-name} should be a
2432@end defun 2409relative file name. The return value is the absolute name of a file
2410in the directory specified by @code{user-emacs-directory}; if that
2411directory does not exist, this function creates it.
2433 2412
2434 The recommended way to specify a standard file name in a Lisp program 2413If the optional argument @var{old-name} is non-@code{nil}, it
2435is to choose a name which fits the conventions of GNU and Unix systems, 2414specifies a file in the user's home directory,
2436usually with a nondirectory part that starts with a period, and pass it 2415@file{~/@var{old-name}}. If such a file exists, the return value is
2437to @code{convert-standard-filename} instead of using it directly. Here 2416the absolute name of that file, instead of the file specified by
2438is an example from the @code{completion} package: 2417@var{base-name}. This argument is intended to be used by Emacs
2418packages to provide backward compatibility. For instance, prior to
2419the introduction of @code{user-emacs-directory}, the abbrev file was
2420located in @file{~/.abbrev_defs}. Here is the definition of
2421@code{abbrev-file-name}:
2439 2422
2440@example 2423@example
2441(defvar save-completions-file-name 2424(defcustom abbrev-file-name
2442 (convert-standard-filename "~/.completions") 2425 (locate-user-emacs-file "abbrev_defs" ".abbrev_defs")
2443 "*The file name to save completions to.") 2426 "Default name of file from which to read abbrevs."
2427 @dots{}
2428 :type 'file)
2444@end example 2429@end example
2430@end defun
2445 2431
2446 On GNU and Unix systems, and on some other systems as well, 2432 A lower-level function for standardizing file names, which
2447@code{convert-standard-filename} returns its argument unchanged. On 2433@code{locate-user-emacs-file} uses as a subroutine, is
2448some other systems, it alters the name to fit the system's conventions. 2434@code{convert-standard-filename}.
2449 2435
2450 For example, on MS-DOS the alterations made by this function include 2436@defun convert-standard-filename filename
2451converting a leading @samp{.} to @samp{_}, converting a @samp{_} in the 2437This function returns a file name based on @var{filename}, which fits
2452middle of the name to @samp{.} if there is no other @samp{.}, inserting 2438the conventions of the current operating system.
2453a @samp{.} after eight characters if there is none, and truncating to 2439
2454three characters after the @samp{.}. (It makes other changes as well.) 2440On GNU and Unix systems, this simply returns @var{filename}. On other
2455Thus, @file{.abbrev_defs} becomes @file{_abbrev.def}, and 2441operating systems, it may enforce system-specific file name
2456@file{.completions} becomes @file{_complet.ion}. 2442conventions; for example, on MS-DOS this function performs a variety
2443of changes to enforce MS-DOS file name limitations, including
2444converting any leading @samp{.} to @samp{_} and truncating to three
2445characters after the @samp{.}.
2446
2447The recommended way to use this function is to specify a name which
2448fits the conventions of GNU and Unix systems, and pass it to
2449@code{convert-standard-filename}.
2450@end defun
2457 2451
2458@node Contents of Directories 2452@node Contents of Directories
2459@section Contents of Directories 2453@section Contents of Directories