An alternative to a monolithic ~/.emacs init file
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
An alternative to a monolithic ~/.emacs init file         


Author: Sebastian Tennant
Date: Oct 30, 2007 08:04

My ~/.emacs reads like this:

;;; generate auto-autoloads.el in ~/elisp/dotemacs/
(let ((generated-autoload-file "~/elisp/dotemacs/auto-autoloads.el")
(backup-inhibited t))
(apply 'update-directory-autoloads '("~/elisp/lib/"))
(kill-buffer (file-name-nondirectory generated-autoload-file)))

;;; load dotemacs/*.el (including auto-autoloads.el)
(mapc (lambda (f) (load f))
(split-string
(shell-command-to-string "find ~/elisp/dotemacs -name *.el")))

That's it, essentially.

With this arrangement, library functions I've written that I don't
always want to load at startup, but I do want to have to hand, go in
~/elisp/lib, and customisations (and functions I do always want to load
at startup) go in ~/elisp/dotemacs.

I can put my customisations and functions in as many .el files as I like
within their respective directories, making it much easier to organise
things generally.
Show full article (1.29Kb)
13 Comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: rustom
Date: Nov 7, 2007 09:13

Sebastian Tennant wrote:
> My ~/.emacs reads like this:
>
> ;;; generate auto-autoloads.el in ~/elisp/dotemacs/
> (let ((generated-autoload-file "~/elisp/dotemacs/auto-autoloads.el")
> (backup-inhibited t))
> (apply 'update-directory-autoloads '("~/elisp/lib/"))
> (kill-buffer (file-name-nondirectory generated-autoload-file)))
>
> ;;; load dotemacs/*.el (including auto-autoloads.el)
> (mapc (lambda (f) (load f))
> (split-string
> (shell-command-to-string "find ~/elisp/dotemacs -name *.el")))
>
> That's it, essentially.
>
> With this arrangement, library functions I've written that I don't
> always want to load at startup, but I do want to have to hand, go in
> ~/elisp/lib, and customisations (and functions I do always want to load
> at startup) go in ~/elisp/dotemacs. ...
Show full article (1.71Kb)
no comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: Sebastian Tennant
Date: Nov 8, 2007 05:08

Quoth rustom gmail.com>:
> Could you please elaborate on how this works a little? [...] I really
> would like to have a tiny little .emacs file and a bunch of files and
> directories containing unrelated stuff

If you don't care about autoloads (or you're not sure what they are) and
you just want a small ~/.emacs, then all you need is this:

;;; load dotemacs/*.el
(mapc (lambda (f) (load f))
(split-string
(shell-command-to-string "find ~/elisp/dotemacs -name *.el")))

This routine simply loads each file ending '.el' found under the
directory ~/elisp/dotemacs.

Sebastian
no comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: rustom
Date: Nov 8, 2007 11:53

On Nov 8, 6:08 pm, Sebastian Tennant smolny.plus.com> wrote:
> Quoth rustom gmail.com>:
>
>> Could you please elaborate on how this works a little? [...] I really
>> would like to have a tiny little .emacs file and a bunch of files and
>> directories containing unrelated stuff
>
> If you don't care about autoloads (or you're not sure what they are) and
> you just want a small ~/.emacs, then all you need is this:
>
> ;;; load dotemacs/*.el
> (mapc (lambda (f) (load f))
> (split-string
> (shell-command-to-string "find ~/elisp/dotemacs -name *.el")))
>
> This routine simply loads each file ending '.el' found under the
> directory ~/elisp/dotemacs.
>
> Sebastian
Show full article (2.12Kb)
no comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: Sebastian Tennant
Date: Nov 9, 2007 06:18

Quoth rustom gmail.com>:
> Thanks. I think I understand autoload. Also I dont want needless
> loading at emacs-startup -- its unlikely that in a given session I
> will do C and python and ruby and org and tramp and elisp and .....
> though I do use all these once in a while. What I dont understand are
> magic cookies and how emacs uses them; or more correctly *When* emacs
> uses them. The elisp manual says:
>
> "These comments do nothing on their own, but they serve as a guide for
> the command `update-file-autoloads', which constructs calls to
> 'autoload' and arranges to execute them when Emacs is built."
> Does this mean I have to rebuild emacs if I want to use this ?!

First of all, autoloads exist precisely for the reason you've stated;
avoiding needless loading of functions at startup. Consider the
function 'foo' defined in bar.el. If your ~/.emacs includes the line

(autoload 'foo "bar.el" "My function foo" t)
Show full article (2.89Kb)
no comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: rustom
Date: Nov 10, 2007 04:18

Thanks Sebastian for a detailed response. But I cant see how it will
work. Let me try and collect the pieces of the jigsaw as I understand
them.
Firstly the organization

On Nov 9, 7:18 pm, Sebastian Tennant smolny.plus.com> wrote:
> With this arrangement, library functions I've written that I don't always want to load at startup, but I do want to have
> to hand, go in ~/elisp/lib, and customisations (and functions I do always want to load at startup) go in
> ~/elisp/dotemacs.

Second the scales:
Lets assume that elisp/lib contains thousands of lines of lisp
distilled into say about 10 autoloads and a few customizations. In
general the user is never expected to use the 10 autoloads together.

Now the call: (apply 'update-directory-autoloads '("~/elisp/lib"))
or (update-directory-autoloads "~/elisp/lib")
will traverse the whole lib file-set -- all the thousands of lines --
at startup losing the advantage of autoloading.

For using an elisp module let us say foo I guess we need the following
three phases:
Show full article (1.83Kb)
no comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: Francisco Miguel Colaço
Date: Nov 10, 2007 16:09

Thu, 08 Nov 2007 11:53:08 -0800, rustom wrote:
> On Nov 8, 6:08 pm, Sebastian Tennant smolny.plus.com> wrote:
>> Quoth rustom gmail.com>:
>>
>>> Could you please elaborate on how this works a little? [...] I
>>> really would like to have a tiny little .emacs file and a bunch of
>>> files and directories containing unrelated stuff
>>
>> If you don't care about autoloads (or you're not sure what they are)
>> and you just want a small ~/.emacs, then all you need is this:
>>
>> ;;; load dotemacs/*.el
>> (mapc (lambda (f) (load f))
>> (split-string
>> (shell-command-to-string "find ~/elisp/dotemacs -name *.el")))
>>

I use the following .emacs:
Show full article (2.06Kb)
no comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: Tom Tromey
Date: Nov 10, 2007 09:13

>>>>> ">" == rustom gmail.com> writes:
>> This way the .emacs can be nothing more than the two lines
>> (load-loaddefs-from-directory "~/elisp/lib")
>> (load-customizations-from-directory "~/elisp/lib")
>> And there are no superfluous file traversals at emacs startup time
>> Knowing emacs and its community I guess this functionality is already
>> available!
>> Question is what is it called :-)

ELPA works this way, more or less. It isn't as simple as "drop in
some elisp and work", since it provides some other features that
require a bit more metadata. But, the basic idea is the same: extract
autoloads and byte-compile at package install time; and read the
minimal number of files and only evaluate autoloads at package
evaluation time.

For more info:

http://tromey.com/elpa/

There are some other, more minimal, elisp install packages. They are
listed on the wiki.

Tom
no comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: rustom
Date: Nov 11, 2007 07:29

After my last post I I looked at my current .emacs file and realised
its more difficult than I thought:

Ideally if the separate aspects of the setup I want were independent
they could be put into separate directories and the corresponding
loaddefs and customizations loaded in any (non-deterministic) order.

However there are dependencies: eg to use python (with refactoring)
one needs bicyclerepairman; to use brm one needs pymacs.

What is worse there are emacs bugs whose correction needs careful
sequencing:
For example I need to put
(provide 'sb-info)
just before the brm-init otherwise I get 'recursive require' errors.
What in the name of ... is sb-info -- thats another OT matter
no comments
Re: An alternative to a monolithic ~/.emacs init file         


Author: Tim X
Date: Nov 12, 2007 13:56

rustom gmail.com> writes:
> After my last post I I looked at my current .emacs file and realised
> its more difficult than I thought:
>
> Ideally if the separate aspects of the setup I want were independent
> they could be put into separate directories and the corresponding
> loaddefs and customizations loaded in any (non-deterministic) order.
>
> However there are dependencies: eg to use python (with refactoring)
> one needs bicyclerepairman; to use brm one needs pymacs.
>

The common way to get around this is to number your files -
e.g. 50my-lib.el 60my-other-lib.el etc. This forces files to be loaded in a
specific order.
Show full article (1.56Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
Re: .emacs in the Windows version of Emacsgnu.emacs.help ·
Bug#439561: dh-make: Enhancements to provided init.d template and a new LSB-compliant init.d scriptlinux.debian.bugs.dist ·
1 2