diff options
| author | Richard M. Stallman | 1996-07-23 15:46:12 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-07-23 15:46:12 +0000 |
| commit | fbc1b72c2046079613ea923a660d6a00951e4ee0 (patch) | |
| tree | 32de1d4c64d2c4653ba26758dcec8772e5a57c60 | |
| parent | 4324b7ab26d9cb92a364b48155ce28f18b7ef02c (diff) | |
| download | emacs-fbc1b72c2046079613ea923a660d6a00951e4ee0.tar.gz emacs-fbc1b72c2046079613ea923a660d6a00951e4ee0.zip | |
New node Standard File Names.
Document set-visited-file-name.
Add some magic file name operations.
Binary file types apply to MSDOS.
| -rw-r--r-- | lispref/files.texi | 92 |
1 files changed, 78 insertions, 14 deletions
diff --git a/lispref/files.texi b/lispref/files.texi index 8665cfbdec3..8b93faf9b68 100644 --- a/lispref/files.texi +++ b/lispref/files.texi | |||
| @@ -392,6 +392,17 @@ doesn't add newlines at all. @code{nil} is the default value, but a few | |||
| 392 | major modes set it to @code{t} in particular buffers. | 392 | major modes set it to @code{t} in particular buffers. |
| 393 | @end defopt | 393 | @end defopt |
| 394 | 394 | ||
| 395 | @deffn Command set-visited-file-name filename &optional no-query | ||
| 396 | This function changes the visited file name of the current buffer to | ||
| 397 | @var{filename}. It also renames the buffer based on @var{filename}, | ||
| 398 | appending a string like @samp{<2>} if necessary to make a unique buffer | ||
| 399 | name. It marks the buffer as @emph{modified},a since the contents do not | ||
| 400 | (as far as Emacs knows) match the actual file's contents. | ||
| 401 | |||
| 402 | If the specified file already exists, @code{set-visited-file-name} | ||
| 403 | asks for confirmation unless @var{no-query} is non-@code{nil}. | ||
| 404 | @end deffn | ||
| 405 | |||
| 395 | @node Reading from Files | 406 | @node Reading from Files |
| 396 | @comment node-name, next, previous, up | 407 | @comment node-name, next, previous, up |
| 397 | @section Reading from Files | 408 | @section Reading from Files |
| @@ -1234,6 +1245,8 @@ as well as Unix syntax. | |||
| 1234 | * File Name Expansion:: Converting relative file names to absolute ones. | 1245 | * File Name Expansion:: Converting relative file names to absolute ones. |
| 1235 | * Unique File Names:: Generating names for temporary files. | 1246 | * Unique File Names:: Generating names for temporary files. |
| 1236 | * File Name Completion:: Finding the completions for a given file name. | 1247 | * File Name Completion:: Finding the completions for a given file name. |
| 1248 | * Standard File Names:: If your package uses a fixed file name, | ||
| 1249 | how to handle various operating systems simply. | ||
| 1237 | @end menu | 1250 | @end menu |
| 1238 | 1251 | ||
| 1239 | @node File Name Components | 1252 | @node File Name Components |
| @@ -1738,6 +1751,53 @@ completion-ignored-extensions | |||
| 1738 | @end example | 1751 | @end example |
| 1739 | @end defopt | 1752 | @end defopt |
| 1740 | 1753 | ||
| 1754 | @node Standard File Names | ||
| 1755 | @subsection Standard File Names | ||
| 1756 | |||
| 1757 | Most of the file names used in Lisp programs are entered by the user. | ||
| 1758 | But occasionally a Lisp program needs to specify a standard file name | ||
| 1759 | for a particular use---typically, to hold customization information | ||
| 1760 | about each user. For example, abbrev definitions are stored (by | ||
| 1761 | default) in the file @file{~/.abbrev_defs}; the @code{completion} | ||
| 1762 | package stores completions in the file @file{~/.completions}. These are | ||
| 1763 | two of the many standard file names used by parts of Emacs for certain | ||
| 1764 | purposes. | ||
| 1765 | |||
| 1766 | Various operating systems have their own conventions for valid file | ||
| 1767 | names and for which file names to use for user profile data. A Lisp | ||
| 1768 | program which reads a file using a standard file name ought to use, on | ||
| 1769 | each type of system, a file name suitable for that system. The function | ||
| 1770 | @code{convert-standard-filename} makes this easy to do. | ||
| 1771 | |||
| 1772 | @defun convert-standard-filename filename | ||
| 1773 | This function alters the file name @var{filename} to fit the conventions | ||
| 1774 | of the operating system in use, and returns the result as a new string. | ||
| 1775 | @end defun | ||
| 1776 | |||
| 1777 | The recommended way to specify a standard file name in a Lisp program | ||
| 1778 | is to choose a name which fits the conventions of GNU and Unix systems, | ||
| 1779 | usually with a nondirectory part that starts with a period, and pass it | ||
| 1780 | to @code{convert-standard-filename} instead of using it directly. Here | ||
| 1781 | is an example from the @code{completion} package: | ||
| 1782 | |||
| 1783 | @example | ||
| 1784 | (defvar save-completions-file-name | ||
| 1785 | (convert-standard-filename "~/.completions") | ||
| 1786 | "*The file name to save completions to.") | ||
| 1787 | @end example | ||
| 1788 | |||
| 1789 | On GNU and Unix systems, and on some other systems as well, | ||
| 1790 | @code{convert-standard-filename} returns its argument unchanged. On | ||
| 1791 | some other systems, it alters the name to fit the systems's conventions. | ||
| 1792 | |||
| 1793 | For example, on MS-DOS the alterations made by this function include | ||
| 1794 | converting a leading @samp{.} to @samp{_}, converting a @samp{_} in the | ||
| 1795 | middle of the name to @samp{.} if there is no other @samp{.}, inserting | ||
| 1796 | a @samp{.} after eight characters if there is none, and truncating to | ||
| 1797 | three characters after the @samp{.}. (It makes other changes as well.) | ||
| 1798 | Thus, @file{.abbrev_defs} becomes @file{_abbrev.def}, and | ||
| 1799 | @file{.completions} becomes @file{_complet.ion}. | ||
| 1800 | |||
| 1741 | @node Contents of Directories | 1801 | @node Contents of Directories |
| 1742 | @section Contents of Directories | 1802 | @section Contents of Directories |
| 1743 | @cindex directory-oriented functions | 1803 | @cindex directory-oriented functions |
| @@ -1884,7 +1944,7 @@ Here are the operations that a magic file name handler gets to handle: | |||
| 1884 | @code{delete-file},@* | 1944 | @code{delete-file},@* |
| 1885 | @code{diff-latest-backup-file}, | 1945 | @code{diff-latest-backup-file}, |
| 1886 | @code{directory-file-name}, | 1946 | @code{directory-file-name}, |
| 1887 | @code{directory-files}, | 1947 | @code{directory-files}, @code{dired-call-process}, |
| 1888 | @code{dired-compress-file}, @code{dired-uncache}, | 1948 | @code{dired-compress-file}, @code{dired-uncache}, |
| 1889 | @code{expand-file-name},@* | 1949 | @code{expand-file-name},@* |
| 1890 | @code{file-accessible-directory-p}, | 1950 | @code{file-accessible-directory-p}, |
| @@ -1894,13 +1954,16 @@ Here are the operations that a magic file name handler gets to handle: | |||
| 1894 | @code{file-name-as-directory}, @code{file-name-completion}, | 1954 | @code{file-name-as-directory}, @code{file-name-completion}, |
| 1895 | @code{file-name-directory}, @code{file-name-nondirectory}, | 1955 | @code{file-name-directory}, @code{file-name-nondirectory}, |
| 1896 | @code{file-name-sans-versions}, @code{file-newer-than-file-p}, | 1956 | @code{file-name-sans-versions}, @code{file-newer-than-file-p}, |
| 1957 | @code{file-ownership-preserved-p}, | ||
| 1897 | @code{file-readable-p}, @code{file-regular-p}, @code{file-symlink-p}, | 1958 | @code{file-readable-p}, @code{file-regular-p}, @code{file-symlink-p}, |
| 1898 | @code{file-truename}, @code{file-writable-p}, | 1959 | @code{file-truename}, @code{file-writable-p}, |
| 1960 | @code{find-backup-file-name}, | ||
| 1899 | @code{get-file-buffer}, | 1961 | @code{get-file-buffer}, |
| 1900 | @code{insert-directory}, | 1962 | @code{insert-directory}, @code{insert-file-contents}, |
| 1901 | @code{insert-file-contents}, @code{load}, @code{make-directory}, | 1963 | @code{load}, @code{make-directory}, |
| 1902 | @code{make-symbolic-link}, @code{rename-file}, @code{set-file-modes}, | 1964 | @code{make-symbolic-link}, @code{rename-file}, @code{set-file-modes}, |
| 1903 | @code{set-visited-file-modtime}, @code{unhandled-file-name-directory}, | 1965 | @code{set-visited-file-modtime}, @code{shell-command}. |
| 1966 | @code{unhandled-file-name-directory}, @code{vc-registered}, | ||
| 1904 | @code{verify-visited-file-modtime}, @code{write-region}. | 1967 | @code{verify-visited-file-modtime}, @code{write-region}. |
| 1905 | 1968 | ||
| 1906 | Handlers for @code{insert-file-contents} typically need to clear the | 1969 | Handlers for @code{insert-file-contents} typically need to clear the |
| @@ -2133,16 +2196,17 @@ is always local in all buffers. | |||
| 2133 | @cindex file types on MS-DOS | 2196 | @cindex file types on MS-DOS |
| 2134 | @cindex text files and binary files | 2197 | @cindex text files and binary files |
| 2135 | @cindex binary files and text files | 2198 | @cindex binary files and text files |
| 2136 | 2199 | @cindex Windows file types | |
| 2137 | Emacs on MS-DOS makes a distinction between text files and binary | 2200 | |
| 2138 | files. This is necessary because ordinary text files on MS-DOS use a | 2201 | Emacs on MS-DOS and on Windows NT or 95 makes a distinction between |
| 2139 | two character sequence between lines: carriage-return and linefeed | 2202 | text files and binary files. This is necessary because ordinary text |
| 2140 | (@sc{crlf}). Emacs expects just a newline character (a linefeed) between | 2203 | files on MS-DOS use a two character sequence between lines: |
| 2141 | lines. When Emacs reads or writes a text file on MS-DOS, it needs to | 2204 | carriage-return and linefeed (@sc{crlf}). Emacs expects just a newline |
| 2142 | convert the line separators. This means it needs to know which files | 2205 | character (a linefeed) between lines. When Emacs reads or writes a text |
| 2143 | are text files and which are binary. It makes this decision when | 2206 | file on MS-DOS, it needs to convert the line separators. This means it |
| 2144 | visiting a file, and records the decision in the variable | 2207 | needs to know which files are text files and which are binary. It makes |
| 2145 | @code{buffer-file-type} for use when the file is saved. | 2208 | this decision when visiting a file, and records the decision in the |
| 2209 | variable @code{buffer-file-type} for use when the file is saved. | ||
| 2146 | 2210 | ||
| 2147 | @xref{MS-DOS Subprocesses}, for a related feature for subprocesses. | 2211 | @xref{MS-DOS Subprocesses}, for a related feature for subprocesses. |
| 2148 | 2212 | ||