emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

load-path contains directories or directory names?


From: Stephen Leake
Subject: load-path contains directories or directory names?
Date: Thu, 22 Oct 2015 23:26:54 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]