From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastian Tennant Newsgroups: gmane.emacs.help Subject: Re: multiple load-paths? Date: Wed, 05 Dec 2007 12:57:53 +0200 Message-ID: <87hcixwgr2.fsf@moley.moleskin.org> References: <20071205015813.37b00664@reforged> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1196852442 32253 80.91.229.12 (5 Dec 2007 11:00:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Dec 2007 11:00:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 05 12:00:52 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Izrzn-0000Ib-DH for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Dec 2007 12:00:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IzrzW-0003xa-ST for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Dec 2007 06:00:34 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IzrzE-0003x0-Au for help-gnu-emacs@gnu.org; Wed, 05 Dec 2007 06:00:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IzrzC-0003wa-UW for help-gnu-emacs@gnu.org; Wed, 05 Dec 2007 06:00:15 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IzrzC-0003wX-KF for help-gnu-emacs@gnu.org; Wed, 05 Dec 2007 06:00:14 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IzrzB-0006T3-VC for help-gnu-emacs@gnu.org; Wed, 05 Dec 2007 06:00:14 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IzryE-0004dc-0v for help-gnu-emacs@gnu.org; Wed, 05 Dec 2007 10:59:14 +0000 Original-Received: from 85.105.17.65 ([85.105.17.65]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Dec 2007 10:59:14 +0000 Original-Received: from sebyte by 85.105.17.65 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Dec 2007 10:59:14 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 69 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 85.105.17.65 User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:xCcsdxCOp9eAqz1cGWuB7Z1nAPI= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49838 Archived-At: Quoth Mike Mattie : > On Sat, 24 Nov 2007 17:05:15 +0100 > bojohan+news@dd.chalmers.se (Johan Bockgård) wrote: > >> someusernamehere 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