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: load-path contains directories or directory names? Date: Thu, 22 Oct 2015 23:26:54 -0500 Message-ID: <86lhauus4x.fsf@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445574487 5979 80.91.229.3 (23 Oct 2015 04:28:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Oct 2015 04:28:07 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 23 06:27:51 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 1ZpTxB-0004NU-Uu for ged-emacs-devel@m.gmane.org; Fri, 23 Oct 2015 06:27:46 +0200 Original-Received: from localhost ([::1]:35834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpTxA-0000mM-TS for ged-emacs-devel@m.gmane.org; Fri, 23 Oct 2015 00:27:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpTww-0000mH-CV for emacs-devel@gnu.org; Fri, 23 Oct 2015 00:27:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpTws-0004wR-Uq for emacs-devel@gnu.org; Fri, 23 Oct 2015 00:27:30 -0400 Original-Received: from gproxy6-pub.mail.unifiedlayer.com ([67.222.39.168]:46932) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1ZpTws-0004wF-Nj for emacs-devel@gnu.org; Fri, 23 Oct 2015 00:27:26 -0400 Original-Received: (qmail 24917 invoked by uid 0); 23 Oct 2015 04:27:18 -0000 Original-Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy6.mail.unifiedlayer.com with SMTP; 23 Oct 2015 04:27:18 -0000 Original-Received: from host114.hostmonster.com ([74.220.207.114]) by cmgw3 with id YaTB1r0142UdiVW01aTEPB; Fri, 23 Oct 2015 04:27:17 -0600 X-Authority-Analysis: v=2.1 cv=Zs1+dbLG 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=OPopVuaPwhujRvB6ubgA:9 Original-Received: from [76.218.37.33] (port=54588 helo=TAKVER2) by host114.hostmonster.com with esmtpa (Exim 4.84) (envelope-from ) id 1ZpTwf-00076U-AH for emacs-devel@gnu.org; Thu, 22 Oct 2015 22:27:13 -0600 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: 67.222.39.168 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:192448 Archived-At: As part of the file completion code I'm working on, I need to build an absolute file name from a directory and a non-directory. That's either: (concat dir name) or (concat dir "/" name) depending on whether `dir' is a directory (ends in '/') or a directory name. Here `dir' is taken from load-path, or a similar user-provided path. The doc string for `load-path' says it consists of "directory names". In emacs -Q, `load-path' indeed has no elements that end in '/'. However, after (package-initialize), `load-path' had elements that end in '/'. This comes from package-autoload-ensure-default-file in package.el, which adds lines like this to each package's autoload: "(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))\n" Is this a bug, or should code that uses `load-path' tolerate this? It's easy to do: (concat (file-name-as-directory dir) name) but I'd rather avoid redundant code if possible. I discovered this when I added a cl-assert to check the precondition that the path contains only directory names. On the other hand, since `load-path' can be modified by users, perhaps code must be tolerant anyway. -- -- Stephe