doomemacs/bootstrap.el

92 lines
3.1 KiB
EmacsLisp
Raw Normal View History

;;; bootstrap.el
2016-03-26 13:19:31 +08:00
(eval-when-compile (require 'cl))
;; Shut up byte-compiler!
(defvar narf-current-theme)
(defvar narf-current-font)
;; Global constants
(eval-and-compile
2016-03-26 13:19:31 +08:00
(defconst narf-default-theme 'wombat)
(defconst narf-default-font nil)
(defconst narf-emacs-dir (expand-file-name "." user-emacs-directory))
(defconst narf-core-dir (concat narf-emacs-dir "/core"))
(defconst narf-modules-dir (concat narf-emacs-dir "/modules"))
(defconst narf-private-dir (concat narf-emacs-dir "/private"))
(defconst narf-packages-dir (concat narf-emacs-dir "/.cask/" emacs-version "/elpa"))
(defconst narf-script-dir (concat narf-emacs-dir "/scripts"))
2016-03-27 12:49:52 +08:00
(defconst narf-ext-dir (concat narf-emacs-dir "/ext"))
2016-03-26 13:19:31 +08:00
(defconst narf-snippet-dirs (list (concat narf-private-dir "/snippets")
(concat narf-private-dir "/templates")))
;; Hostname and emacs version-based elisp temp directories
2016-03-27 12:49:52 +08:00
(defconst narf-temp-dir (format "%s/cache/%s/%s.%s"
2016-03-26 13:19:31 +08:00
narf-private-dir (system-name)
emacs-major-version emacs-minor-version))
(defconst IS-MAC (eq system-type 'darwin))
(defconst IS-LINUX (eq system-type 'gnu/linux))
2016-04-05 05:28:30 +08:00
(defconst IS-WINDOWS (eq system-type 'windows-nt)))
(eval-when-compile
(defvar narf--load-path load-path)
;; Helper for traversing subdirectories recursively
(defun --subdirs (path &optional include-self)
2016-03-26 13:19:31 +08:00
(let ((result (if include-self (list path) (list))))
(dolist (file (ignore-errors (directory-files path t "^[^.]" t)))
(when (file-directory-p file)
(push file result)))
2016-03-26 13:19:31 +08:00
result)))
2016-03-26 13:19:31 +08:00
;;
;; Bootstrap
;;
(defun narf (packages)
"Bootstrap NARF emacs and initialize PACKAGES"
2016-03-28 06:18:43 +08:00
;; stop package.el from being annoying. I rely solely on Cask.
2016-03-26 13:19:31 +08:00
(setq-default
package--init-file-ensured t
package-enable-at-startup nil
2016-03-28 06:18:43 +08:00
gc-cons-threshold 4388608
gc-cons-percentage 0.2)
2016-03-26 13:19:31 +08:00
;; prematurely optimize for faster startup
2016-03-26 13:19:31 +08:00
(let ((gc-cons-threshold 169715200)
(gc-cons-percentage 0.3)
file-name-handler-alist)
2016-02-27 06:58:42 +08:00
;; Scan various folders to populate the load-paths
2016-03-26 13:19:31 +08:00
(setq load-path
2016-04-05 05:28:30 +08:00
(eval-when-compile
(append (list narf-private-dir)
(--subdirs narf-core-dir t)
(--subdirs narf-modules-dir t)
(--subdirs narf-packages-dir)
(--subdirs (expand-file-name "../bootstrap" narf-packages-dir))
narf--load-path))
2016-03-26 13:19:31 +08:00
custom-theme-load-path
2016-02-27 06:58:42 +08:00
(append (list (expand-file-name "themes/" narf-private-dir))
2016-03-26 13:19:31 +08:00
custom-theme-load-path))
(require 'f)
(require 'dash)
(require 's)
;; Load local settings, if available
(when (file-exists-p "~/.emacs.local.el")
(load "~/.emacs.local.el"))
2016-03-26 13:19:31 +08:00
;; Global settings
2016-03-23 23:55:52 +08:00
(setq narf-current-theme narf-default-theme
2016-03-26 13:19:31 +08:00
narf-current-font narf-default-font)
;; Load 'em up!
(load-theme narf-current-theme t)
2016-03-28 06:18:43 +08:00
(mapc 'require packages)))
;;; bootstrap.el ends here