Permalink
Browse files

[Fix #451] Add the ability to preload personal code

  • Loading branch information...
1 parent 3cdb7f3 commit 4ca22fbf1c408f8f64a07520ed7c95843ce64234 @bbatsov committed Dec 6, 2013
Showing with 17 additions and 0 deletions.
  1. +6 −0 README.md
  2. +11 −0 init.el
  3. 0 personal/preload/.gitkeep
View
@@ -443,6 +443,12 @@ If you require just a single package you can also use:
(prelude-require-package 'some-package)
```
+#### Preloading personal config
+
+Sometimes you might want to load code before Prelude has started loading. Prelude will automatically preload all
+Emacs Lisp files in your `personal/preload` directory. Note that at this point you can't using anything from
+Prelude, except a few variables like `prelude-dir`, etc (since nothing is yet loaded).
+
#### Disabling whitespace-mode
Although `whitespace-mode` is awesome some people might find it too
View
11 init.el
@@ -53,6 +53,8 @@
Users of Emacs Prelude are encouraged to keep their personal configuration
changes in this directory. All Emacs Lisp files there are loaded automatically
by Prelude.")
+(defvar prelude-personal-preload-dir (expand-file-name "preload" prelude-personal-dir)
+ "This directory is for your personal configuration, that you want loaded before Prelude.")
(defvar prelude-vendor-dir (expand-file-name "vendor" prelude-dir)
"This directory houses packages that are not yet available in ELPA (or MELPA).")
(defvar prelude-savefile-dir (expand-file-name "savefile" prelude-dir)
@@ -83,6 +85,13 @@ by Prelude.")
;; each 50MB of allocated data (the default is on every 0.76MB)
(setq gc-cons-threshold 50000000)
+;; preload the personal settings from `prelude-personal-preload-dir'
+(when (file-exists-p prelude-personal-preload-dir)
+ (message "Loading personal configuration files in %s..." prelude-personal-preload-dir)
+ (mapc 'load (directory-files prelude-personal-preload-dir 't "^[^#].*el$")))
+
+(message "Loading Prelude's core...")
+
;; the core stuff
(require 'prelude-packages)
(require 'prelude-ui)
@@ -95,6 +104,8 @@ by Prelude.")
(when (eq system-type 'darwin)
(require 'prelude-osx))
+(message "Loading Prelude's modules...")
+
;; the modules
(when (file-exists-p prelude-modules-file)
(load prelude-modules-file))
No changes.

2 comments on commit 4ca22fb

I just updated prelude today (git pull on my .emacs.d) and all my custom .el files in personal have been deleted (since now personal contains the preload dir).
Maybe you can create 2 separate directories: personal and preload (with a .gitkeep file in them) directly under .emacs.d?

Owner

bbatsov replied Dec 11, 2013

This change should not affect files you had in the personal dir in any way. I've briefly considered adding a top-level dir for preloading, but it seems both excessive and confusing, since preloading makes sense only for personal code.

Please sign in to comment.