comparison lispref/files.texi @ 22271:71f954d59214

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Thu, 28 May 1998 01:15:58 +0000
parents d4ac295a98b3
children 7451b1458af1
comparison
equal deleted inserted replaced
22270:0739384d4356 22271:71f954d59214
163 When this command is called interactively, it prompts for 163 When this command is called interactively, it prompts for
164 @var{filename}. 164 @var{filename}.
165 @end deffn 165 @end deffn
166 166
167 @deffn Command view-file filename 167 @deffn Command view-file filename
168 This command visits @var{filename} in View mode, and displays it in a 168 This command visits @var{filename} using View mode, returning to the
169 recursive edit, returning to the previous buffer when done. View mode 169 previous buffer when you exit View mode. View mode is a minor mode that
170 is a mode that allows you to skim rapidly through the file but does not 170 provides commands to skim rapidly through the file, but does not let you
171 let you modify it. Entering View mode runs the normal hook 171 modify the text. Entering View mode runs the normal hook
172 @code{view-mode-hook}. @xref{Hooks}. 172 @code{view-mode-hook}. @xref{Hooks}.
173 173
174 When @code{view-file} is called interactively, it prompts for 174 When @code{view-file} is called interactively, it prompts for
175 @var{filename}. 175 @var{filename}.
176 @end deffn 176 @end deffn
180 file is visited. The file's local-variables specification (if any) will 180 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 181 have been processed before the hooks are run. The buffer visiting the
182 file is current when the hook functions are run. 182 file is current when the hook functions are run.
183 183
184 This variable works just like a normal hook, but we think that renaming 184 This variable works just like a normal hook, but we think that renaming
185 it would not be advisable. 185 it would not be advisable. @xref{Hooks}.
186 @end defvar 186 @end defvar
187 187
188 @defvar find-file-not-found-hooks 188 @defvar find-file-not-found-hooks
189 The value of this variable is a list of functions to be called when 189 The value of this variable is a list of functions to be called when
190 @code{find-file} or @code{find-file-noselect} is passed a nonexistent 190 @code{find-file} or @code{find-file-noselect} is passed a nonexistent
336 336
337 The hook functions in @code{write-file-hooks} are also responsible for 337 The hook functions in @code{write-file-hooks} are also responsible for
338 encoding the data (if desired): they must choose a suitable coding 338 encoding the data (if desired): they must choose a suitable coding
339 system (@pxref{Lisp and Coding Systems}), perform the encoding 339 system (@pxref{Lisp and Coding Systems}), perform the encoding
340 (@pxref{Explicit Encoding}), and set @code{last-coding-system-used} to 340 (@pxref{Explicit Encoding}), and set @code{last-coding-system-used} to
341 the coding system that was used (@pxref{Specifying Coding Systems}). 341 the coding system that was used (@pxref{Encoding and I/O}).
342 342
343 Do not make this variable buffer-local. To set up buffer-specific hook 343 Do not make this variable buffer-local. To set up buffer-specific hook
344 functions, use @code{write-contents-hooks} instead. 344 functions, use @code{write-contents-hooks} instead.
345 345
346 Even though this is not a normal hook, you can use @code{add-hook} and 346 Even though this is not a normal hook, you can use @code{add-hook} and
374 @end defvar 374 @end defvar
375 375
376 @c Emacs 19 feature 376 @c Emacs 19 feature
377 @defvar after-save-hook 377 @defvar after-save-hook
378 This normal hook runs after a buffer has been saved in its visited file. 378 This normal hook runs after a buffer has been saved in its visited file.
379 One use of this hook is in Fast Lock mode; it uses this hook to save the
380 highlighting information in a cache file.
379 @end defvar 381 @end defvar
380 382
381 @defvar file-precious-flag 383 @defvar file-precious-flag
382 If this variable is non-@code{nil}, then @code{save-buffer} protects 384 If this variable is non-@code{nil}, then @code{save-buffer} protects
383 against I/O errors while saving by writing the new file to a temporary 385 against I/O errors while saving by writing the new file to a temporary
388 390
389 As a side effect, backups are necessarily made by copying. @xref{Rename 391 As a side effect, backups are necessarily made by copying. @xref{Rename
390 or Copy}. Yet, at the same time, saving a precious file always breaks 392 or Copy}. Yet, at the same time, saving a precious file always breaks
391 all hard links between the file you save and other file names. 393 all hard links between the file you save and other file names.
392 394
393 Some modes give this variable non-@code{nil} buffer-local value 395 Some modes give this variable a non-@code{nil} buffer-local value
394 in particular buffers. 396 in particular buffers.
395 @end defvar 397 @end defvar
396 398
397 @defopt require-final-newline 399 @defopt require-final-newline
398 This variable determines whether files may be written out that do 400 This variable determines whether files may be written out that do
525 The function @code{write-region} converts the data which it writes to 527 The function @code{write-region} converts the data which it writes to
526 the appropriate file formats specified by @code{buffer-file-format}. 528 the appropriate file formats specified by @code{buffer-file-format}.
527 @xref{Format Conversion}. It also calls the functions in the list 529 @xref{Format Conversion}. It also calls the functions in the list
528 @code{write-region-annotate-functions}; see @ref{Saving Properties}. 530 @code{write-region-annotate-functions}; see @ref{Saving Properties}.
529 531
530 Normally, @code{write-region} displays a message @samp{Wrote file 532 Normally, @code{write-region} displays the message @samp{Wrote
531 @var{filename}} in the echo area. If @var{visit} is neither @code{t} 533 @var{filename}} in the echo area. If @var{visit} is neither @code{t}
532 nor @code{nil} nor a string, then this message is inhibited. This 534 nor @code{nil} nor a string, then this message is inhibited. This
533 feature is useful for programs that use files for internal purposes, 535 feature is useful for programs that use files for internal purposes,
534 files that the user does not need to know about. 536 files that the user does not need to know about.
535 @end deffn 537 @end deffn
565 who saves second. Also, the detection of modification of a buffer 567 who saves second. Also, the detection of modification of a buffer
566 visiting a file changed on disk catches some cases of simultaneous 568 visiting a file changed on disk catches some cases of simultaneous
567 editing; see @ref{Modification Time}. 569 editing; see @ref{Modification Time}.
568 570
569 @defun file-locked-p filename 571 @defun file-locked-p filename
570 This function returns @code{nil} if the file @var{filename} is not 572 This function returns @code{nil} if the file @var{filename} is not
571 locked by this Emacs process. It returns @code{t} if it is locked by 573 locked. It returns @code{t} if it is locked by this Emacs process, and
572 this Emacs, and it returns the name of the user who has locked it if it 574 it returns the name of the user who has locked it if it is locked by
573 is locked by someone else. 575 some other job.
574 576
575 @example 577 @example
576 @group 578 @group
577 (file-locked-p "foo") 579 (file-locked-p "foo")
578 @result{} nil 580 @result{} nil
867 @subsection Truenames 869 @subsection Truenames
868 @cindex truename (of file) 870 @cindex truename (of file)
869 871
870 @c Emacs 19 features 872 @c Emacs 19 features
871 The @dfn{truename} of a file is the name that you get by following 873 The @dfn{truename} of a file is the name that you get by following
872 symbolic links until none remain, then expanding to get rid of @samp{.} 874 symbolic links until none remain, then simplifying away @samp{.}@: and
873 and @samp{..} as components. Strictly speaking, a file need not have a 875 @samp{..}@: appearing as components. Strictly speaking, a file need not
874 unique truename; the number of distinct truenames a file has is equal to 876 have a unique truename; the number of distinct truenames a file has is
875 the number of hard links to the file. However, truenames are useful 877 equal to the number of hard links to the file. However, truenames are
876 because they eliminate symbolic links as a cause of name variation. 878 useful because they eliminate symbolic links as a cause of name
879 variation.
877 880
878 @defun file-truename filename 881 @defun file-truename filename
879 The function @code{file-truename} returns the true name of the file 882 The function @code{file-truename} returns the true name of the file
880 @var{filename}. This is the name that you get by following symbolic 883 @var{filename}. This is the name that you get by following symbolic
881 links until none remain. The argument must be an absolute file name. 884 links until none remain. The argument must be an absolute file name.
1672 where to put the temporary file. All Emacs Lisp programs should 1675 where to put the temporary file. All Emacs Lisp programs should
1673 use @code{temporary-file-directory} for this purpose, to give the user 1676 use @code{temporary-file-directory} for this purpose, to give the user
1674 a uniform way to specify the directory for all temporary files. 1677 a uniform way to specify the directory for all temporary files.
1675 1678
1676 @defun make-temp-name string 1679 @defun make-temp-name string
1677 This function generates string that can be used as a unique file name. 1680 This function generates a string that can be used as a unique file name.
1678 The name starts with @var{string}, and contains a number that is 1681 The name starts with @var{string}, and contains a number that is
1679 different in each Emacs job. 1682 different in each Emacs job.
1680 1683
1681 @example 1684 @example
1682 @group 1685 @group
1696 @defvar temporary-file-directory 1699 @defvar temporary-file-directory
1697 @cindex @code{TMPDIR} environment variable. 1700 @cindex @code{TMPDIR} environment variable.
1698 @cindex @code{TMP} environment variable. 1701 @cindex @code{TMP} environment variable.
1699 This variable specifies the directory name for creating temporary files. 1702 This variable specifies the directory name for creating temporary files.
1700 Its value should be a directory name (@pxref{Directory Names}), but it 1703 Its value should be a directory name (@pxref{Directory Names}), but it
1701 is good for Lisp programs to cope if the value is a file name instead. 1704 is good for Lisp programs to cope if the value is a directory's file
1702 (Using the value as the second argument to @code{expand-file-name} is a 1705 name instead. Using the value as the second argument to
1703 good way to achieve that.) 1706 @code{expand-file-name} is a good way to achieve that.
1704 1707
1705 The default value is determined in a reasonable way for your operating 1708 The default value is determined in a reasonable way for your operating
1706 system; on GNU and Unix systems it is based on the @code{TMP} and 1709 system; on GNU and Unix systems it is based on the @code{TMP} and
1707 @code{TMPDIR} environment variables. 1710 @code{TMPDIR} environment variables.
1708 1711
1993 (funcall @var{handler} 'file-exists-p @var{filename}) 1996 (funcall @var{handler} 'file-exists-p @var{filename})
1994 @end example 1997 @end example
1995 1998
1996 Here are the operations that a magic file name handler gets to handle: 1999 Here are the operations that a magic file name handler gets to handle:
1997 2000
2001 @ifinfo
1998 @noindent 2002 @noindent
1999 @code{add-name-to-file}, @code{copy-file}, @code{delete-directory}, 2003 @code{add-name-to-file}, @code{copy-file}, @code{delete-directory},
2000 @code{delete-file}, 2004 @code{delete-file},
2001 @code{diff-latest-backup-file}, 2005 @code{diff-latest-backup-file},
2002 @code{directory-file-name}, 2006 @code{directory-file-name},
2022 @code{get-file-buffer},@* 2026 @code{get-file-buffer},@*
2023 @code{insert-directory}, 2027 @code{insert-directory},
2024 @code{insert-file-contents}, 2028 @code{insert-file-contents},
2025 @code{load}, @code{make-directory}, 2029 @code{load}, @code{make-directory},
2026 @code{make-symbolic-link}, @code{rename-file}, @code{set-file-modes}, 2030 @code{make-symbolic-link}, @code{rename-file}, @code{set-file-modes},
2027 @code{set-visited-file-modtime}, @code{shell-command}.@* 2031 @code{set-visited-file-modtime}, @code{shell-command},@*
2028 @code{unhandled-file-name-directory}, 2032 @code{unhandled-file-name-directory},
2029 @code{vc-registered}, 2033 @code{vc-registered},
2030 @code{verify-visited-file-modtime},@* 2034 @code{verify-visited-file-modtime},@*
2031 @code{write-region}. 2035 @code{write-region}.
2036 @end ifinfo
2037 @iftex
2038 @noindent
2039 @code{add-name-to-file}, @code{copy-file}, @code{delete-directory},
2040 @code{delete-file},
2041 @code{diff-latest-backup-file},
2042 @code{directory-file-name},
2043 @code{directory-files},
2044 @code{dired-call-process},
2045 @code{dired-compress-file}, @code{dired-uncache},
2046 @code{expand-file-name},
2047 @code{file-accessible-direc@discretionary{}{}{}tory-p},
2048 @code{file-attributes},
2049 @code{file-direct@discretionary{}{}{}ory-p},
2050 @code{file-executable-p}, @code{file-exists-p},
2051 @code{file-local-copy},
2052 @code{file-modes}, @code{file-name-all-completions},
2053 @code{file-name-as-directory},
2054 @code{file-name-completion},
2055 @code{file-name-directory},
2056 @code{file-name-nondirec@discretionary{}{}{}tory},
2057 @code{file-name-sans-versions}, @code{file-newer-than-file-p},
2058 @code{file-ownership-pre@discretionary{}{}{}served-p},
2059 @code{file-readable-p}, @code{file-regular-p}, @code{file-symlink-p},
2060 @code{file-truename}, @code{file-writable-p},
2061 @code{find-backup-file-name},
2062 @code{get-file-buffer},
2063 @code{insert-directory},
2064 @code{insert-file-contents},
2065 @code{load}, @code{make-direc@discretionary{}{}{}tory},
2066 @code{make-symbolic-link}, @code{rename-file}, @code{set-file-modes},
2067 @code{set-visited-file-modtime}, @code{shell-command},
2068 @code{unhandled-file-name-directory},
2069 @code{vc-regis@discretionary{}{}{}tered},
2070 @code{verify-visited-file-modtime},
2071 @code{write-region}.
2072 @end iftex
2032 2073
2033 Handlers for @code{insert-file-contents} typically need to clear the 2074 Handlers for @code{insert-file-contents} typically need to clear the
2034 buffer's modified flag, with @code{(set-buffer-modified-p nil)}, if the 2075 buffer's modified flag, with @code{(set-buffer-modified-p nil)}, if the
2035 @var{visit} argument is non-@code{nil}. This also has the effect of 2076 @var{visit} argument is non-@code{nil}. This also has the effect of
2036 unlocking the buffer if it is locked. 2077 unlocking the buffer if it is locked.
2087 2128
2088 @defun file-local-copy filename 2129 @defun file-local-copy filename
2089 This function copies file @var{filename} to an ordinary non-magic file, 2130 This function copies file @var{filename} to an ordinary non-magic file,
2090 if it isn't one already. 2131 if it isn't one already.
2091 2132
2092 If @var{filename} specifies a ``magic'' file name, which programs 2133 If @var{filename} specifies a magic file name, which programs
2093 outside Emacs cannot directly read or write, this copies the contents to 2134 outside Emacs cannot directly read or write, this copies the contents to
2094 an ordinary file and returns that file's name. 2135 an ordinary file and returns that file's name.
2095 2136
2096 If @var{filename} is an ordinary file name, not magic, then this function 2137 If @var{filename} is an ordinary file name, not magic, then this function
2097 does nothing and returns @code{nil}. 2138 does nothing and returns @code{nil}.