From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 4d3a595: `load-path' should contain only directory names Date: Mon, 26 Oct 2015 08:19:25 -0500 Message-ID: <86d1w1ahsy.fsf@stephe-leake.org> References: <20151023135532.11512.53356@vcs.savannah.gnu.org> <83mvv8wejc.fsf@gnu.org> <86bnboeymw.fsf@stephe-leake.org> <83wpuadc9k.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1445865627 23260 80.91.229.3 (26 Oct 2015 13:20:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Oct 2015 13:20:27 +0000 (UTC) Cc: monnier@IRO.UMontreal.CA, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 26 14:20:16 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zqhh8-0005Dj-Sz for ged-emacs-devel@m.gmane.org; Mon, 26 Oct 2015 14:20:15 +0100 Original-Received: from localhost ([::1]:52881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqhh8-0007xa-6N for ged-emacs-devel@m.gmane.org; Mon, 26 Oct 2015 09:20:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqhgz-0007sp-C7 for emacs-devel@gnu.org; Mon, 26 Oct 2015 09:20:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zqhgu-000728-FT for emacs-devel@gnu.org; Mon, 26 Oct 2015 09:20:05 -0400 Original-Received: from gproxy2-pub.mail.unifiedlayer.com ([69.89.18.3]:37746) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Zqhgu-00071y-7v for emacs-devel@gnu.org; Mon, 26 Oct 2015 09:20:00 -0400 Original-Received: (qmail 6415 invoked by uid 0); 26 Oct 2015 13:19:50 -0000 Original-Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy2.mail.unifiedlayer.com with SMTP; 26 Oct 2015 13:19:50 -0000 Original-Received: from host114.hostmonster.com ([74.220.207.114]) by cmgw2 with id ZpKY1r00S2UdiVW01pKb7S; Mon, 26 Oct 2015 07:19:48 -0600 X-Authority-Analysis: v=2.1 cv=Jv9i8qIC c=1 sm=1 tr=0 a=CQdxDb2CKd3SRg4I0/XZPQ==:117 a=CQdxDb2CKd3SRg4I0/XZPQ==:17 a=DsvgjBjRAAAA:8 a=f5113yIGAAAA:8 a=9i_RQKNPAAAA:8 a=hEr_IkYJT6EA:10 a=x_XPkuGwIRMA:10 a=5lJygRwiOn0A:10 a=mDV3o1hIAAAA:8 a=jbikZ1ZLvffpudwAlSoA:9 a=3nJHBsc8QKp4hvcWipAA:9 Original-Received: from [76.218.37.33] (port=58555 helo=TAKVER2) by host114.hostmonster.com with esmtpa (Exim 4.84) (envelope-from ) id 1ZqhgT-00024l-PX; Mon, 26 Oct 2015 07:19:33 -0600 In-Reply-To: <83wpuadc9k.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 25 Oct 2015 20:38:31 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) X-Identified-User: {2442:host114.hostmonster.com:stephele:stephe-leake.org} {sentby:smtp auth 76.218.37.33 authed with stephen_leake@stephe-leake.org} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 69.89.18.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:192651 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Let's say "directory file name" in the doc string of 'load-path', > since we've been doing that since time immemoriam. See attached patch; if approved, I'll push it. > > Yes, and also a reference to 'directory-file-name' would be useful > here. Added "Use `directory-file-name' when adding items to this path." >> And the info node should define "directory file name". > > Yup. Patches welcome, thanks in advance. Using "directory file name" consistently in that section makes it cleaner, I think; see patch. >> However, there is one more quirk; `default-directory' does end in a >> slash, so having nil mean that in `load-path' is inconsistent. Should >> that then be: >> >> ... or nil (meaning (directory-file-name default-directory)). >> >> ? > > I don't think this subtlety is relevant. The issue at hand is the > _form_, not the _semantics_. As far as the form is concerned, nil > doesn't end in a slash, and you cannot use it in 'concat' for > generating a file name with leading directories anyway; you must use > 'expand-file-name', which already does TRT. I added the suggestion to use `expand-file-name' in the info section. It might make sense to suggest only that; I'm not clear if there is a speed difference, but it's probably negligible. -- -- Stephe --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=dirnames.patch diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index ca8abe5..61a00cd 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -2041,29 +2041,31 @@ forward slash (@samp{/}) character. @cindex file name of directory A @dfn{directory name} is the name of a directory. A directory is -actually a kind of file, so it has a file name, which is related to -the directory name but not identical to it. (This is not quite the -same as the usual Unix terminology.) These two different names for -the same entity are related by a syntactic transformation. On GNU and -Unix systems, this is simple: a directory name ends in a slash, -whereas the directory's name as a file lacks that slash. On MS-DOS -the relationship is more complicated. - - The difference between a directory name and its name as a file is +actually a kind of file, so it has a file name (called the +@dfn{directory file name}, which is related to the directory name but +not identical to it. (This is not quite the same as the usual Unix +terminology.) These two different names for the same entity are +related by a syntactic transformation. On GNU and Unix systems, this +is simple: a directory name ends in a slash, whereas the directory +file name lacks that slash. On MS-DOS the relationship is more +complicated. + + The difference between directory name and directory file name is subtle but crucial. When an Emacs variable or function argument is -described as being a directory name, a file name of a directory is not +described as being a directory name, a directory file name is not acceptable. When @code{file-name-directory} returns a string, that is always a directory name. - The following two functions convert between directory names and file -names. They do nothing special with environment variable substitutions -such as @samp{$HOME}, and the constructs @samp{~}, @samp{.} and @samp{..}. + The following two functions convert between directory names and +directory file names. They do nothing special with environment +variable substitutions such as @samp{$HOME}, and the constructs +@samp{~}, @samp{.} and @samp{..}. @defun file-name-as-directory filename This function returns a string representing @var{filename} in a form -that the operating system will interpret as the name of a directory. On -most systems, this means appending a slash to the string (if it does not -already end in one). +that the operating system will interpret as the name of a directory (a +directory name). On most systems, this means appending a slash to the +string (if it does not already end in one). @example @group @@ -2074,10 +2076,10 @@ already end in one). @end defun @defun directory-file-name dirname -This function returns a string representing @var{dirname} in a form that -the operating system will interpret as the name of a file. On most -systems, this means removing the final slash (or backslash) from the -string. +This function returns a string representing @var{dirname} in a form +that the operating system will interpret as the name of a file (a +directory file name). On most systems, this means removing the final +slash (or backslash) from the string. @example @group @@ -2119,6 +2121,13 @@ Don't try concatenating a slash by hand, as in because this is not portable. Always use @code{file-name-as-directory}. + To avoid the issues mentioned above, or if the @var{dirname} value +might be nil (for example, from an element of @var{load-path}), use: + +@example +(expand-file-name @var{relfile} @var{dirname}) +@end example + To convert a directory name to its abbreviation, use this function: --- a/src/lread.c +++ b/src/lread.c @@ -4479,8 +4479,9 @@ were read in. */); DEFVAR_LISP ("load-path", Vload_path, doc: /* List of directories to search for files to load. -Each element is a string (directory name) or nil (meaning `default-directory'). -Initialized during startup as described in Info node `(elisp)Library Search'. */); +Each element is a string (directory file name) or nil (meaning `default-directory'). +Initialized during startup as described in Info node `(elisp)Library Search'. +Use `directory-file-name' when adding items to this path. */); DEFVAR_LISP ("load-suffixes", Vload_suffixes, doc: /* List of suffixes for (compiled or source) Emacs Lisp files. --=-=-=--