* multiple load-paths?
@ 2007-11-24 15:30 someusernamehere
2007-11-24 15:57 ` Juanma Barranquero
2007-11-24 16:05 ` Johan Bockgård
0 siblings, 2 replies; 5+ messages in thread
From: someusernamehere @ 2007-11-24 15:30 UTC (permalink / raw)
To: help-gnu-emacs
hey, I have in my .emacs 4 lines such as>
(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?
thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multiple load-paths?
2007-11-24 15:30 multiple load-paths? someusernamehere
@ 2007-11-24 15:57 ` Juanma Barranquero
2007-11-24 16:05 ` Johan Bockgård
1 sibling, 0 replies; 5+ messages in thread
From: Juanma Barranquero @ 2007-11-24 15:57 UTC (permalink / raw)
To: help-gnu-emacs
On Nov 24, 2007 4:30 PM, someusernamehere <someusernamehere@gmail.com> wrote:
> (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?
You could do
(dolist (dir '("lisp" "repos" "testing" "elisp"))
(push (expand-file-name (concat "~/" dir)) load-path))
About the "poshiness" of it, that's you call :-)
Juanma
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multiple load-paths?
2007-11-24 15:30 multiple load-paths? someusernamehere
2007-11-24 15:57 ` Juanma Barranquero
@ 2007-11-24 16:05 ` Johan Bockgård
2007-12-05 9:58 ` Mike Mattie
1 sibling, 1 reply; 5+ messages in thread
From: Johan Bockgård @ 2007-11-24 16:05 UTC (permalink / raw)
To: help-gnu-emacs
someusernamehere <someusernamehere@gmail.com> 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.
--
Johan Bockgård
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multiple load-paths?
2007-11-24 16:05 ` Johan Bockgård
@ 2007-12-05 9:58 ` Mike Mattie
2007-12-05 10:57 ` Sebastian Tennant
0 siblings, 1 reply; 5+ messages in thread
From: Mike Mattie @ 2007-12-05 9:58 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1546 bytes --]
On Sat, 24 Nov 2007 17:05:15 +0100
bojohan+news@dd.chalmers.se (Johan Bockgård) wrote:
> someusernamehere <someusernamehere@gmail.com> 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.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multiple load-paths?
2007-12-05 9:58 ` Mike Mattie
@ 2007-12-05 10:57 ` Sebastian Tennant
0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Tennant @ 2007-12-05 10:57 UTC (permalink / raw)
To: help-gnu-emacs
Quoth Mike Mattie <codermattie@gmail.com>:
> On Sat, 24 Nov 2007 17:05:15 +0100
> bojohan+news@dd.chalmers.se (Johan Bockgård) wrote:
>
>> someusernamehere <someusernamehere@gmail.com> 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
time:
;;; this is cleaner
(defun shell-command-to-list (str) (split-string (shell-command-to-string str)))
;;; prepend $el/lib/pre (plus subdirs) to load-path
(mapc (lambda (i) (add-to-list 'load-path i))
(remove-if
(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
(remove-if
(lambda (f) (not (file-accessible-directory-p f)))
(shell-command-to-list "find ~/elisp/lib/app -type d -o -type l")))
Hope this helps.
Sebastian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-12-05 10:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-24 15:30 multiple load-paths? someusernamehere
2007-11-24 15:57 ` Juanma Barranquero
2007-11-24 16:05 ` Johan Bockgård
2007-12-05 9:58 ` Mike Mattie
2007-12-05 10:57 ` Sebastian Tennant
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).