Dumping emacs

Suppose you have many customizations and you want to dump that into a new binary so that emacs can be started quickly. You might choose dumping new emacs. Here is a simple way to dump without the burden of separate configuration file management. Write your ~/.emacs.el as follows:

(require 'cl)
(defmacro eval-when-dump (&rest body)
  (when (boundp 'eval-when-dump) `(progn ,@body (makunbound 'eval-when-dump))))
(defmacro eval-after-dump (&rest body)
  (unless (boundp 'eval-when-dump) `(progn ,@body)))
(eval-when-dump ...)
(eval-after-dump ...)
The actual dumping process goes like this:
$ $EMACS --batch --execute "(setq eval-when-dump t)" -f batch-byte-compile ~/.emacs.el
$ $EMACS --batch -l ~/.emacs.elc --execute "(dump-emacs \"$HOME/xe\" \"$EMACS\")"
$ $EMACS --batch -f batch-byte-compile ~/.emacs.el
Then byte compile ~/.emacs.el then the newly created binary will read only the (eval-afater-dump ..) part and dump process only reads (eval-when-dump ....).

A few commands should not be called while dumping. These includes (display-time), (setenv ...), and so on. Gnus needs some hack to be loaded while dumping.

Randum note:

Here's a emacs binary replacement to do automatic re-dumping if .emacs.el changes. Save it to emacs and make it an executable and make sure this emacs comes before the real emacs binary(check with type -a in your shell).

#! /bin/sh
export PATH
if test -n $DUMPUP -a -f $DUMPUP -a $DUMPUP -nt $EMACSDIR/src/xe; then
    pushd $EMACSDIR/src &&
    ./emacs -batch -eval "(setq eval-when-dump t)" -f batch-byte-compile $DUMPUP &&
    ./emacs -batch -l ${DUMPUP}c -eval "(dump-emacs \"xe\" \"emacs\")" &&
    ./emacs -batch -f batch-byte-compile $DUMPUP &&
exec xe "$@"

emacs lisp codes

Here's a list of small emacs lisp scripts I've written.

Time-stamp: <11/20/2004 10:16 KST by jay>
Chung Jae-youn