More Emacs Refatorings

I ended up performing a few more refactorings to my initialize code in order to make it work a bit better, so I thought I’d share them with you. The first is adding another subdirectory to my customizations directory, so the tree of my .emacs.d directory in svn looks like:

~/emacs.d/
        customizations/http://nflath.com/wp-admin/post.php?action=edit&post=377
                1/
                2/
        documentation/
        java-libraries/
        major-modes/
        minor-modes/
        utilities/

This allows me to have finer control over the order in which my customizations execute. Mainly, almost every file is in directory customizations/1/: the only one that is in customizations/2 is state.el, which will open all previously visited files. I want this to happen after my hooks have been added to modes so the buffers are set up how they should be; this wasn’t quite happening with one directory. This does mean my init.el file now has these two lines in it to load the two directories in the proper order:

(setq customizations-directory-load-times-1 (load-directory "~/.emacs.d/customizations/1/"))
(setq customizations-directory-load-times-2 (load-directory "~/.emacs.d/customizations/2/"))

I also removed several directories from my version control repository, although they are in myt actual .emacs.d repository. Specifically, the slime, clojure, clojure-contrib, swank-clojure, and emacs-w3m folders are all gone from SVN. However, since I still want these accessible from wherever I check out, I added a few lines to clojure.el and w3m-cust.el to create these files if they don’t exist:

(if (not (file-exists-p (concat clojure-src-root "/clojure")))
    (clojure-install))
 
(if (not (file-exists-p "~/.emacs.d/emacs-w3m/"))
    (let ((default-directory "~/.emacs.d/"))
      (shell-command-to-string
       "cvs -d :pserver:anonymous@cvs.namazu.org:/storage/cvsroot co emacs-w3m")
      (let ((default-directory "~/.emacs.d/emacs-w3m/"))
        (add-to-list 'load-path default-directory)
        (normal-top-level-add-subdirs-to-load-path))))

Essentially, the first time I start emacs on a new checkout, clojure-install will be run, retrieving all the files I need to start editing Clojure files. The same thing happens with emacs-w3m: If the directory doesn’t exist, it is checked out and the directories are added to the load-path. This can take a while, but I’d have to check the directory out anyway, and this allows for a much easier package update. I also ended up updating clojure-mode.el itself, which is checked into version control.

Tags:

Leave a Reply