2017-01-16 23:15:48 -05:00
|
|
|
;;; core-packages.el
|
2017-02-06 00:12:44 -05:00
|
|
|
;;
|
2017-02-11 06:00:08 -05:00
|
|
|
;; Emacs package management is opinionated. Unfortunately, so am I. So with the
|
|
|
|
;; help of `use-package', `quelpa' and package.el, DOOM Emacs manages my
|
|
|
|
;; plugins and internal module dependency chains.
|
|
|
|
;;
|
|
|
|
;; So I've divided my config into two parts: configuration and
|
|
|
|
;; packages/dependency control. You'll find packages.el files in each DOOM
|
|
|
|
;; module (in `doom-modules-dir') and one in `doom-core-dir'. When executed,
|
|
|
|
;; they fill `doom-packages' and `doom-modules', which are necessary for DOOM to
|
|
|
|
;; extrapolate all kinds of information about plugins.
|
2017-01-16 23:15:48 -05:00
|
|
|
;;
|
2017-01-28 02:02:16 -05:00
|
|
|
;; Why all the trouble? Because:
|
2017-02-11 06:00:08 -05:00
|
|
|
;; 1. Scriptability: I want my plugins managable from the command line. This
|
|
|
|
;; means a `doom/packages-update' command I can call to programmatically
|
|
|
|
;; update my plugins, rather than through package.el's interface.
|
|
|
|
;; 2. Flexibility: I want to install packages from sources other than ELPA. Like
|
|
|
|
;; github or the Emacs wiki. Some plugins are out-of-date through official
|
|
|
|
;; channels, have changed hands unofficially, or simply haven't been
|
|
|
|
;; submitted to an ELPA repo yet.
|
2017-02-01 00:29:39 -05:00
|
|
|
;; 3. Stability: I don't want to worry that each time I use my package
|
2017-02-11 06:00:08 -05:00
|
|
|
;; manager something might inexplicably go wrong. Cask, which I used
|
|
|
|
;; previously, was horribly unstable. package.el and quelpa, however, appear
|
|
|
|
;; very stable (and much faster).
|
|
|
|
;; 4. Performance: A minor point, but it helps startup performance not to do
|
|
|
|
;; package.el initialization and package installation checks at startup.
|
|
|
|
;; 5. Simplicity: Without Cask, I have no external dependencies to worry about
|
|
|
|
;; (unless make counts). DOOM handles itself. Arguably, my emacs.d is
|
|
|
|
;; overcomplicated, but configuring is simpler as a result (well, for me
|
|
|
|
;; anyway :P).
|
2017-02-06 00:13:24 -05:00
|
|
|
;;
|
2017-02-11 06:00:08 -05:00
|
|
|
;; It should be safe to use package.el functionality, however, avoid
|
|
|
|
;; `package-autoremove' as it may not reliably select the right packages to
|
|
|
|
;; delete.
|
2017-02-09 04:25:32 -05:00
|
|
|
;;
|
2017-02-11 06:00:08 -05:00
|
|
|
;; For complete certainty, I've provided DOOM alternatives of package commands,
|
|
|
|
;; like `doom/install-package', `doom/delete-package' and
|
|
|
|
;; `doom/update-packages'. As well as: `doom/packages-install',
|
|
|
|
;; `doom/packages-update' and `doom/packages-autoremove', which are called from
|
|
|
|
;; the Makefile tasks.
|
2017-02-06 00:13:24 -05:00
|
|
|
;;
|
|
|
|
;; See core/autoload/packages.el for more functions.
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-02-03 07:58:16 -05:00
|
|
|
(defvar doom-init-p nil
|
2017-02-01 00:29:39 -05:00
|
|
|
"Non-nil if doom's package system has been initialized or not. It may not be
|
2017-02-11 06:00:08 -05:00
|
|
|
if you have byte-compiled your configuration (as intended). Running
|
|
|
|
`doom-initialize' sets this.")
|
|
|
|
|
|
|
|
(defvar doom-modules nil
|
2017-02-13 04:47:20 -05:00
|
|
|
"A hash table of enabled modules.")
|
2017-01-31 04:31:14 -05:00
|
|
|
|
2017-02-11 06:00:08 -05:00
|
|
|
(defvar doom-packages nil
|
|
|
|
"A list of enabled packages. Each element is a sublist, whose CAR is the
|
|
|
|
package's name as a symbol, and whose CDR is the plist supplied to its
|
|
|
|
`@package' declaration.")
|
|
|
|
|
|
|
|
(defvar doom-protected-packages
|
|
|
|
'(quelpa use-package dash f s)
|
|
|
|
"A list of packages that must be installed (and will be auto-installed if
|
|
|
|
missing) and shouldn't be deleted.")
|
|
|
|
|
|
|
|
(defvar doom--base-load-path
|
|
|
|
(append (list doom-core-dir doom-modules-dir)
|
|
|
|
load-path)
|
|
|
|
"A backup of `load-path' before it was altered by `doom-initialize'. Used as a
|
|
|
|
base when running `doom/reload', or by `@doom', for calculating how many
|
|
|
|
packages exist.")
|
2017-01-16 23:15:48 -05:00
|
|
|
|
|
|
|
(setq load-prefer-newer nil
|
|
|
|
package--init-file-ensured t
|
|
|
|
package-user-dir (expand-file-name "elpa" doom-packages-dir)
|
|
|
|
package-enable-at-startup nil
|
|
|
|
package-archives
|
|
|
|
'(("gnu" . "http://elpa.gnu.org/packages/")
|
|
|
|
("melpa" . "http://melpa.org/packages/")
|
|
|
|
("org" . "http://orgmode.org/elpa/"))
|
2017-02-11 00:46:42 -05:00
|
|
|
;; I omit Marmalade because its packages are manually submitted rather
|
|
|
|
;; than pulled, so packages are often out of date with upstream.
|
2017-01-16 23:15:48 -05:00
|
|
|
|
|
|
|
use-package-always-defer t
|
2017-01-28 02:02:16 -05:00
|
|
|
use-package-always-ensure nil
|
2017-02-02 04:37:59 -05:00
|
|
|
use-package-expand-minimally t
|
2017-02-02 21:54:47 -05:00
|
|
|
use-package-debug nil
|
2017-01-31 04:31:14 -05:00
|
|
|
use-package-verbose doom-debug-mode
|
2017-02-06 01:23:24 -05:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
quelpa-checkout-melpa-p nil
|
|
|
|
quelpa-update-melpa-p nil
|
2017-01-31 18:59:58 -05:00
|
|
|
quelpa-dir (expand-file-name "quelpa" doom-packages-dir)
|
2017-02-06 01:23:24 -05:00
|
|
|
|
|
|
|
byte-compile-dynamic t
|
|
|
|
byte-compile-warnings '(not mapcar free-vars unresolved noruntime lexical make-local))
|
2017-01-16 23:15:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
2017-01-31 04:31:14 -05:00
|
|
|
;; Bootstrap function
|
2017-01-16 23:15:48 -05:00
|
|
|
;;
|
|
|
|
|
2017-01-31 04:31:14 -05:00
|
|
|
(defun doom-initialize (&optional force-p)
|
2017-02-02 04:37:59 -05:00
|
|
|
"Initialize installed packages (using package.el) and ensure the core packages
|
2017-02-13 04:49:53 -05:00
|
|
|
are installed. If you byte-compile core/core.el, this function will be avoided
|
2017-02-11 05:59:16 -05:00
|
|
|
to speed up startup."
|
2017-02-13 04:49:53 -05:00
|
|
|
;; Called early during initialization; only use native functions!
|
2017-02-03 07:58:16 -05:00
|
|
|
(unless (or doom-init-p force-p)
|
|
|
|
(setq load-path doom--base-load-path
|
2017-01-31 04:31:14 -05:00
|
|
|
package-activated-list nil)
|
2017-02-11 05:59:16 -05:00
|
|
|
|
|
|
|
;; Ensure cache folder exists
|
|
|
|
(mapc (lambda (dir)
|
|
|
|
(unless (file-directory-p dir)
|
|
|
|
(make-directory dir t)))
|
|
|
|
(list doom-cache-dir package-user-dir))
|
|
|
|
|
2017-02-03 19:20:47 -05:00
|
|
|
(package-initialize t)
|
2017-02-13 04:49:53 -05:00
|
|
|
;; Sure, `package-initialize' could fill `load-path', but package activation
|
|
|
|
;; costs precious milliseconds, and my premature optimization quota isn't
|
|
|
|
;; filled yet. UNACCEPTAABBLLLE!
|
|
|
|
;;
|
|
|
|
;; Also, in some edge cases involving package initialization during a
|
|
|
|
;; non-interactive session, `package-initialize' fails to fill `load-path'.
|
2017-02-06 00:13:24 -05:00
|
|
|
(setq load-path (append load-path (directory-files package-user-dir t "^[a-zA-Z0-9]" t)))
|
|
|
|
|
2017-02-09 04:25:32 -05:00
|
|
|
;; Ensure core packages are installed
|
2017-02-11 05:59:16 -05:00
|
|
|
(let ((core-packages (cl-remove-if 'package-installed-p doom-protected-packages)))
|
|
|
|
(when core-packages
|
|
|
|
(package-refresh-contents)
|
|
|
|
(dolist (pkg core-packages)
|
|
|
|
(let ((inhibit-message t))
|
|
|
|
(package-install pkg))
|
|
|
|
(if (package-installed-p pkg)
|
|
|
|
(message "Installed %s" pkg)
|
|
|
|
(error "Couldn't install %s" pkg)))))
|
2017-02-03 07:58:16 -05:00
|
|
|
|
|
|
|
(require 'quelpa)
|
|
|
|
(require 'use-package)
|
2017-02-11 05:59:16 -05:00
|
|
|
;; Remove package management keywords, I'll deal with that myself
|
2017-02-03 07:58:16 -05:00
|
|
|
(mapc (lambda (keyword) (setq use-package-keywords (delq keyword use-package-keywords)))
|
|
|
|
'(:ensure :pin))
|
2017-02-11 00:46:42 -05:00
|
|
|
|
2017-02-03 07:58:16 -05:00
|
|
|
(setq doom-init-p t)))
|
|
|
|
|
2017-02-06 00:13:24 -05:00
|
|
|
(defun doom-initialize-autoloads (&optional force-p)
|
2017-02-11 06:00:08 -05:00
|
|
|
"Ensures that `doom-autoload-file' exists and is loaded. If it doesn't, run
|
|
|
|
`doom/reload-autoloads' to generate it."
|
2017-02-11 00:46:42 -05:00
|
|
|
(unless (ignore-errors (require 'autoloads doom-autoload-file t))
|
|
|
|
(unless noninteractive
|
|
|
|
(doom/reload-autoloads)
|
|
|
|
(unless (file-exists-p doom-autoload-file)
|
|
|
|
(error "Autoloads file couldn't be generated")))))
|
|
|
|
|
2017-02-13 04:49:32 -05:00
|
|
|
(defun doom-initialize-packages (&optional force-p load-p)
|
|
|
|
"Loads the packages.el files across DOOM Emacs in order to fill `doom-modules'
|
|
|
|
and `doom-packages', if they aren't set already. If FORCE-P is non-nil, do it
|
|
|
|
even if they are."
|
2017-02-11 00:46:42 -05:00
|
|
|
(doom-initialize force-p)
|
2017-02-13 04:49:32 -05:00
|
|
|
(let ((noninteractive t)
|
|
|
|
(load-fn
|
|
|
|
(lambda (file &optional noerror)
|
|
|
|
(condition-case ex
|
|
|
|
(load file noerror :nomessage :nosuffix)
|
|
|
|
('error (message "INIT-PACKAGES ERROR (%s): %s" file ex))))))
|
|
|
|
(when (or force-p (not doom-modules))
|
|
|
|
(setq doom-modules nil)
|
|
|
|
(funcall load-fn (f-expand "init.el" doom-emacs-dir))
|
|
|
|
(when load-p
|
|
|
|
(mapc (lambda (file) (funcall load-fn file t))
|
|
|
|
(append (reverse (f-glob "core*.el" doom-core-dir))
|
|
|
|
(f-glob "autoload/*.el" doom-core-dir)
|
|
|
|
(--map (doom-module-path (car it) (cdr it) "config.el")
|
|
|
|
(doom--module-pairs))))))
|
|
|
|
|
|
|
|
(when (or force-p (not doom-packages))
|
|
|
|
(setq doom-packages nil)
|
|
|
|
(funcall load-fn (f-expand "packages.el" doom-core-dir))
|
|
|
|
(mapc (lambda (file) (funcall load-fn file t))
|
2017-02-11 00:46:42 -05:00
|
|
|
(--map (doom-module-path (car it) (cdr it) "packages.el")
|
2017-02-11 06:00:08 -05:00
|
|
|
(doom--module-pairs))))))
|
2017-02-11 00:46:42 -05:00
|
|
|
|
2017-02-13 04:47:20 -05:00
|
|
|
(defun doom-initialize-modules (modules)
|
|
|
|
"Adds MODULES to `doom-modules'. MODULES must be in mplist format.
|
|
|
|
|
|
|
|
e.g '(:feature evil :lang emacs-lisp javascript java)"
|
|
|
|
(unless doom-modules
|
|
|
|
(setq doom-modules (make-hash-table :test 'equal :size (length modules))))
|
|
|
|
(let (mode)
|
|
|
|
(dolist (m modules)
|
|
|
|
(cond ((keywordp m)
|
|
|
|
(setq mode m))
|
|
|
|
((not mode)
|
|
|
|
(error "No namespace specified on `@doom' for %s" m))
|
|
|
|
((eq m '*)
|
|
|
|
(let ((mode-str (substring (symbol-name mode) 1)))
|
|
|
|
(doom-initialize-modules
|
|
|
|
(cons mode
|
|
|
|
(--map (intern (f-base it))
|
|
|
|
(f-directories (f-expand mode-str doom-modules-dir)))))))
|
|
|
|
(t
|
|
|
|
(doom--enable-module mode m))))))
|
|
|
|
|
2017-02-11 00:46:42 -05:00
|
|
|
(defun doom-module-path (module submodule &optional file)
|
|
|
|
"Get the full path to a module: e.g. :lang emacs-lisp maps to
|
|
|
|
~/.emacs.d/modules/lang/emacs-lisp/ and will append FILE if non-nil."
|
|
|
|
(unless (keywordp module)
|
|
|
|
(error "Expected a keyword, got %s" module))
|
|
|
|
(unless (symbolp submodule)
|
|
|
|
(error "Expected a symbol, got %s" submodule))
|
|
|
|
(let ((module-name (substring (symbol-name module) 1))
|
|
|
|
(submodule-name (symbol-name submodule)))
|
|
|
|
(f-expand (concat module-name "/" submodule-name "/" file)
|
|
|
|
doom-modules-dir)))
|
|
|
|
|
2017-02-11 06:00:08 -05:00
|
|
|
(defun doom-module-loaded-p (module submodule)
|
2017-02-13 04:47:20 -05:00
|
|
|
"Returns t if MODULE->SUBMODULE is present in `doom-modules'."
|
|
|
|
(gethash (cons module submodule) doom-modules))
|
2017-02-11 06:00:08 -05:00
|
|
|
|
|
|
|
(defun doom--module-pairs ()
|
2017-02-13 04:47:20 -05:00
|
|
|
"Returns `doom-modules' as a list of (MODULE . SUBMODULE) cons cells. The list
|
|
|
|
is sorted by order of insertion."
|
|
|
|
(let (pairs)
|
|
|
|
(maphash (lambda (key value)
|
|
|
|
(setq pairs (append pairs (list (cons (car key) (cdr key))))))
|
|
|
|
doom-modules)
|
2017-02-11 00:46:42 -05:00
|
|
|
pairs))
|
|
|
|
|
2017-02-11 06:00:08 -05:00
|
|
|
(defun doom--enable-module (module submodule &optional force-p)
|
|
|
|
"Adds MODULE and SUBMODULE to `doom-modules', if it isn't already there (or if
|
|
|
|
FORCE-P is non-nil). MODULE is a keyword, SUBMODULE is a symbol. e.g. :lang
|
|
|
|
'emacs-lisp.
|
2017-02-11 00:46:42 -05:00
|
|
|
|
2017-02-11 06:00:08 -05:00
|
|
|
Used by `@require' and `@depends-on'."
|
2017-02-11 00:46:42 -05:00
|
|
|
(unless (or force-p (doom-module-loaded-p module submodule))
|
2017-02-13 04:47:20 -05:00
|
|
|
(puthash (cons module submodule) t doom-modules)))
|
2017-02-06 00:13:24 -05:00
|
|
|
|
2017-01-31 04:31:14 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; Macros
|
|
|
|
;;
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-02-11 00:46:42 -05:00
|
|
|
(autoload 'use-package "use-package" nil nil 'macro)
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-02-11 00:46:42 -05:00
|
|
|
(defmacro @doom (&rest modules)
|
|
|
|
"DOOM Emacs bootstrap macro. List the modules to load. Benefits from
|
|
|
|
byte-compilation."
|
2017-02-13 04:47:20 -05:00
|
|
|
(doom-initialize-modules modules)
|
2017-02-11 00:46:42 -05:00
|
|
|
(unless noninteractive
|
|
|
|
`(let (file-name-handler-alist)
|
2017-02-11 06:00:08 -05:00
|
|
|
(setq doom-modules ',doom-modules)
|
|
|
|
|
2017-02-13 04:47:20 -05:00
|
|
|
,@(mapcar (lambda (module) `(@require ,(car module) ,(cdr module) t))
|
2017-02-11 06:00:08 -05:00
|
|
|
(doom--module-pairs))
|
2017-02-11 00:46:42 -05:00
|
|
|
|
|
|
|
(when (display-graphic-p)
|
|
|
|
(require 'server)
|
|
|
|
(unless (server-running-p)
|
|
|
|
(server-start)))
|
|
|
|
|
|
|
|
;; Benchmark
|
|
|
|
(format "Loaded %s packages in %s"
|
|
|
|
(- (length load-path) (length doom--base-load-path))
|
|
|
|
(emacs-init-time)))))
|
|
|
|
|
|
|
|
(defalias '@def-package 'use-package
|
2017-02-06 00:13:24 -05:00
|
|
|
"A `use-package' alias. It exists so DOOM configs adhere to the naming
|
2017-02-11 00:46:42 -05:00
|
|
|
conventions of DOOM emacs. Note that packages are deferred by default.")
|
|
|
|
|
|
|
|
(defmacro @load (filesym &optional path noerror)
|
2017-02-11 06:00:08 -05:00
|
|
|
"Loads a file relative to the current module (or PATH). FILESYM is a file path
|
|
|
|
as a symbol. PATH is a directory to prefix it with. If NOERROR is non-nil, don't
|
|
|
|
throw an error if the file doesn't exist.
|
|
|
|
|
|
|
|
Sets `__FILE__' and `__DIR__' on the loaded file."
|
2017-02-13 04:49:32 -05:00
|
|
|
(let ((path (or (and path (eval path)) (__DIR__))))
|
2017-02-11 00:46:42 -05:00
|
|
|
(unless path
|
|
|
|
(error "Could not find %s" filesym))
|
2017-02-11 06:00:08 -05:00
|
|
|
(let ((file (f-expand (concat (symbol-name filesym) ".el") path)))
|
|
|
|
(if (f-exists-p file)
|
|
|
|
`(let ((__FILE__ ,file)
|
|
|
|
(__DIR__ ,path))
|
|
|
|
(load ,(f-no-ext file) ,noerror (not doom-debug-mode)))
|
|
|
|
(unless noerror
|
|
|
|
(error "Could not @load file %s" file))))))
|
2017-02-11 00:46:42 -05:00
|
|
|
|
|
|
|
(defmacro @require (module submodule &optional reload-p)
|
2017-02-11 06:00:08 -05:00
|
|
|
"Like `require', but for doom modules. Will load a module's config.el file if
|
|
|
|
it hasn't already, and if it exists."
|
2017-02-11 00:46:42 -05:00
|
|
|
(unless noninteractive
|
|
|
|
(let ((loaded-p (doom-module-loaded-p module submodule)))
|
|
|
|
(when (or reload-p (not loaded-p))
|
|
|
|
(unless loaded-p
|
2017-02-11 06:00:08 -05:00
|
|
|
(doom--enable-module module submodule t))
|
2017-02-11 00:46:42 -05:00
|
|
|
`(@load config ,(doom-module-path module submodule) t)))))
|
|
|
|
|
2017-02-11 06:52:38 -05:00
|
|
|
(defmacro @featurep (module submodule)
|
|
|
|
"Convenience macro that wraps `doom-module-loaded-p'."
|
|
|
|
`(doom-module-loaded-p ,module ',submodule))
|
|
|
|
|
2017-02-06 00:13:24 -05:00
|
|
|
|
2017-02-11 00:46:42 -05:00
|
|
|
;;
|
|
|
|
;; Declarative macros
|
|
|
|
;;
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-02-09 04:22:08 -05:00
|
|
|
(defmacro @package (name &rest plist)
|
2017-02-13 04:49:53 -05:00
|
|
|
"Declares a package and how to install it (if applicable). This does not load
|
|
|
|
nor install them.
|
2017-02-04 21:07:54 -05:00
|
|
|
|
2017-02-11 00:46:42 -05:00
|
|
|
Accepts the following properties:
|
2017-02-03 20:10:40 -05:00
|
|
|
|
2017-02-13 04:49:53 -05:00
|
|
|
:recipe RECIPE Takes a MELPA-style recipe (see `quelpa-recipe' in
|
|
|
|
`quelpa' for an example); for packages to be installed
|
|
|
|
from external sources.
|
2017-02-03 20:10:40 -05:00
|
|
|
:pin ARCHIVE-NAME Instructs ELPA to only look for this package in
|
2017-02-13 04:49:53 -05:00
|
|
|
ARCHIVE-NAME. e.g. \"org\". Ignored if RECIPE is present.
|
|
|
|
|
|
|
|
This macro serves a purely declarative purpose, and are used to fill
|
|
|
|
`doom-packages', so that functions like `doom/packages-install' can operate on
|
|
|
|
them. "
|
2017-01-16 23:15:48 -05:00
|
|
|
(declare (indent defun))
|
2017-02-11 00:46:42 -05:00
|
|
|
(let ((pkg-recipe (plist-get plist :recipe))
|
|
|
|
(pkg-pin (plist-get plist :pin)))
|
|
|
|
(when (= 0 (mod (length pkg-recipe) 2))
|
|
|
|
(plist-put plist :recipe (cons name pkg-recipe)))
|
2017-02-13 04:49:53 -05:00
|
|
|
(when (and pkg-recipe pkg-pin)
|
|
|
|
(plist-put plist :pkg-pin nil))
|
2017-02-11 00:46:42 -05:00
|
|
|
`(add-to-list 'doom-packages ',(cons name plist) t)))
|
2017-01-28 02:02:16 -05:00
|
|
|
|
2017-02-11 00:46:42 -05:00
|
|
|
(defmacro @depends-on (module submodule)
|
|
|
|
"Declares that this module depends on another. MODULE is a keyword, and
|
|
|
|
SUBMODULE is a symbol."
|
2017-02-11 06:52:29 -05:00
|
|
|
(doom--enable-module module submodule)
|
2017-02-11 00:46:42 -05:00
|
|
|
`(@load packages ,(doom-module-path module submodule) t))
|
2017-01-31 19:42:11 -05:00
|
|
|
|
2017-01-31 04:31:14 -05:00
|
|
|
|
|
|
|
;;
|
2017-02-03 07:58:16 -05:00
|
|
|
;; Commands
|
2017-01-31 04:31:14 -05:00
|
|
|
;;
|
|
|
|
|
2017-02-03 07:58:16 -05:00
|
|
|
(defun doom/reload ()
|
2017-02-11 00:46:42 -05:00
|
|
|
"Reload `load-path' by reinitializing package.el and reloading autoloads."
|
2017-02-03 07:58:16 -05:00
|
|
|
(interactive)
|
|
|
|
(doom-initialize t)
|
2017-02-11 00:46:42 -05:00
|
|
|
(doom/reload-autoloads)
|
2017-02-03 07:58:16 -05:00
|
|
|
(message "Reloaded %s packages" (length package-alist)))
|
|
|
|
|
2017-02-11 00:46:42 -05:00
|
|
|
(defun doom/reload-autoloads ()
|
2017-02-02 04:37:59 -05:00
|
|
|
"Refreshes the autoloads.el file, which tells Emacs where to find all the
|
2017-02-13 04:49:53 -05:00
|
|
|
autoloaded functions in enabled modules or among the core libraries, e.g.
|
2017-02-06 00:12:44 -05:00
|
|
|
core/autoload/*.el.
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-02-06 00:12:44 -05:00
|
|
|
In modules, checks modules/*/autoload.el and modules/*/autoload/*.el.
|
2017-02-03 19:20:47 -05:00
|
|
|
|
2017-02-06 00:12:44 -05:00
|
|
|
Rerun this whenever init.el is modified. You can also use `make autoloads` from
|
|
|
|
the commandline."
|
2017-01-16 23:15:48 -05:00
|
|
|
(interactive)
|
2017-02-11 00:46:42 -05:00
|
|
|
(doom-initialize-packages noninteractive)
|
2017-02-06 00:12:44 -05:00
|
|
|
(let ((generated-autoload-file doom-autoload-file)
|
2017-02-13 04:50:04 -05:00
|
|
|
(autoload-files
|
|
|
|
(append (-flatten (--map (let ((auto-dir (f-expand "autoload" it))
|
|
|
|
(auto-file (f-expand "autoload.el" it)))
|
|
|
|
(append (and (f-exists-p auto-file)
|
|
|
|
(list auto-file))
|
|
|
|
(and (f-directory-p auto-dir)
|
|
|
|
(f-glob "*.el" auto-dir))))
|
|
|
|
(--map (doom-module-path (car it) (cdr it))
|
|
|
|
(doom--module-pairs))))
|
|
|
|
(f-glob "autoload/*.el" doom-core-dir))))
|
2017-02-04 21:07:54 -05:00
|
|
|
(when (f-exists-p generated-autoload-file)
|
|
|
|
(f-delete generated-autoload-file)
|
|
|
|
(message "Deleted old autoloads.el"))
|
|
|
|
(dolist (file autoload-files)
|
2017-02-13 04:50:04 -05:00
|
|
|
(let ((inhibit-message t))
|
|
|
|
(update-file-autoloads file))
|
2017-02-04 21:07:54 -05:00
|
|
|
(message "Scanned %s" (f-relative file doom-emacs-dir)))
|
2017-02-11 00:46:42 -05:00
|
|
|
(condition-case ex
|
|
|
|
(with-current-buffer (get-file-buffer generated-autoload-file)
|
|
|
|
(save-buffer)
|
|
|
|
(eval-buffer)
|
|
|
|
(message "Done!"))
|
|
|
|
('error (error "Couldn't evaluate autoloads.el: %s" (cadr ex))))))
|
|
|
|
|
|
|
|
(defun doom/recompile (&optional simple-p)
|
2017-02-06 00:12:44 -05:00
|
|
|
"Byte (re)compile the important files in your emacs configuration (init.el &
|
|
|
|
core/*.el). DOOM Emacs was designed to benefit from this.
|
2017-02-02 21:56:40 -05:00
|
|
|
|
2017-02-06 00:12:44 -05:00
|
|
|
If SIMPLE-P is nil, also byte-compile modules/*/*/*.el (except for packages.el).
|
|
|
|
There should be a measurable benefit from this, but it may take a while."
|
2017-01-16 23:15:48 -05:00
|
|
|
(interactive)
|
2017-02-13 04:49:32 -05:00
|
|
|
;; Ensure all relevant config files are loaded. This way we don't need
|
|
|
|
;; eval-when-compile and require blocks scattered all over.
|
|
|
|
(doom-initialize-packages t noninteractive)
|
2017-02-06 00:12:44 -05:00
|
|
|
(let ((targets
|
|
|
|
(append (list (f-expand "init.el" doom-emacs-dir)
|
|
|
|
(f-expand "core.el" doom-core-dir))
|
|
|
|
(f-glob "core-*.el" doom-core-dir)
|
2017-02-13 04:49:32 -05:00
|
|
|
(f-glob "autoload/*.el" doom-core-dir)
|
2017-02-06 00:12:44 -05:00
|
|
|
(unless simple-p
|
|
|
|
(-flatten
|
|
|
|
(--map (f--entries (doom-module-path (car it) (cdr it))
|
2017-02-13 04:49:32 -05:00
|
|
|
(and (f-ext-p it "el")
|
|
|
|
(let ((fname (f-filename it)))
|
|
|
|
(or (string= fname "config.el")
|
|
|
|
(s-prefix-p "+" fname t))))
|
|
|
|
t)
|
2017-02-11 06:00:08 -05:00
|
|
|
(doom--module-pairs))))))
|
2017-02-03 07:58:16 -05:00
|
|
|
(n 0)
|
|
|
|
results)
|
2017-02-04 21:07:54 -05:00
|
|
|
(dolist (file targets)
|
|
|
|
(push (cons (f-relative file doom-emacs-dir)
|
2017-02-11 06:00:08 -05:00
|
|
|
(and (byte-recompile-file file nil 0)
|
|
|
|
(setq n (1+ n))))
|
2017-02-04 21:07:54 -05:00
|
|
|
results))
|
2017-01-31 19:44:31 -05:00
|
|
|
(when noninteractive
|
2017-02-11 06:00:08 -05:00
|
|
|
(if targets (message "\n"))
|
2017-02-04 21:07:54 -05:00
|
|
|
(message "Compiled %s files:\n%s" n
|
2017-02-02 04:37:59 -05:00
|
|
|
(mapconcat (lambda (file) (concat "+ " (if (cdr file) "SUCCESS" "FAIL") ": " (car file)))
|
|
|
|
(reverse results) "\n")))))
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-02-11 00:46:42 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; Package.el modifications
|
|
|
|
;;
|
|
|
|
|
|
|
|
(advice-add 'package-delete :after 'doom*package-delete)
|
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(provide 'core-packages)
|
|
|
|
;;; core-packages.el ends here
|