From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Evans Winner Newsgroups: gmane.emacs.devel Subject: Re: user-controlled load-path extension: load-dir Date: Tue, 08 Mar 2011 02:58:03 -0700 Message-ID: <87tyfeq6hg.fsf@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1299578469 23863 80.91.229.12 (8 Mar 2011 10:01:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 8 Mar 2011 10:01:09 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 08 11:01:05 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pwtiz-0001rV-3x for ged-emacs-devel@m.gmane.org; Tue, 08 Mar 2011 11:01:05 +0100 Original-Received: from localhost ([127.0.0.1]:50173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pwtiw-0007P5-Sa for ged-emacs-devel@m.gmane.org; Tue, 08 Mar 2011 05:01:03 -0500 Original-Received: from [140.186.70.92] (port=36052 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pwti3-00072P-Tg for emacs-devel@gnu.org; Tue, 08 Mar 2011 05:00:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pwti1-0007PI-VI for emacs-devel@gnu.org; Tue, 08 Mar 2011 05:00:06 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:60165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pwti1-0007P8-H0 for emacs-devel@gnu.org; Tue, 08 Mar 2011 05:00:05 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pwti0-0001R9-01 for emacs-devel@gnu.org; Tue, 08 Mar 2011 11:00:04 +0100 Original-Received: from 67.42.142.120 ([67.42.142.120]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 08 Mar 2011 11:00:03 +0100 Original-Received: from ego111 by 67.42.142.120 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 08 Mar 2011 11:00:03 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 29 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 67.42.142.120 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:hjEmT7ZvhxZAzqUauf4tzQ10b3s= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:136882 Archived-At: For what it's worth, this is the thing I have in my .emacs. It does what I want it to, which is just to allow me to break my .emacs into various not-excessively-long files organized by subject, like email config, org-mode config and so-forth. It's not very well tested, and I know that once or twice I have gotten some kind of symlink to nowhere left in that directory when a remote emacsclient session dies (at least I think that's the cause) -- and then the result is a file that ends in .el, but that can't be loaded and halts the init process. Anyway, for what it's worth. This is the sort of functionality I expected when I heard about the ~/.emacs.d/ concept, and was surprised when that's not what it was. (defun load-dir (directory &optional recurse) "Load all Emacs Lisp files in DIRECTORY. If RECURSE is non-nil, recursively load all such files in all subdirectories." (interactive "D") (dolist (file (directory-files (expand-file-name directory) t directory-files-no-dot-files-regexp) nil) (cond ((and recurse (file-directory-p file)) (when recurse (load-dir file))) ((string-match "\\.el$\\|\\.elc$" file) (load-library (file-name-sans-extension file))))))