HTTPS SSH

mk-startup

My take on ~/.emacs micro-framework.

Supports using directory hierarchy like ~/emacs/etc (with various initialization snippets), ~/emacs/site-lisp (with downloaded modules) etc.

Also, provides a few handy functions which may turn useful for .emacs writing.

Noticeable parts of this code were inspired by or even copied from various .emacs examples published around the net (unfortunately most important of those seem to be gone, so no links, safe loading idea is taken from rranelli).

Installation

Save mk-startup.el wherever you like.

Usage

Here is my ~/.emacs using this module:

(defvar *my-emacs-dir*  "~/emacs/")
(defvar *my-elpa-dir*  (expand-file-name "elpa" *my-emacs-dir*))
(defvar *my-site-dir*  (expand-file-name "site-lisp" *my-emacs-dir*))
(defvar *my-own-dir*   (expand-file-name "own-lisp" *my-emacs-dir*))
(defvar *my-etc-dir*   (expand-file-name "etc" *my-emacs-dir*))

;; Load mk-startup (explicite as it will bootstrap paths)
(load-file (expand-file-name "mk_startup/mk-startup.el" *own-lisp*))

;; This updates load-path and info path, prepending any elisp-containing
;; directories found inside my trees.
(mk-add-source-trees *my-own-dir*
                     *my-site-dir*
                     *my-elpa-dir*)

;; This loads all files present in ~/emacs/etc, in name order
;; (and don't stop even if one of those fails)
(mk-load-init-directory *my-etc-dir*)

With such setup:

  • most of my configuration resides in ~/emacs/etc/ (~/emacs/etc/02-setup-elpa.el, ~/emacs/etc/50-theme.el, ~/emacs/etc/60-python.el, … ),

  • manually downloaded modules are saved in ~/emacs/site-lisp (usually in subdirectories),

  • stuff grabbed from elpa/melpa/marmelade lands in ~/emacs/elpa (in one of my etc files I configure it doing (set-variable 'package-user-dir *my-elpa-dir*)).

Apart from mk-add-source-tree and mk-load-init-directory there are various lower level functions (like find all directories which contain file matching regexp) and some extra initialization-related stuff (like support for extending PATH). See mk-startup.el for details.

Source

The code is available on BitBucket:

 hg clone https://bitbucket.org/Mekk/emacs_libs-mk_startup

(or download repository if you don’t speak Mercurial).