diff options
| author | Stephen Leake | 2015-10-26 14:38:59 -0500 |
|---|---|---|
| committer | Stephen Leake | 2015-10-26 14:40:34 -0500 |
| commit | 93dba9c2d7fd511fd7deba2e172cd54a73314d0b (patch) | |
| tree | d426aa5ee5f17f6051961d1bc318042e0c902fb9 | |
| parent | c9fb8954bc72c9e362f7bf71b3457882887cb182 (diff) | |
| download | emacs-93dba9c2d7fd511fd7deba2e172cd54a73314d0b.tar.gz emacs-93dba9c2d7fd511fd7deba2e172cd54a73314d0b.zip | |
Clarify that load-path contents should be directory file names
* doc/lispref/files.texi (Directory Names): Define and use "directory
file name". Recommend `expand-file-name'.
* src/lread.c (load-path): Fix doc string; elements are directory file
names.
| -rw-r--r-- | doc/lispref/files.texi | 50 | ||||
| -rw-r--r-- | src/lread.c | 6 |
2 files changed, 34 insertions, 22 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index ca8abe54ace..65a97a46699 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -2038,32 +2038,35 @@ forward slash (@samp{/}) character. | |||
| 2038 | @node Directory Names | 2038 | @node Directory Names |
| 2039 | @subsection Directory Names | 2039 | @subsection Directory Names |
| 2040 | @cindex directory name | 2040 | @cindex directory name |
| 2041 | @cindex directory file name | ||
| 2041 | @cindex file name of directory | 2042 | @cindex file name of directory |
| 2042 | 2043 | ||
| 2043 | A @dfn{directory name} is the name of a directory. A directory is | 2044 | A @dfn{directory name} is the name of a directory. A directory is |
| 2044 | actually a kind of file, so it has a file name, which is related to | 2045 | actually a kind of file, so it has a file name (called the |
| 2045 | the directory name but not identical to it. (This is not quite the | 2046 | @dfn{directory file name}, which is related to the directory name but |
| 2046 | same as the usual Unix terminology.) These two different names for | 2047 | not identical to it. (This is not quite the same as the usual Unix |
| 2047 | the same entity are related by a syntactic transformation. On GNU and | 2048 | terminology.) These two different names for the same entity are |
| 2048 | Unix systems, this is simple: a directory name ends in a slash, | 2049 | related by a syntactic transformation. On GNU and Unix systems, this |
| 2049 | whereas the directory's name as a file lacks that slash. On MS-DOS | 2050 | is simple: a directory name ends in a slash, whereas the directory |
| 2050 | the relationship is more complicated. | 2051 | file name lacks that slash. On MS-DOS the relationship is more |
| 2051 | 2052 | complicated. | |
| 2052 | The difference between a directory name and its name as a file is | 2053 | |
| 2054 | The difference between directory name and directory file name is | ||
| 2053 | subtle but crucial. When an Emacs variable or function argument is | 2055 | subtle but crucial. When an Emacs variable or function argument is |
| 2054 | described as being a directory name, a file name of a directory is not | 2056 | described as being a directory name, a directory file name is not |
| 2055 | acceptable. When @code{file-name-directory} returns a string, that is | 2057 | acceptable. When @code{file-name-directory} returns a string, that is |
| 2056 | always a directory name. | 2058 | always a directory name. |
| 2057 | 2059 | ||
| 2058 | The following two functions convert between directory names and file | 2060 | The following two functions convert between directory names and |
| 2059 | names. They do nothing special with environment variable substitutions | 2061 | directory file names. They do nothing special with environment |
| 2060 | such as @samp{$HOME}, and the constructs @samp{~}, @samp{.} and @samp{..}. | 2062 | variable substitutions such as @samp{$HOME}, and the constructs |
| 2063 | @samp{~}, @samp{.} and @samp{..}. | ||
| 2061 | 2064 | ||
| 2062 | @defun file-name-as-directory filename | 2065 | @defun file-name-as-directory filename |
| 2063 | This function returns a string representing @var{filename} in a form | 2066 | This function returns a string representing @var{filename} in a form |
| 2064 | that the operating system will interpret as the name of a directory. On | 2067 | that the operating system will interpret as the name of a directory (a |
| 2065 | most systems, this means appending a slash to the string (if it does not | 2068 | directory name). On most systems, this means appending a slash to the |
| 2066 | already end in one). | 2069 | string (if it does not already end in one). |
| 2067 | 2070 | ||
| 2068 | @example | 2071 | @example |
| 2069 | @group | 2072 | @group |
| @@ -2074,10 +2077,10 @@ already end in one). | |||
| 2074 | @end defun | 2077 | @end defun |
| 2075 | 2078 | ||
| 2076 | @defun directory-file-name dirname | 2079 | @defun directory-file-name dirname |
| 2077 | This function returns a string representing @var{dirname} in a form that | 2080 | This function returns a string representing @var{dirname} in a form |
| 2078 | the operating system will interpret as the name of a file. On most | 2081 | that the operating system will interpret as the name of a file (a |
| 2079 | systems, this means removing the final slash (or backslash) from the | 2082 | directory file name). On most systems, this means removing the final |
| 2080 | string. | 2083 | slash (or backslash) from the string. |
| 2081 | 2084 | ||
| 2082 | @example | 2085 | @example |
| 2083 | @group | 2086 | @group |
| @@ -2119,6 +2122,13 @@ Don't try concatenating a slash by hand, as in | |||
| 2119 | because this is not portable. Always use | 2122 | because this is not portable. Always use |
| 2120 | @code{file-name-as-directory}. | 2123 | @code{file-name-as-directory}. |
| 2121 | 2124 | ||
| 2125 | To avoid the issues mentioned above, or if the @var{dirname} value | ||
| 2126 | might be nil (for example, from an element of @code{load-path}), use: | ||
| 2127 | |||
| 2128 | @example | ||
| 2129 | (expand-file-name @var{relfile} @var{dirname}) | ||
| 2130 | @end example | ||
| 2131 | |||
| 2122 | To convert a directory name to its abbreviation, use this | 2132 | To convert a directory name to its abbreviation, use this |
| 2123 | function: | 2133 | function: |
| 2124 | 2134 | ||
diff --git a/src/lread.c b/src/lread.c index a98fa6199f1..1119f3fdfd4 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -4479,8 +4479,10 @@ were read in. */); | |||
| 4479 | 4479 | ||
| 4480 | DEFVAR_LISP ("load-path", Vload_path, | 4480 | DEFVAR_LISP ("load-path", Vload_path, |
| 4481 | doc: /* List of directories to search for files to load. | 4481 | doc: /* List of directories to search for files to load. |
| 4482 | Each element is a string (directory name) or nil (meaning `default-directory'). | 4482 | Each element is a string (directory file name) or nil (meaning |
| 4483 | Initialized during startup as described in Info node `(elisp)Library Search'. */); | 4483 | `default-directory'). Initialized during startup as described in Info |
| 4484 | node `(elisp)Library Search'. Use `directory-file-name' when adding items | ||
| 4485 | to this path. */); | ||
| 4484 | 4486 | ||
| 4485 | DEFVAR_LISP ("load-suffixes", Vload_suffixes, | 4487 | DEFVAR_LISP ("load-suffixes", Vload_suffixes, |
| 4486 | doc: /* List of suffixes for (compiled or source) Emacs Lisp files. | 4488 | doc: /* List of suffixes for (compiled or source) Emacs Lisp files. |