2016-01-29 02:04:27 -05:00
|
|
|
;;; bootstrap.el
|
|
|
|
|
2016-04-21 00:31:54 -04:00
|
|
|
(eval-when-compile (require 'cl-lib))
|
2016-03-26 01:19:31 -04:00
|
|
|
|
|
|
|
;; Shut up byte-compiler!
|
|
|
|
(defvar narf-current-theme)
|
|
|
|
(defvar narf-current-font)
|
|
|
|
|
|
|
|
;; Global constants
|
2016-02-26 00:08:57 -05:00
|
|
|
(eval-and-compile
|
2016-03-26 01:19:31 -04: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 00:49:52 -04:00
|
|
|
(defconst narf-ext-dir (concat narf-emacs-dir "/ext"))
|
2016-03-26 01:19:31 -04:00
|
|
|
(defconst narf-snippet-dirs (list (concat narf-private-dir "/snippets")
|
|
|
|
(concat narf-private-dir "/templates")))
|
2016-02-26 00:08:57 -05:00
|
|
|
;; Hostname and emacs version-based elisp temp directories
|
2016-03-27 00:49:52 -04:00
|
|
|
(defconst narf-temp-dir (format "%s/cache/%s/%s.%s"
|
2016-03-26 01:19:31 -04:00
|
|
|
narf-private-dir (system-name)
|
|
|
|
emacs-major-version emacs-minor-version))
|
2016-01-29 02:04:27 -05:00
|
|
|
|
2016-02-26 00:08:57 -05:00
|
|
|
(defconst IS-MAC (eq system-type 'darwin))
|
|
|
|
(defconst IS-LINUX (eq system-type 'gnu/linux))
|
2016-04-04 17:28:30 -04:00
|
|
|
(defconst IS-WINDOWS (eq system-type 'windows-nt)))
|
|
|
|
|
|
|
|
(eval-when-compile
|
|
|
|
(defvar narf--load-path load-path)
|
2016-01-29 02:04:27 -05:00
|
|
|
|
|
|
|
;; Helper for traversing subdirectories recursively
|
|
|
|
(defun --subdirs (path &optional include-self)
|
2016-03-26 01:19:31 -04:00
|
|
|
(let ((result (if include-self (list path) (list))))
|
|
|
|
(dolist (file (ignore-errors (directory-files path t "^[^.]" t)))
|
2016-01-29 02:04:27 -05:00
|
|
|
(when (file-directory-p file)
|
|
|
|
(push file result)))
|
2016-03-26 01:19:31 -04:00
|
|
|
result)))
|
2016-01-29 02:04:27 -05:00
|
|
|
|
2016-03-26 01:19:31 -04:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; Bootstrap
|
|
|
|
;;
|
2016-01-29 02:04:27 -05:00
|
|
|
|
|
|
|
(defun narf (packages)
|
|
|
|
"Bootstrap NARF emacs and initialize PACKAGES"
|
2016-04-21 00:31:54 -04:00
|
|
|
(setq-default gc-cons-threshold 4388608
|
|
|
|
gc-cons-percentage 0.4)
|
2016-03-26 01:19:31 -04:00
|
|
|
|
2016-01-29 02:04:27 -05:00
|
|
|
;; prematurely optimize for faster startup
|
2016-04-21 00:31:54 -04:00
|
|
|
(let ((gc-cons-threshold 339430400)
|
|
|
|
(gc-cons-percentage 0.6)
|
2016-03-26 01:19:31 -04:00
|
|
|
file-name-handler-alist)
|
|
|
|
|
2016-02-26 17:58:42 -05:00
|
|
|
;; Scan various folders to populate the load-paths
|
2016-03-26 01:19:31 -04:00
|
|
|
(setq load-path
|
2016-04-04 17:28:30 -04: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 01:19:31 -04:00
|
|
|
custom-theme-load-path
|
2016-02-26 17:58:42 -05:00
|
|
|
(append (list (expand-file-name "themes/" narf-private-dir))
|
2016-03-26 01:19:31 -04:00
|
|
|
custom-theme-load-path))
|
|
|
|
|
|
|
|
(require 'f)
|
|
|
|
(require 'dash)
|
|
|
|
(require 's)
|
|
|
|
|
2016-01-29 02:04:27 -05:00
|
|
|
;; Load local settings, if available
|
|
|
|
(when (file-exists-p "~/.emacs.local.el")
|
|
|
|
(load "~/.emacs.local.el"))
|
2016-03-26 01:19:31 -04:00
|
|
|
|
|
|
|
;; Global settings
|
2016-03-23 11:55:52 -04:00
|
|
|
(setq narf-current-theme narf-default-theme
|
2016-03-26 01:19:31 -04:00
|
|
|
narf-current-font narf-default-font)
|
|
|
|
|
|
|
|
;; Load 'em up!
|
|
|
|
(load-theme narf-current-theme t)
|
2016-03-27 18:18:43 -04:00
|
|
|
(mapc 'require packages)))
|
2016-01-29 02:04:27 -05:00
|
|
|
|
|
|
|
;;; bootstrap.el ends here
|