aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
authorPaul Eggert2017-08-25 21:12:37 -0700
committerPaul Eggert2017-08-25 21:14:06 -0700
commit05f9ffd53c65699e8de6cca4817b1f2dc2f63a79 (patch)
tree84cb18218bf10ba8d614c28ecdcf3cd9e56b69e9 /doc/lispref
parentfeecb66b6fe41c977b8e11b5f2d419c9544f42de (diff)
downloademacs-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.texi16
-rw-r--r--doc/lispref/minibuf.texi2
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
2141leading @samp{~} and convert the result to an
2141absolute name using @code{expand-file-name} (@pxref{File Name 2142absolute name using @code{expand-file-name} (@pxref{File Name
2142Expansion}). This function converts absolute file names to relative 2143Expansion}). This function converts absolute file names to relative
2143names: 2144names:
@@ -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
2268However, @code{expand-file-name} expands leading @samp{~} in
2269@var{relfile}, which may not be what you want. @xref{File Name
2270Expansion}.
2271
2267 To convert a directory name to its abbreviation, use this 2272 To convert a directory name to its abbreviation, use this
2268function: 2273function:
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
2303This function converts @var{filename} to an absolute file name. If 2308This 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
2305if @var{filename} is relative. (The value of @var{directory} should 2310if @var{filename} is relative and does not start with @samp{~}.
2311(The value of @var{directory} should
2306itself be an absolute directory name or directory file name; it may 2312itself be an absolute directory name or directory file name; it may
2307start with @samp{~}.) Otherwise, the current buffer's value of 2313start 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
2325If the part of the combined file name before the first slash is 2331If 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
2327variable (usually your home directory). If the part before the first 2333variable (usually your home directory). If the part before the first
2328slash is @samp{~@var{user}} and if @var{user} is a valid login name, 2334slash is @samp{~@var{user}} and if @var{user} is a valid login name,
2329it expands to @var{user}'s home directory. 2335it expands to @var{user}'s home directory.
2336If you do not want this expansion for a relative @var{filename} that
2337might 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
2331Filenames containing @samp{.} or @samp{..} are simplified to their 2341Filenames containing @samp{.} or @samp{..} are simplified to their
2332canonical form: 2342canonical 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
1439the minibuffer. 1439the 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
1442name. You must call @code{expand-file-name} yourself if an absolute 1442name. You can call @code{expand-file-name} yourself if an absolute
1443file name is required. 1443file name is required.
1444 1444
1445The optional argument @var{require-match} has the same meaning as in 1445The optional argument @var{require-match} has the same meaning as in