[Top][All Lists]

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

Re: user-controlled load-path extension: load-dir

From: Evans Winner
Subject: Re: user-controlled load-path extension: load-dir
Date: Tue, 08 Mar 2011 02:58:03 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

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
  (interactive "D")
  (dolist (file
           (directory-files (expand-file-name directory) t
                            directory-files-no-dot-files-regexp) nil)
     ((and recurse (file-directory-p file))
      (when recurse (load-dir file)))
     ((string-match "\\.el$\\|\\.elc$" file)
      (load-library (file-name-sans-extension file))))))

reply via email to

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