comparison lispref/files.texi @ 24951:7451b1458af1

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Sat, 17 Jul 1999 02:15:13 +0000
parents 71f954d59214
children a6db4671c7a0
comparison
equal deleted inserted replaced
24950:39bac3b71db1 24951:7451b1458af1
81 In a Lisp program, if you want to look at the contents of a file but 81 In a Lisp program, if you want to look at the contents of a file but
82 not alter it, the fastest way is to use @code{insert-file-contents} in a 82 not alter it, the fastest way is to use @code{insert-file-contents} in a
83 temporary buffer. Visiting the file is not necessary and takes longer. 83 temporary buffer. Visiting the file is not necessary and takes longer.
84 @xref{Reading from Files}. 84 @xref{Reading from Files}.
85 85
86 @deffn Command find-file filename 86 @deffn Command find-file filename &optional wildcards
87 This command selects a buffer visiting the file @var{filename}, 87 This command selects a buffer visiting the file @var{filename},
88 using an existing buffer if there is one, and otherwise creating a 88 using an existing buffer if there is one, and otherwise creating a
89 new buffer and reading the file into it. It also returns that buffer. 89 new buffer and reading the file into it. It also returns that buffer.
90 90
91 The body of the @code{find-file} function is very simple and looks 91 The body of the @code{find-file} function is very simple and looks
96 @end example 96 @end example
97 97
98 @noindent 98 @noindent
99 (See @code{switch-to-buffer} in @ref{Displaying Buffers}.) 99 (See @code{switch-to-buffer} in @ref{Displaying Buffers}.)
100 100
101 If @var{wildcards} is non-@code{nil}, which is always true in an
102 interactive call, then @code{find-file} expands wildcard characters in
103 @var{filename} and visits all the matching files.
104
101 When @code{find-file} is called interactively, it prompts for 105 When @code{find-file} is called interactively, it prompts for
102 @var{filename} in the minibuffer. 106 @var{filename} in the minibuffer.
103 @end deffn 107 @end deffn
104 108
105 @defun find-file-noselect filename &optional nowarn rawfile 109 @defun find-file-noselect filename &optional nowarn rawfile wildcards
106 This function is the guts of all the file-visiting functions. It finds 110 This function is the guts of all the file-visiting functions. It finds
107 or creates a buffer visiting the file @var{filename}, and returns it. 111 or creates a buffer visiting the file @var{filename}, and returns it.
108 It uses an existing buffer if there is one, and otherwise creates a new 112 It uses an existing buffer if there is one, and otherwise creates a new
109 buffer and reads the file into it. You may make the buffer current or 113 buffer and reads the file into it. You may make the buffer current or
110 display it in a window if you wish, but this function does not do so. 114 display it in a window if you wish, but this function does not do so.
115
116 If @var{wildcards} is non-@code{nil}, which is always true in an
117 interactive call, then @code{find-file-noselect} expands wildcard
118 characters in @var{filename} and visits all the matching files.
111 119
112 When @code{find-file-noselect} uses an existing buffer, it first 120 When @code{find-file-noselect} uses an existing buffer, it first
113 verifies that the file has not changed since it was last visited or 121 verifies that the file has not changed since it was last visited or
114 saved in that buffer. If the file has changed, then this function asks 122 saved in that buffer. If the file has changed, then this function asks
115 the user whether to reread the changed file. If the user says 123 the user whether to reread the changed file. If the user says
144 @result{} #<buffer fstab> 152 @result{} #<buffer fstab>
145 @end group 153 @end group
146 @end example 154 @end example
147 @end defun 155 @end defun
148 156
149 @deffn Command find-file-other-window filename 157 @deffn Command find-file-other-window filename &optional wildcards
150 This command selects a buffer visiting the file @var{filename}, but 158 This command selects a buffer visiting the file @var{filename}, but
151 does so in a window other than the selected window. It may use another 159 does so in a window other than the selected window. It may use another
152 existing window or split a window; see @ref{Displaying Buffers}. 160 existing window or split a window; see @ref{Displaying Buffers}.
153 161
154 When this command is called interactively, it prompts for 162 When this command is called interactively, it prompts for
155 @var{filename}. 163 @var{filename}.
156 @end deffn 164 @end deffn
157 165
158 @deffn Command find-file-read-only filename 166 @deffn Command find-file-read-only filename &optional wildcards
159 This command selects a buffer visiting the file @var{filename}, like 167 This command selects a buffer visiting the file @var{filename}, like
160 @code{find-file}, but it marks the buffer as read-only. @xref{Read Only 168 @code{find-file}, but it marks the buffer as read-only. @xref{Read Only
161 Buffers}, for related functions and variables. 169 Buffers}, for related functions and variables.
162 170
163 When this command is called interactively, it prompts for 171 When this command is called interactively, it prompts for
172 @code{view-mode-hook}. @xref{Hooks}. 180 @code{view-mode-hook}. @xref{Hooks}.
173 181
174 When @code{view-file} is called interactively, it prompts for 182 When @code{view-file} is called interactively, it prompts for
175 @var{filename}. 183 @var{filename}.
176 @end deffn 184 @end deffn
185
186 @tindex find-file-wildcards
187 @defvar find-file-wildcards
188 If this variable is non-@code{nil}, then the various @code{find-file}
189 commands check for wildcard characters and visit all the files that
190 match them. If this is @code{nil}, then wildcard characters are
191 not treated specially.
192 @end defvar
177 193
178 @defvar find-file-hooks 194 @defvar find-file-hooks
179 The value of this variable is a list of functions to be called after a 195 The value of this variable is a list of functions to be called after a
180 file is visited. The file's local-variables specification (if any) will 196 file is visited. The file's local-variables specification (if any) will
181 have been processed before the hooks are run. The buffer visiting the 197 have been processed before the hooks are run. The buffer visiting the
558 When two users edit the same file at the same time, they are likely to 574 When two users edit the same file at the same time, they are likely to
559 interfere with each other. Emacs tries to prevent this situation from 575 interfere with each other. Emacs tries to prevent this situation from
560 arising by recording a @dfn{file lock} when a file is being modified. 576 arising by recording a @dfn{file lock} when a file is being modified.
561 Emacs can then detect the first attempt to modify a buffer visiting a 577 Emacs can then detect the first attempt to modify a buffer visiting a
562 file that is locked by another Emacs job, and ask the user what to do. 578 file that is locked by another Emacs job, and ask the user what to do.
563 579 The file lock is really a file, a symbolic link with a special name,
564 File locks are not completely reliable when multiple machines can 580 stored in the same directory as the file you are editing.
565 share file systems. When file locks do not work, it is possible for two 581
566 users to make changes simultaneously, but Emacs can still warn the user 582 When you access files using NFS, there may be a small probability that
567 who saves second. Also, the detection of modification of a buffer 583 you and another user will both lock the same file ``simultaneously''.
568 visiting a file changed on disk catches some cases of simultaneous 584 If this happens, it is possible for the two users to make changes
569 editing; see @ref{Modification Time}. 585 simultaneously, but Emacs will still warn the user who saves second.
586 Also, the detection of modification of a buffer visiting a file changed
587 on disk catches some cases of simultaneous editing; see
588 @ref{Modification Time}.
570 589
571 @defun file-locked-p filename 590 @defun file-locked-p filename
572 This function returns @code{nil} if the file @var{filename} is not 591 This function returns @code{nil} if the file @var{filename} is not
573 locked. It returns @code{t} if it is locked by this Emacs process, and 592 locked. It returns @code{t} if it is locked by this Emacs process, and
574 it returns the name of the user who has locked it if it is locked by 593 it returns the name of the user who has locked it if it is locked by
581 @end group 600 @end group
582 @end example 601 @end example
583 @end defun 602 @end defun
584 603
585 @defun lock-buffer &optional filename 604 @defun lock-buffer &optional filename
586 This function locks the file @var{filename}, if the current buffer is 605 This function locks the file @var{filename}, if the current buffer is
587 modified. The argument @var{filename} defaults to the current buffer's 606 modified. The argument @var{filename} defaults to the current buffer's
588 visited file. Nothing is done if the current buffer is not visiting a 607 visited file. Nothing is done if the current buffer is not visiting a
589 file, or is not modified. 608 file, or is not modified.
590 @end defun 609 @end defun
591 610
859 @end example 878 @end example
860 @end defun 879 @end defun
861 880
862 @defun file-regular-p filename 881 @defun file-regular-p filename
863 This function returns @code{t} if the file @var{filename} exists and is 882 This function returns @code{t} if the file @var{filename} exists and is
864 a regular file (not a directory, symbolic link, named pipe, terminal, or 883 a regular file (not a directory, named pipe, terminal, or
865 other I/O device). 884 other I/O device).
866 @end defun 885 @end defun
867 886
868 @node Truenames 887 @node Truenames
869 @subsection Truenames 888 @subsection Truenames
995 1014
996 @item 1015 @item
997 The time of last status change as a list of two integers (as above). 1016 The time of last status change as a list of two integers (as above).
998 1017
999 @item 1018 @item
1000 The size of the file in bytes. 1019 The size of the file in bytes. If the size is too large to fit in a
1020 Lisp integer, this is a floating point number.
1001 1021
1002 @item 1022 @item
1003 The file's modes, as a string of ten letters or dashes, 1023 The file's modes, as a string of ten letters or dashes,
1004 as in @samp{ls -l}. 1024 as in @samp{ls -l}.
1005 1025
1898 @end defun 1918 @end defun
1899 1919
1900 @defun file-name-all-versions file dirname 1920 @defun file-name-all-versions file dirname
1901 This function returns a list of all versions of the file named 1921 This function returns a list of all versions of the file named
1902 @var{file} in directory @var{dirname}. 1922 @var{file} in directory @var{dirname}.
1923 @end defun
1924
1925 @tindex file-expand-wildcards
1926 @defun file-expand-wildcards pattern &optional full
1927 This function expands the wildcard pattern @var{pattern}, returning
1928 alist of file names that match it.
1929
1930 If @var{pattern} is written as an absolute relative file name,
1931 the values are absolute also.
1932
1933 If @var{pattern} is written as a relative file name, it is interpreted
1934 relative to the current default directory. The file names returned are
1935 normally also relative to the current default directory. However, if
1936 @var{full} is non-@code{nil}, they are absolute.
1903 @end defun 1937 @end defun
1904 1938
1905 @defun insert-directory file switches &optional wildcard full-directory-p 1939 @defun insert-directory file switches &optional wildcard full-directory-p
1906 This function inserts (in the current buffer) a directory listing for 1940 This function inserts (in the current buffer) a directory listing for
1907 directory @var{file}, formatted with @code{ls} according to 1941 directory @var{file}, formatted with @code{ls} according to