emacs-devel
[Top][All Lists]
Advanced

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

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


From: Ted Zlatanov
Subject: Re: user-controlled load-path extension: load-dir
Date: Thu, 17 Mar 2011 05:55:22 -0500
User-agent: Gnus/5.110014 (No Gnus v0.14) Emacs/24.0.50 (gnu/linux)

On Thu, 17 Mar 2011 00:22:10 -0400 Ben Key <address@hidden> wrote: 

BK> For what it is worth I signed the necessary copyright assignment papers
BK> years ago.  I have been a member of the Emacs project since Wednesday,
BK> November 13, 2002.  If you go to the Emacs Project Memberlist page you will
BK> see me listed as Ben Key <bkey1>.  I simply have not been an active
BK> contributor to Emacs for the past several years.

Sorry Ben, I just checked the ChangeLogs.  I put you in the authors list
of user-load-dirs.el, which is attached below.  Please suggest any
changes you think are necessary.

BK> I do think it is important to trap errors though.  If you do not, and you
BK> call this new load directory function in your .emacs file, Emacs
BK> initialization will abort at the first error leaving your Emacs session half
BK> configured (any code positioned after the call to load directory will not
BK> run).  I do not think this is a good idea.  I do not feel very strongly
BK> about this though.

I think it's a valid way to do it, but the way I think of it (as a
logical extension to .emacs) errors should not be trapped.

I made it an option.

On Thu, 17 Mar 2011 00:31:34 -0600 Evans Winner <address@hidden> wrote: 

EW> By the way, a version of `load-dir' that I sent Ben Key a
EW> week or so ago mostly/partly includes handling of gzipped
EW> libraries (or whatever is returned by `get-load-suffixes')
EW> which seemed a useful variation, though it occurs to me that
EW> I don't know if that is portable across platforms.

It seems to work OK and automatically filters out "." and ".." so it's a
good idea.  I added that to user-load-dirs.el as well.

On Wed, 16 Mar 2011 21:42:17 -0700 PJ Weisberg <address@hidden> wrote: 

PW> I only saw Stefan say to go ahead with a load-directory function,

I know, but a package IMO will provide a better user experience because
of the number of possible options.  We already have recursive and
ignore-errors; I imagine the list will only grow.  Plus the loaded cache
in `user-load-dirs-loaded' is pretty crucial to avoid double-loading
files; remember Stephen Turnbull's concerns about installing hooks twice
for instance.  All of that is a pain to handle without a package.

PW> which I assumed would live in files.el next to load-file and look
PW> something like this:

PW> (defun load-directory (dir recursive)
PW>  "Load all Lisp files in DIR.  If RECURSIVE is non-nil,
PW> recursively call load-directory for all subdirectories of dir."
PW>  (interactive "DLoad Dir: \nP")
PW>  (dolist (file (directory-files dir t ".*\\.el$"))
PW>    ;; Cut off the .el so load will pick up the .elc version if it's there
PW>    (setq file (substring file 0 -3))
PW>    (load file))
PW>  (when recursive
PW>    (dolist (file (directory-files dir t))
PW>      (if (and (file-directory-p file)
PW>               (not (string-match "/\\.\\.?$" file)))
PW>          (load-directory file recursive)))))

PW> If I'm not mistaken that's about 90% of what you want, and makes using
PW> your own load-dir at least as easy as using your own custom-file.

I will use `file-name-sans-extension' instead of the substring to handle
all the possible values from `get-load-suffixes', but yeah I think using
the bare file name is better than explicitly loading it with the
extension.  Thanks for that (and I think both Ben and Evans had
something similar).

If `user-load-dirs-load' is autoloaded then it's just as easy to manage
at the user level as the `load-directory' function you suggest.

The library can be made into an ELPA package easily and thus used in
older Emacsen.  My goal, though, is to call `user-load-dirs-load' in the
Emacs startup, as I've mentioned.

Ted

Attachment: user-load-dirs.el
Description: application/emacs-lisp


reply via email to

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