Return to Snippet

Revision: 13402
at April 22, 2009 16:38 by bigfaceworm


Initial Code
(defconst dot-emacs (concat (getenv "HOME") "/" "frog.el")
    "My dot emacs file")

(require 'bytecomp)
(setq compiled-dot-emacs (byte-compile-dest-file dot-emacs))

(if (or (not (file-exists-p compiled-dot-emacs))
	(file-newer-than-file-p dot-emacs compiled-dot-emacs)
        (equal (nth 4 (file-attributes dot-emacs)) (list 0 0)))
    (load dot-emacs)
  (load compiled-dot-emacs))

(add-hook 'kill-emacs-hook
          '(lambda () (and (file-newer-than-file-p dot-emacs compiled-dot-emacs)
                           (byte-compile-file dot-emacs))))

Initial URL


Initial Description
Move your current .emacs file to a new name (like `.emacs.username.el`), and change the `"frog.el"` to that new name.  This code will byte compile your (newly named) .emacs file upon exit, and upon starting up will load the byte compiled (unless the source is newer).

I chose not to byte compile on startup b/c the original purpose of this code was to speed things up, and loading and byte compiling will slow things down slightly...

Initial Title
Auto-compiled .emacs file

Initial Tags


Initial Language
Emacs Lisp