[Top][All Lists]

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

Re: multiple load-paths?

From: Sebastian Tennant
Subject: Re: multiple load-paths?
Date: Wed, 05 Dec 2007 12:57:53 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

Quoth Mike Mattie <address@hidden>:
> On Sat, 24 Nov 2007 17:05:15 +0100
> address@hidden (Johan Bockgård) wrote:
>> someusernamehere <address@hidden> writes:
>> > (setq load-path (cons (expand-file-name "~/lisp") load-path))
>> > (setq load-path (cons (expand-file-name "~/repos") load-path))
>> > (setq load-path (cons (expand-file-name "~/testing") load-path))
>> > (setq load-path (cons (expand-file-name "~/elisp") load-path))
>> >
>> > there is a way to do this more "posh" ?, I mean may be in one line o
>> > something similar?
>> I'd prefer
>>     (add-to-list 'load-path "~/lisp")
>>     (add-to-list 'load-path "~/repos")
>>     (add-to-list 'load-path "~/testing")
>>     (add-to-list 'load-path "~/elisp")
>> (add-to-list is shorter and avoids adding duplicates to load-path if
>> .emacs is reloaded.  expand-file-name shouldn't be necessary)
>> You could use a loop, but having one line per entry is more
>> grep-friendly. 
> this is my flavor. The version above is superior in that it filters dups, but 
> I don't see that
> as a serious problem for small cases.
> (setq load-path
>   (append
>     ;; overide distributed elisp with local modifications by
>     ;; inserting a "local" directory at the beginning of the
>     ;; load list
>     (cons localized-source-dir load-path)
>     ;; add the extras to the end of the list.
>     (list extras-source-dir)
>     ))
> in this version anything you want to override emacs goes in 
> localized-source-dir, while anything that is an add-on
> can simply go in the list at the end.

And here's my offering.  I've created two directories, under ~/elisp;
one called pre/ and one called app/.  Any directories (or links to
directories) I create in these subdirectories are prepended or appended
to my load path accordingly, and it all happens dynamically at start

 ;;; this is cleaner
 (defun shell-command-to-list (str) (split-string (shell-command-to-string 

 ;;; prepend $el/lib/pre (plus subdirs) to load-path
 (mapc (lambda (i) (add-to-list 'load-path i))
        (lambda (f) (not (file-accessible-directory-p f)))
        (shell-command-to-list "find ~/elisp/lib/pre -type d -o -type l")))

 ;;; append $el/lib/app (plus subdirs) to load-path
 (mapc (lambda (i) (add-to-list 'load-path i t))  ;note the 't', for appending
        (lambda (f) (not (file-accessible-directory-p f)))
        (shell-command-to-list "find ~/elisp/lib/app -type d -o -type l")))

Hope this helps.


reply via email to

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