I have been using emacs for a while now. I would guess about five years. I would classify myself as a power user and not really a true emacs user. To be a ‘true’ emacs user you should at least be able to write elisp and generally hack emacs. Instead, I rely very heavily on existing elisp code and blogs. Of course, you can not mention emacs without pointing to http://emacswiki.org.
Writing about your dot emacs has become all the rage lately and I figured I would join in the fun. By writing about this I hope to do a few things;
- filter out the junk in my dot emacs
- get tips and/or ideas about what I can do better
- finally get the motivation to write some elisp
(setq my-init-dir "~/.emacs.lisp" my-pkg-dir (concat my-init-dir "/pkg") my-site-dir (concat my-pkg-dir "/share/emacs/site-lisp")) (load "~/.emacs.lisp/init.el")
And the ~/.emacs.lisp/init.el
(add-to-list 'load-path (expand-file-name "~/.emacs.lisp")) (add-to-list 'load-path (expand-file-name (concat my-init-dir "/pkg"))) (load "safe-load") (dolist (file (reverse (mapcar 'file-name-sans-extension (file-expand-wildcards (concat my-init-dir "/conf[0-9][0-9].d/[a-z-]*.el"))))) (safe-load (expand-file-name file))) (safe-load "keys.el")
I can not recall where I got this idea from, but it has served me well so far. As any *nix user will note, this is inspired by the rc.d runlevel concept. I can have conf00.d to conf99.d as sub directories to the main .emacs.lisp directory. This allows for relatively easy control of ‘boot’ order of various modes,apps,etc…
I have only been bitten by the implicit boot order a couple of times. Currently, I only have 0-3 and I am just thinking about adding a 4.
One thing to note is the keys.el file is at the bottom, I wanted a single place to find all my global key bindings.
In later posts I will go over what is hiding in the conf00.d-conf03.d directories, but for now I will move on.
Here are some stats:
- 36 elisp files
- 854 loc
- 73 packages
I have still not found a way to deal with packages well at all. As the stat above shows, I have 73 of something via ls -l|wc -l.
I decided to put all pkgs under ~/.emacs.lisp/pkg Normally I just grab a release tarbal and extract it there. Then have the elisp file under conf??.d add the path to the load-path list and its working. Sometimes I do grab a clone of a repos and dump it in there too.
This works out ok, except that when the pkg needs to ./configure the parameters can get quite hairy, keeping the ‘install’ under ~/.emacs.lisp/pkg is messy then.
Of course I keep the entire ~/.emacs.lisp dir under hg, pushed to a remote server. This way I can pull onto my laptop or anyother random *nix and get my exact environment.
Does this work in practice? Not really.
Often times the ~/.emacs.lisp gets too far out of sync and I have to choose what to blow away. (I can be lazy with horrible merges.) Also having clones of other repos in ~/.emacs.lisp/pkg means I have to delete their .git or .hg and lose all of that info. (No I am not going to commit those dirs). Also, I get lazy and forget to commit and/or push and when I pull everything is ancient.
I like it, kind of
There are downsides to this method, finding where you configured something can be a pain, grep’ing files all the time does become tedious.
I would say it is a win so far. At least I have not discovered a better method for managing a huge emacs config.