From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: user-controlled load-path extension: load-dir Date: Wed, 16 Mar 2011 15:08:56 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87lj0eu8tj.fsf@lifelogs.com> References: <87oc5kax8l.fsf@stupidchicken.com> <8739mwnj3v.fsf@lifelogs.com> <87oc5kjarb.fsf@stupidchicken.com> <87pqprw3px.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1300306179 12752 80.91.229.12 (16 Mar 2011 20:09:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 16 Mar 2011 20:09:39 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 16 21:09:35 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 1Pzx2B-0001jG-Ta for ged-emacs-devel@m.gmane.org; Wed, 16 Mar 2011 21:09:32 +0100 Original-Received: from localhost ([127.0.0.1]:53961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pzx28-00080K-6H for ged-emacs-devel@m.gmane.org; Wed, 16 Mar 2011 16:09:28 -0400 Original-Received: from [140.186.70.92] (port=34407 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pzx1t-0007s7-OF for emacs-devel@gnu.org; Wed, 16 Mar 2011 16:09:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pzx1s-00030V-26 for emacs-devel@gnu.org; Wed, 16 Mar 2011 16:09:13 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:42285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pzx1r-0002zK-ON for emacs-devel@gnu.org; Wed, 16 Mar 2011 16:09:12 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pzx1o-0001Y9-GI for emacs-devel@gnu.org; Wed, 16 Mar 2011 21:09:08 +0100 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 16 Mar 2011 21:09:08 +0100 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 16 Mar 2011 21:09:08 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 135 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110014 (No Gnus v0.14) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:BKWs1sS0tW2VsubGZrJJCGKbCZc= 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:137313 Archived-At: --=-=-= Content-Type: text/plain On Wed, 16 Mar 2011 11:43:09 -0400 Stefan Monnier wrote: >> Chong, Stefan, can I take this and the lack of new posts in this thread >> to mean it's OK to commit an experimental implementation of the load-dir >> idea? SM> Adding a load-directory function is OK, yes. But please send the SM> corresponding patch for review first. First, the library. I'm not sure about the name (`user-load-dirs-load' sounds terrible) and I've omitted the byte-compilation stuff that was in Ben Key's code. It's a full rewrite of his code, which makes copyright assignments unnecessary so we can speed up the process. Do we want to support loading byte-compiled files? Is the messaging too intrusive? Also I don't trap errors. I think that's the right approach. These are not packages, they are like a part of your .emacs and should be treated accordingly. This is also why I'm sort of avoiding the byte compilation support, although it's pretty easy to add. Thanks Ted --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=user-load-dirs.el Content-Transfer-Encoding: quoted-printable ;;; user-load-dirs.el --- load all Emacs Lisp files in given directories ;; Copyright (C) 2011 Teodor Zlatanov ;; Author: Teodor Zlatanov ;; With-Help-From: Ben Key , Evans Winner ;; Keywords: lisp, files, convenience ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; This library will load all Lisp files found in the `user-load-dirs' ;; variable. ;; Normal usage: ;; (setq user-load-dirs-list '("~/mystuff")) ;; or Customize it ;; you may also want to set user-load-dirs-recursive ;; (require 'user-load-dirs) ;; this may be automatic in Emacs at some point but you still need to ;; do it manually if you add files ;; M-x user-load-dirs-load ;;; Code: (eval-when-compile (require 'cl)) (defgroup user-load-dirs nil "Automatically load all Emacs Lisp files in given directories." :group 'initialization) (defcustom user-load-dirs-recursive nil "List of directories to load." :group 'user-load-dirs :type 'boolean) (defcustom user-load-dirs-list nil "List of directories to load." :group 'user-load-dirs :type '(repeat directory)) (defun user-load-dirs-load () "Load all Emacs Lisp files in `user-load-dirs-list'. Will not load a file twice (use `user-load-dirs-reload' for that). Recurses into subdirectories if `user-load-dirs-recursive' is t." (interactive) (mapcar 'user-load-dirs-one user-load-dirs-list)) (defun user-load-dirs-reload () "Load all Emacs Lisp files in `user-load-dirs-list'. Clears the list of loaded files and just calls `user-load-dirs-load'." (interactive) (setq user-load-dirs-loaded nil) (user-load-dirs-load)) (defvar user-load-dirs-loaded nil "List of already loaded files.") (defun user-load-dirs-clear () "Load all Emacs Lisp files in `user-load-dirs-list'. Recurses into subdirectories if `user-load-dirs-recursive' is t." (interactive) (mapcar 'user-load-dirs-one user-load-dirs-list)) (defun user-load-dirs-one (dir) "Load all Emacs Lisp files in DIR. Recurses into subdirectories if `user-load-dirs-recursive' is t." (message "Loading Emacs Lisp code from %s" dir) (dolist (f (and (file-exists-p dir) (file-directory-p dir) (directory-files dir t "\\.el\\'"))) (when (not (file-directory-p f)) (if (member f user-load-dirs-loaded) (message "Skipping %s, it's already loaded." f) (message "Loading %s..." f) (load f) (message "Loading %s... done" f) (add-to-list 'user-load-dirs-loaded f)))) (when user-load-dirs-recursive (dolist (f (directory-files dir t)) (when (file-directory-p f) (user-load-dirs-one f))))) (provide 'user-load-dirs) ;;; user-load-dirs.el ends here --=-=-=--