terça-feira, 24 de abril de 2012

Cleaner meaner emacs .init file

Just finished an improved version of my emacs configuration in order to clean up
its increasing complexity. Check out its size:


(defvar *my-default-lib* "~/.emacs.d/lib"
  "Vendor libraries that cannot be installed via the package system")
(defvar *my-conf* "~/.emacs.d/conf/"
  "My configurations")

(add-to-list 'load-path *my-default-lib*)
(add-to-list 'load-path *my-conf*)


(load "package-manager.el")
(load "misc.el")
(load "history.el")
(load "keybindings.el")
(load "ido-conf.el")
(load "autocompletion.el")
(load "eshell-conf.el")
(load "slime-conf.el")
(load "spell-checking.el")
(load "lisp-conf.el")
(load "scheme-conf.el")
(load "ruby-conf.el")
(load "js-conf.el")
(load "haskell-conf.el")


(setq custom-file (concat *my-conf* "custom.el"))
(load custom-file 'noerror)
Basically everything now has its own file. There is also a nice package system that I borrowed from here. That means that everything that can be installed through the package system will be.
(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/")
             '("ELPA"      . "http://tromey.com/elpa/"))

(package-initialize)

(defvar my-packages '(ac-slime
                      highlight-parentheses
                      highlight-symbol
                      paredit
                      rainbow-delimiters
                      ido-ubiquitous
                      smex
                      undo-tree
                      haskell-mode
                      yasnippet
                      yasnippet-bundle
                      clojure-mode
                      zenburn-theme)
  "A list of packages to ensure are installed at launch.")


(defun my-packages-installed-p ()
  (loop for p in my-packages
        when (not (package-installed-p p)) do (progn (message "%s" p) (return nil))
        finally (return t)))

(unless (my-packages-installed-p)
  ;; check for new packages (package versions)
  (message "%s" "Emacs is now refreshing its package database...")
  (package-refresh-contents)
  (message "%s" " done.")
  ;; install the missing packages
  (dolist (p my-packages)
    (when (not (package-installed-p p))
      (package-install p))))


Nenhum comentário:

Postar um comentário