diff options
| author | Paul Eggert | 2017-08-25 21:12:37 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-08-25 21:14:06 -0700 |
| commit | 05f9ffd53c65699e8de6cca4817b1f2dc2f63a79 (patch) | |
| tree | 84cb18218bf10ba8d614c28ecdcf3cd9e56b69e9 /doc/lispref | |
| parent | feecb66b6fe41c977b8e11b5f2d419c9544f42de (diff) | |
| download | emacs-05f9ffd53c65699e8de6cca4817b1f2dc2f63a79.tar.gz emacs-05f9ffd53c65699e8de6cca4817b1f2dc2f63a79.zip | |
Improve expand-file-name doc
* doc/lispref/files.texi (Relative File Names, Directory Names)
(File Name Expansion):
* doc/lispref/minibuf.texi (Reading File Names):
Document expand-file-name behavior with ~ more clearly
and accurately.
* doc/misc/org.texi (Batch execution): Simplify example
script so that it does not need expand-file-name and thus
will not mishandle file names with leading ~.
Diffstat (limited to 'doc/lispref')
| -rw-r--r-- | doc/lispref/files.texi | 16 | ||||
| -rw-r--r-- | doc/lispref/minibuf.texi | 2 |
2 files changed, 14 insertions, 4 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 60369236ff5..bb355f1ee35 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -2137,7 +2137,8 @@ file name, @code{nil} otherwise. | |||
| 2137 | @end example | 2137 | @end example |
| 2138 | @end defun | 2138 | @end defun |
| 2139 | 2139 | ||
| 2140 | Given a possibly relative file name, you can convert it to an | 2140 | Given a possibly relative file name, you can expand any |
| 2141 | leading @samp{~} and convert the result to an | ||
| 2141 | absolute name using @code{expand-file-name} (@pxref{File Name | 2142 | absolute name using @code{expand-file-name} (@pxref{File Name |
| 2142 | Expansion}). This function converts absolute file names to relative | 2143 | Expansion}). This function converts absolute file names to relative |
| 2143 | names: | 2144 | names: |
| @@ -2264,6 +2265,10 @@ might be nil (for example, from an element of @code{load-path}), use: | |||
| 2264 | (expand-file-name @var{relfile} @var{dirname}) | 2265 | (expand-file-name @var{relfile} @var{dirname}) |
| 2265 | @end example | 2266 | @end example |
| 2266 | 2267 | ||
| 2268 | However, @code{expand-file-name} expands leading @samp{~} in | ||
| 2269 | @var{relfile}, which may not be what you want. @xref{File Name | ||
| 2270 | Expansion}. | ||
| 2271 | |||
| 2267 | To convert a directory name to its abbreviation, use this | 2272 | To convert a directory name to its abbreviation, use this |
| 2268 | function: | 2273 | function: |
| 2269 | 2274 | ||
| @@ -2302,7 +2307,8 @@ and eliminating redundancies like @file{./} and @file{@var{name}/../}. | |||
| 2302 | @defun expand-file-name filename &optional directory | 2307 | @defun expand-file-name filename &optional directory |
| 2303 | This function converts @var{filename} to an absolute file name. If | 2308 | This function converts @var{filename} to an absolute file name. If |
| 2304 | @var{directory} is supplied, it is the default directory to start with | 2309 | @var{directory} is supplied, it is the default directory to start with |
| 2305 | if @var{filename} is relative. (The value of @var{directory} should | 2310 | if @var{filename} is relative and does not start with @samp{~}. |
| 2311 | (The value of @var{directory} should | ||
| 2306 | itself be an absolute directory name or directory file name; it may | 2312 | itself be an absolute directory name or directory file name; it may |
| 2307 | start with @samp{~}.) Otherwise, the current buffer's value of | 2313 | start with @samp{~}.) Otherwise, the current buffer's value of |
| 2308 | @code{default-directory} is used. For example: | 2314 | @code{default-directory} is used. For example: |
| @@ -2322,11 +2328,15 @@ start with @samp{~}.) Otherwise, the current buffer's value of | |||
| 2322 | @end group | 2328 | @end group |
| 2323 | @end example | 2329 | @end example |
| 2324 | 2330 | ||
| 2325 | If the part of the combined file name before the first slash is | 2331 | If the part of @var{filename} before the first slash is |
| 2326 | @samp{~}, it expands to the value of the @env{HOME} environment | 2332 | @samp{~}, it expands to the value of the @env{HOME} environment |
| 2327 | variable (usually your home directory). If the part before the first | 2333 | variable (usually your home directory). If the part before the first |
| 2328 | slash is @samp{~@var{user}} and if @var{user} is a valid login name, | 2334 | slash is @samp{~@var{user}} and if @var{user} is a valid login name, |
| 2329 | it expands to @var{user}'s home directory. | 2335 | it expands to @var{user}'s home directory. |
| 2336 | If you do not want this expansion for a relative @var{filename} that | ||
| 2337 | might begin with a literal @samp{~}, you can use @code{(concat | ||
| 2338 | (file-name-as-directory directory) filename)} instead of | ||
| 2339 | @code{(expand-file-name filename directory)}. | ||
| 2330 | 2340 | ||
| 2331 | Filenames containing @samp{.} or @samp{..} are simplified to their | 2341 | Filenames containing @samp{.} or @samp{..} are simplified to their |
| 2332 | canonical form: | 2342 | canonical form: |
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 81402552678..89dee847841 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi | |||
| @@ -1439,7 +1439,7 @@ platform-dependent. Here, we simply document the behavior when using | |||
| 1439 | the minibuffer. | 1439 | the minibuffer. |
| 1440 | 1440 | ||
| 1441 | @code{read-file-name} does not automatically expand the returned file | 1441 | @code{read-file-name} does not automatically expand the returned file |
| 1442 | name. You must call @code{expand-file-name} yourself if an absolute | 1442 | name. You can call @code{expand-file-name} yourself if an absolute |
| 1443 | file name is required. | 1443 | file name is required. |
| 1444 | 1444 | ||
| 1445 | The optional argument @var{require-match} has the same meaning as in | 1445 | The optional argument @var{require-match} has the same meaning as in |