emacs: Handling external dependencies
Tomi Ollila
tomi.ollila at iki.fi
Wed Nov 14 01:43:00 PST 2012
On Wed, Nov 14 2012, Ethan Glasser-Camp <ethan.glasser.camp at gmail.com> wrote:
> Damien Cassou <damien.cassou at gmail.com> writes:
>
>> 4) distribute the dependency with the rest of notmuch (in a separate
>> "fallback-libs/" directory) and load it only when requiring the
>> library with the standard load-path does not work. Jonas Bernoulli
>> gave me a way to do that:
>>
>> ,----
>> | (or (require 'THE-LIB nil t)
>> | (let ((load-path
>> | (cons (expand-file-name
>> | "fallback-libs"
>> | (file-name-directory (or load-file-name buffer-file-name)))
>> | load-path)))
>> | (require 'THE-LIB)))
>> `----
>>
>> What do you think?
>
> Why not just append it to the *end* of load-path? Then it won't shadow
> anything.
The scope of the load-path change is for just this one require -- if
header-button required some other modules, the fallback-libs version
should be preferred (in case exists) over loading elsewehere in this case
header-button is loaded from fallback-libs.
But, maybe we should be more spesific there and use something like:
(let ((dir (expand-file-name
"notmuch-deps"
(file-name-directory (or load-file-name buffer-file-name)))))
(unless (require 'header-button (concat dir "/header-button.elc") t)
(require 'header-button (concat dir "/header-button.el") nil)))
(if we ever agree to do either kind of loading...)
> Ethan
Tomi
More information about the notmuch
mailing list