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 | |
| 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')
| -rw-r--r-- | doc/lispref/files.texi | 16 | ||||
| -rw-r--r-- | doc/lispref/minibuf.texi | 2 | ||||
| -rw-r--r-- | doc/misc/org.texi | 31 |
3 files changed, 26 insertions, 23 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 |
diff --git a/doc/misc/org.texi b/doc/misc/org.texi index e1de3087311..2d537946be0 100644 --- a/doc/misc/org.texi +++ b/doc/misc/org.texi | |||
| @@ -1040,8 +1040,8 @@ shown below. | |||
| 1040 | debug-on-quit nil) | 1040 | debug-on-quit nil) |
| 1041 | 1041 | ||
| 1042 | ;; add latest org-mode to load path | 1042 | ;; add latest org-mode to load path |
| 1043 | (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp")) | 1043 | (add-to-list 'load-path "/path/to/org-mode/lisp") |
| 1044 | (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t)) | 1044 | (add-to-list 'load-path "/path/to/org-mode/contrib/lisp" t) |
| 1045 | @end lisp | 1045 | @end lisp |
| 1046 | 1046 | ||
| 1047 | If an error occurs, a backtrace can be very useful (see below on how to | 1047 | If an error occurs, a backtrace can be very useful (see below on how to |
| @@ -16900,25 +16900,18 @@ The sample script shows batch processing of multiple files using | |||
| 16900 | 16900 | ||
| 16901 | @example | 16901 | @example |
| 16902 | #!/bin/sh | 16902 | #!/bin/sh |
| 16903 | # -*- mode: shell-script -*- | ||
| 16904 | # | ||
| 16905 | # tangle files with org-mode | 16903 | # tangle files with org-mode |
| 16906 | # | 16904 | # |
| 16907 | DIR=`pwd` | 16905 | emacs -Q --batch --eval " |
| 16908 | FILES="" | 16906 | (progn |
| 16909 | 16907 | (require 'ob-tangle) | |
| 16910 | # wrap each argument in the code required to call tangle on it | 16908 | (mapc (lambda (file) |
| 16911 | for i in $@@; do | 16909 | (save-current-buffer |
| 16912 | FILES="$FILES \"$i\"" | 16910 | (find-file file) |
| 16913 | done | 16911 | (org-babel-tangle) |
| 16914 | 16912 | (kill-buffer))) | |
| 16915 | emacs -Q --batch \ | 16913 | command-line-args-left)) |
| 16916 | --eval "(progn | 16914 | " "$@@" |
| 16917 | (require 'org)(require 'ob)(require 'ob-tangle) | ||
| 16918 | (mapc (lambda (file) | ||
| 16919 | (find-file (expand-file-name file \"$DIR\")) | ||
| 16920 | (org-babel-tangle) | ||
| 16921 | (kill-buffer)) '($FILES)))" 2>&1 |grep -i tangled | ||
| 16922 | @end example | 16915 | @end example |
| 16923 | 16916 | ||
| 16924 | @node Miscellaneous | 16917 | @node Miscellaneous |