unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* load-path contains directories or directory names?
@ 2015-10-23  4:26 Stephen Leake
  2015-10-23  7:25 ` Eli Zaretskii
  2015-10-23 22:57 ` Michael Heerdegen
  0 siblings, 2 replies; 15+ messages in thread
From: Stephen Leake @ 2015-10-23  4:26 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-10-26 16:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-23  4:26 load-path contains directories or directory names? Stephen Leake
2015-10-23  7:25 ` 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

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).