From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel@gnu.org
Subject: load-path contains directories or directory names?
Date: Thu, 22 Oct 2015 23:26:54 -0500 [thread overview]
Message-ID: <86lhauus4x.fsf@stephe-leake.org> (raw)
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
next reply other threads:[~2015-10-23 4:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 4:26 Stephen Leake [this message]
2015-10-23 7:25 ` load-path contains directories or directory names? Eli Zaretskii
2015-10-23 14:01 ` Stephen Leake
2015-10-23 22:57 ` Michael Heerdegen
2015-10-24 1:00 ` John Wiegley
2015-10-24 21:46 ` Stephen Leake
2015-10-24 22:48 ` Michael Heerdegen
2015-10-25 18:39 ` Eli Zaretskii
2015-10-25 19:02 ` John Wiegley
2015-10-25 19:08 ` Eli Zaretskii
2015-10-25 19:12 ` John Wiegley
2015-10-25 21:58 ` Drew Adams
2015-10-26 13:27 ` Stephen Leake
2015-10-26 13:46 ` Stephen Leake
2015-10-26 16:29 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86lhauus4x.fsf@stephe-leake.org \
--to=stephen_leake@stephe-leake.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).