2016-05-23 06:26:28 -04:00
|
|
|
;;; core-defuns.el
|
|
|
|
|
|
|
|
;; Bootstrap macro
|
2016-10-04 22:52:43 +02:00
|
|
|
(defmacro doom (&rest packages)
|
2016-05-23 06:26:28 -04:00
|
|
|
"Bootstrap DOOM emacs and initialize PACKAGES"
|
2016-05-28 21:51:21 -04:00
|
|
|
`(let (file-name-handler-alist)
|
2016-10-02 23:23:35 +02:00
|
|
|
;; Local settings
|
|
|
|
(load "~/.emacs.local.el" t t)
|
|
|
|
;; Bootstrap
|
2016-05-23 06:26:28 -04:00
|
|
|
(unless noninteractive
|
2016-06-17 15:39:04 -04:00
|
|
|
,@(mapcar (lambda (pkg)
|
|
|
|
(let ((lib-path (locate-library (symbol-name pkg))))
|
|
|
|
(unless lib-path
|
|
|
|
(error "Initfile not found: %s" pkg))
|
2016-10-02 23:23:35 +02:00
|
|
|
`(require ',pkg ,(file-name-sans-extension lib-path))))
|
2016-05-23 06:26:28 -04:00
|
|
|
packages)
|
2016-05-28 21:51:21 -04:00
|
|
|
(when window-system
|
2016-05-23 06:26:28 -04:00
|
|
|
(require 'server)
|
|
|
|
(unless (server-running-p)
|
|
|
|
(server-start)))
|
|
|
|
;; Prevent any auto-displayed text + benchmarking
|
|
|
|
(advice-add 'display-startup-echo-area-message :override 'ignore)
|
2016-05-28 21:51:21 -04:00
|
|
|
(message ""))
|
|
|
|
(setq-default gc-cons-threshold 4388608
|
|
|
|
gc-cons-percentage 0.4)))
|
2016-05-23 06:26:28 -04:00
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
;; Backwards compatible `with-eval-after-load'
|
|
|
|
(unless (fboundp 'with-eval-after-load)
|
|
|
|
(defmacro with-eval-after-load (file &rest body)
|
|
|
|
`(eval-after-load ,file (lambda () ,@body))))
|
|
|
|
|
2015-12-11 22:43:31 -05:00
|
|
|
(defmacro λ! (&rest body)
|
2016-05-23 06:26:28 -04:00
|
|
|
"A shortcut for inline keybind lambdas."
|
2015-06-15 09:05:52 +02:00
|
|
|
`(lambda () (interactive) ,@body))
|
|
|
|
|
|
|
|
(defmacro shut-up! (&rest body)
|
|
|
|
"Silence message output from code."
|
|
|
|
(declare (indent defun))
|
|
|
|
`(let (message-log-max) ,@body (message "")))
|
|
|
|
|
|
|
|
(defmacro after! (feature &rest forms)
|
|
|
|
"A smart wrapper around `with-eval-after-load', that supresses warnings
|
|
|
|
during compilation."
|
|
|
|
(declare (indent defun) (debug t))
|
|
|
|
`(,(if (or (not (boundp 'byte-compile-current-file))
|
|
|
|
(not byte-compile-current-file)
|
|
|
|
(if (symbolp feature)
|
|
|
|
(require feature nil :no-error)
|
|
|
|
(load feature :no-message :no-error)))
|
|
|
|
'progn
|
|
|
|
(message "after: cannot find %s" feature)
|
|
|
|
'with-no-warnings)
|
|
|
|
(with-eval-after-load ',feature ,@forms)))
|
|
|
|
|
2016-05-23 06:26:28 -04:00
|
|
|
(defmacro noop! (name &optional args)
|
|
|
|
`(defun ,name ,args (interactive) (error "%s not implemented!" name)))
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
(defmacro add-hook! (hook &rest func-or-forms)
|
|
|
|
"A convenience macro for `add-hook'.
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
|
|
HOOK can be one hook or a list of hooks. If the hook(s) are not quoted, -hook is
|
|
|
|
appended to them automatically. If they are quoted, they are used verbatim.
|
|
|
|
|
2016-05-11 05:36:49 -04:00
|
|
|
FUNC-OR-FORMS can be a quoted symbol, a list of quoted symbols, or forms. Forms will be
|
|
|
|
wrapped in a lambda. A list of symbols will expand into a series of add-hook calls.
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
|
|
Examples:
|
2015-06-15 09:05:52 +02:00
|
|
|
(add-hook! 'some-mode-hook 'enable-something)
|
|
|
|
(add-hook! some-mode '(enable-something and-another))
|
|
|
|
(add-hook! '(one-mode-hook second-mode-hook) 'enable-something)
|
|
|
|
(add-hook! (one-mode second-mode) 'enable-something)
|
2016-05-11 05:36:49 -04:00
|
|
|
(add-hook! (one-mode second-mode) (setq v 5) (setq a 2))"
|
2015-06-15 09:05:52 +02:00
|
|
|
(declare (indent defun) (debug t))
|
|
|
|
(unless func-or-forms
|
|
|
|
(error "add-hook!: FUNC-OR-FORMS is empty"))
|
|
|
|
(let* ((val (car func-or-forms))
|
|
|
|
(quoted (eq (car-safe hook) 'quote))
|
|
|
|
(hook (if quoted (cadr hook) hook))
|
|
|
|
(funcs (if (eq (car-safe val) 'quote)
|
|
|
|
(if (cdr-safe (cadr val))
|
|
|
|
(cadr val)
|
|
|
|
(list (cadr val)))
|
|
|
|
(list func-or-forms)))
|
|
|
|
(forms '()))
|
|
|
|
(mapc
|
2016-05-12 22:11:43 -04:00
|
|
|
(lambda (f)
|
|
|
|
(let ((func (cond ((symbolp f) `(quote ,f))
|
|
|
|
(t `(lambda (&rest _) ,@func-or-forms)))))
|
|
|
|
(mapc
|
|
|
|
(lambda (h)
|
|
|
|
(push `(add-hook ',(if quoted h (intern (format "%s-hook" h))) ,func) forms))
|
|
|
|
(-list hook)))) funcs)
|
2015-06-15 09:05:52 +02:00
|
|
|
`(progn ,@forms)))
|
|
|
|
|
2016-05-12 02:36:11 -04:00
|
|
|
(defmacro associate! (mode &rest rest)
|
2015-06-15 09:05:52 +02:00
|
|
|
"Associate a major or minor mode to certain patterns and project files."
|
|
|
|
(declare (indent 1))
|
2016-05-12 02:36:11 -04:00
|
|
|
(let ((minor (plist-get rest :minor))
|
2016-05-18 02:13:46 -04:00
|
|
|
(in (plist-get rest :in))
|
2016-05-12 02:36:11 -04:00
|
|
|
(match (plist-get rest :match))
|
2016-05-18 02:13:46 -04:00
|
|
|
(files (plist-get rest :files))
|
|
|
|
(pred (plist-get rest :when)))
|
2016-05-12 02:36:11 -04:00
|
|
|
`(progn
|
2016-05-18 02:13:46 -04:00
|
|
|
(,@(cond ((or files in pred)
|
2016-05-12 02:36:11 -04:00
|
|
|
(when (and files (not (or (listp files) (stringp files))))
|
|
|
|
(user-error "associate! :files expects a string or list of strings"))
|
2016-05-20 22:37:30 -04:00
|
|
|
(let ((hook-name (intern (format "doom--init-mode-%s" mode))))
|
2016-05-12 02:36:11 -04:00
|
|
|
`(progn
|
|
|
|
(defun ,hook-name ()
|
|
|
|
(when (and ,(if match `(if buffer-file-name (string-match-p ,match buffer-file-name)) t)
|
|
|
|
(or ,(not files)
|
|
|
|
(and (boundp ',mode)
|
|
|
|
(not ,mode)
|
2016-05-20 22:37:30 -04:00
|
|
|
(doom/project-has-files ,@(-list files))))
|
2016-05-18 02:13:46 -04:00
|
|
|
(or (not ,pred)
|
|
|
|
(funcall ,pred buffer-file-name)))
|
2016-05-12 02:36:11 -04:00
|
|
|
(,mode 1)))
|
|
|
|
,@(if (and in (listp in))
|
|
|
|
(mapcar (lambda (h) `(add-hook ',h ',hook-name))
|
|
|
|
(mapcar (lambda (m) (intern (format "%s-hook" m))) in))
|
|
|
|
`((add-hook 'find-file-hook ',hook-name))))))
|
|
|
|
(match
|
2016-05-20 22:37:30 -04:00
|
|
|
`(add-to-list ',(if minor 'doom-auto-minor-mode-alist 'auto-mode-alist)
|
2016-05-12 02:36:11 -04:00
|
|
|
(cons ,match ',mode)))
|
|
|
|
(t (user-error "associate! invalid rules for mode [%s] (in %s) (match %s) (files %s)"
|
|
|
|
mode in match files)))))))
|
2016-04-16 21:36:24 -04:00
|
|
|
|
2016-04-23 22:08:46 -04:00
|
|
|
(defmacro def-project-type! (name lighter &rest body)
|
2016-05-01 00:58:42 -04:00
|
|
|
"Define a minor mode for a specific framework, library or project type."
|
2016-04-16 21:36:24 -04:00
|
|
|
(declare (indent 2))
|
|
|
|
(let* ((mode-name (format "%s-project-mode" name))
|
|
|
|
(mode (intern mode-name))
|
2016-05-01 00:58:42 -04:00
|
|
|
(mode-map (intern (format "%s-map" mode-name)))
|
|
|
|
(mode-hook-sym (intern (format "%s-hook" mode-name)))
|
2016-05-20 22:37:30 -04:00
|
|
|
(mode-init-sym (intern (format "doom--init-project-%s" mode-name))))
|
2016-04-16 21:36:24 -04:00
|
|
|
(let ((modes (plist-get body :modes))
|
2016-05-18 02:13:46 -04:00
|
|
|
(pred (plist-get body :when))
|
2016-04-16 21:36:24 -04:00
|
|
|
(match (plist-get body :match))
|
|
|
|
(files (plist-get body :files))
|
|
|
|
(build (plist-get body :build))
|
|
|
|
(bind (plist-get body :bind))
|
|
|
|
elem)
|
|
|
|
(while (keywordp (car body))
|
|
|
|
(pop body)
|
|
|
|
(pop body))
|
|
|
|
`(progn
|
|
|
|
(define-minor-mode ,mode
|
2016-04-23 22:08:46 -04:00
|
|
|
"Auto-generated by `def-project-type!'"
|
2016-04-16 21:36:24 -04:00
|
|
|
:init-value nil
|
|
|
|
:lighter ,(concat " " lighter)
|
2016-05-01 00:58:42 -04:00
|
|
|
:keymap (make-sparse-keymap))
|
2016-04-16 21:36:24 -04:00
|
|
|
|
2016-06-03 00:45:39 -04:00
|
|
|
(after! yasnippet
|
|
|
|
(add-hook ',mode-hook-sym
|
|
|
|
(lambda ()
|
|
|
|
(if ,mode
|
|
|
|
(yas-activate-extra-mode ',mode)
|
|
|
|
(yas-deactivate-extra-mode ',mode)))))
|
|
|
|
|
2016-05-01 00:58:42 -04:00
|
|
|
,(when bind `(map! :map ,mode-map ,bind))
|
2016-04-16 21:36:24 -04:00
|
|
|
|
|
|
|
(associate! ,mode
|
|
|
|
:minor t
|
|
|
|
:in ,modes
|
|
|
|
:match ,match
|
2016-05-18 02:13:46 -04:00
|
|
|
:files ,files
|
|
|
|
:when ,pred)
|
2016-04-16 21:36:24 -04:00
|
|
|
|
2016-05-01 00:58:42 -04:00
|
|
|
(defun ,mode-init-sym ()
|
|
|
|
(after! company-dict
|
|
|
|
(push ',mode company-dict-minor-mode-list))
|
|
|
|
,(when build
|
2016-05-02 15:58:10 -04:00
|
|
|
(let ((cmd build) file)
|
|
|
|
(when (and (not (functionp build)) (listp build))
|
|
|
|
(setq cmd (car-safe (cdr-safe build))
|
|
|
|
file (cdr-safe (cdr-safe build))))
|
2016-05-01 00:58:42 -04:00
|
|
|
`(def-builder! ,mode ,cmd ,file)))
|
|
|
|
,@body
|
|
|
|
(remove-hook ',mode-hook-sym ',mode-init-sym))
|
|
|
|
(add-hook ',mode-hook-sym ',mode-init-sym)
|
2016-04-16 21:36:24 -04:00
|
|
|
',mode))))
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
|
|
|
|
(after! evil
|
2016-05-20 09:04:39 -04:00
|
|
|
(defalias 'ex! 'evil-ex-define-cmd)
|
|
|
|
|
2016-06-08 14:43:40 -04:00
|
|
|
;; NOTE evil-mode doesn't read local `evil-ex-commands', and will not
|
|
|
|
;; autocomplete local commands.
|
2016-06-08 03:50:20 -04:00
|
|
|
(defun ex-local! (cmd fn)
|
|
|
|
"Define a buffer-local ex command."
|
|
|
|
(unless (local-variable-p 'evil-ex-commands)
|
|
|
|
(setq-local evil-ex-commands (copy-alist evil-ex-commands)))
|
|
|
|
(evil-ex-define-cmd cmd fn))
|
|
|
|
|
2015-11-30 05:31:20 -05:00
|
|
|
;; Register keywords for proper indentation (see `map!')
|
2017-01-02 20:59:28 -05:00
|
|
|
(put ':prefix 'lisp-indent-function 'defun)
|
|
|
|
(put ':map 'lisp-indent-function 'defun)
|
|
|
|
(put ':map* 'lisp-indent-function 'defun)
|
|
|
|
(put ':after 'lisp-indent-function 'defun)
|
|
|
|
(put ':when 'lisp-indent-function 'defun)
|
|
|
|
(put ':unless 'lisp-indent-function 'defun)
|
|
|
|
(put ':leader 'lisp-indent-function 'defun)
|
|
|
|
(put ':localleader 'lisp-indent-function 'defun)
|
2015-11-30 05:31:20 -05:00
|
|
|
|
|
|
|
(defmacro map! (&rest rest)
|
2017-01-02 15:23:26 -05:00
|
|
|
"A nightmare of a key-binding macro that will use `evil-define-key',
|
|
|
|
`evil-define-key*', `define-key' and `global-set-key' depending on context and
|
|
|
|
plist key flags. It was designed to make binding multiple keys more concise,
|
|
|
|
like in vim.
|
|
|
|
|
2017-01-02 20:59:28 -05:00
|
|
|
Yes, it tries to do too much. Yes, I only did it to make the \"frontend\" config
|
|
|
|
that little bit more concise. Yes, I could simply have used the above functions.
|
|
|
|
But it takes a little insanity to custom write your own emacs.d, so what else
|
|
|
|
were you expecting?
|
|
|
|
|
2017-01-02 15:23:26 -05:00
|
|
|
States
|
|
|
|
:n normal
|
|
|
|
:v visual
|
|
|
|
:i insert
|
|
|
|
:e emacs
|
|
|
|
:o operator
|
|
|
|
:m motion
|
|
|
|
:r replace
|
2017-01-02 20:59:28 -05:00
|
|
|
:L local
|
2017-01-02 15:23:26 -05:00
|
|
|
|
|
|
|
These can be combined (order doesn't matter), e.g. :nvi will apply to
|
|
|
|
normal, visual and insert mode. The state resets after the following
|
|
|
|
key=>def pair.
|
|
|
|
|
2017-01-02 20:59:28 -05:00
|
|
|
Capitalize the state flag to make it a local binding.
|
|
|
|
|
2017-01-02 15:23:26 -05:00
|
|
|
If omitted, the keybind will be defined globally.
|
|
|
|
|
|
|
|
Flags
|
2017-01-02 20:59:28 -05:00
|
|
|
:unset [KEY] ; unset key
|
|
|
|
(:map [KEYMAP] [...]) ; apply inner keybinds to KEYMAP
|
|
|
|
(:map* [KEYMAP] [...]) ; apply inner keybinds to KEYMAP (deferred)
|
|
|
|
(:prefix [PREFIX] [...]) ; assign prefix to all inner keybindings
|
|
|
|
(:after [FEATURE] [...]) ; apply keybinds when [FEATURE] loads
|
2017-01-02 15:23:26 -05:00
|
|
|
|
|
|
|
Conditional keybinds
|
|
|
|
(:when [CONDITION] [...])
|
|
|
|
(:unless [CONDITION] [...])
|
|
|
|
|
|
|
|
Example
|
|
|
|
(map! :map magit-mode-map
|
|
|
|
:m \"C-r\" 'do-something ; assign C-r in motion state
|
|
|
|
:nv \"q\" 'magit-mode-quit-window ; assign to 'q' in normal and visual states
|
|
|
|
\"C-x C-r\" 'a-global-keybind
|
|
|
|
|
|
|
|
(:when IS-MAC
|
|
|
|
:n \"M-s\" 'some-fn
|
|
|
|
:i \"M-o\" (lambda (interactive) (message \"Hi\"))))"
|
2017-01-02 20:59:28 -05:00
|
|
|
(let ((keymaps (if (boundp 'keymaps) keymaps))
|
2015-06-15 09:05:52 +02:00
|
|
|
(state-map '(("n" . normal)
|
|
|
|
("v" . visual)
|
|
|
|
("i" . insert)
|
|
|
|
("e" . emacs)
|
|
|
|
("o" . operator)
|
|
|
|
("m" . motion)
|
2015-11-30 05:31:20 -05:00
|
|
|
("r" . replace)))
|
2015-12-09 02:10:44 -05:00
|
|
|
(prefix (if (boundp 'prefix) prefix))
|
2017-01-02 20:59:28 -05:00
|
|
|
(defer (if (boundp 'defer) defer))
|
|
|
|
local key def states forms)
|
2015-06-15 09:05:52 +02:00
|
|
|
(while rest
|
|
|
|
(setq key (pop rest))
|
2016-04-19 22:15:18 -04:00
|
|
|
(push
|
2016-05-20 01:47:11 -04:00
|
|
|
(reverse
|
2017-01-02 20:59:28 -05:00
|
|
|
(cond
|
|
|
|
;; it's a sub expr
|
|
|
|
((listp key)
|
|
|
|
`(,(macroexpand `(map! ,@key))))
|
|
|
|
|
|
|
|
;; it's a flag
|
|
|
|
((keywordp key)
|
|
|
|
(when (memq key '(:leader :localleader))
|
|
|
|
(push (cond ((eq key :leader)
|
|
|
|
doom-leader)
|
|
|
|
((eq key :localleader)
|
|
|
|
doom-localleader))
|
|
|
|
rest)
|
|
|
|
(setq key :prefix))
|
|
|
|
(pcase key
|
|
|
|
(:prefix (setq prefix (concat prefix (kbd (pop rest)))) nil)
|
|
|
|
(:map (setq keymaps (-list (pop rest))) nil)
|
|
|
|
(:map* (setq defer t keymaps (-list (pop rest))) nil)
|
|
|
|
(:unset `(,(macroexpand `(map! ,(kbd (pop rest)) nil))))
|
|
|
|
(:after (prog1 `((after! ,(pop rest) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
|
|
|
|
(:when (prog1 `((if ,(pop rest) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
|
|
|
|
(:unless (prog1 `((if (not ,(pop rest)) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
|
|
|
|
(otherwise ; might be a state prefix
|
|
|
|
(mapc (lambda (letter)
|
|
|
|
(cond ((assoc letter state-map)
|
|
|
|
(push (cdr (assoc letter state-map)) states))
|
|
|
|
((string= letter "L")
|
|
|
|
(setq local t))
|
|
|
|
(t (user-error "Invalid mode prefix %s in key %s" letter key))))
|
|
|
|
(split-string (substring (symbol-name key) 1) "" t))
|
|
|
|
(unless states
|
|
|
|
(user-error "Unrecognized keyword %s" key))
|
|
|
|
(when (assoc "L" states)
|
|
|
|
(cond ((= (length states) 1)
|
|
|
|
(user-error "local keybinding for %s must accompany another state" key))
|
|
|
|
((> (length keymaps) 0)
|
|
|
|
(user-error "local keybinding for %s cannot accompany a keymap" key))))
|
|
|
|
nil)))
|
|
|
|
|
|
|
|
;; It's a key-def pair
|
|
|
|
((or (stringp key)
|
|
|
|
(characterp key)
|
|
|
|
(vectorp key))
|
|
|
|
(when (stringp key)
|
|
|
|
(setq key (kbd key)))
|
|
|
|
(when prefix
|
|
|
|
(setq key (cond ((vectorp key) (vconcat prefix key))
|
|
|
|
(t (concat prefix key)))))
|
|
|
|
(unless (> (length rest) 0)
|
|
|
|
(user-error "Map has no definition for %s" key))
|
|
|
|
(setq def (pop rest))
|
|
|
|
(let (out-forms)
|
|
|
|
(cond ((and keymaps states)
|
|
|
|
(mapc (lambda (keymap)
|
|
|
|
(push `(,(if defer 'evil-define-key 'evil-define-key*)
|
|
|
|
',states ,keymap ,key ,def)
|
|
|
|
out-forms))
|
|
|
|
keymaps))
|
|
|
|
(keymaps
|
|
|
|
(mapc (lambda (keymap) (push `(define-key ,keymap ,key ,def) out-forms))
|
|
|
|
keymaps))
|
|
|
|
(states
|
|
|
|
(mapc (lambda (state)
|
|
|
|
(push `(define-key
|
|
|
|
(evil-state-property ',state ,(if local :local-keymap :keymap) t)
|
|
|
|
,key ,def)
|
|
|
|
out-forms))
|
|
|
|
states))
|
|
|
|
(t (push `(,(if local 'local-set-key 'global-set-key)
|
|
|
|
,key ,def)
|
|
|
|
out-forms)))
|
|
|
|
(setq states '()
|
|
|
|
local nil)
|
|
|
|
out-forms))
|
|
|
|
|
|
|
|
(t (user-error "Invalid key %s" key))))
|
|
|
|
forms))
|
2016-04-19 22:15:18 -04:00
|
|
|
`(progn ,@(apply #'nconc (delete nil (delete (list nil) (reverse forms))))))))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
2016-05-12 02:53:31 -04:00
|
|
|
(defmacro def-repeat! (command next-func prev-func)
|
|
|
|
"Repeat motions with SPC/S-SPC"
|
|
|
|
`(defadvice ,command
|
2016-05-20 22:37:30 -04:00
|
|
|
(before ,(intern (format "doom-space--%s" (symbol-name command))) activate)
|
2016-05-12 02:53:31 -04:00
|
|
|
(define-key evil-motion-state-map (kbd "SPC") ',next-func)
|
|
|
|
(define-key evil-motion-state-map (kbd "S-SPC") ',prev-func)))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
|
|
|
2016-05-11 05:36:49 -04:00
|
|
|
;;
|
|
|
|
;; Global Defuns
|
|
|
|
;;
|
|
|
|
|
2016-10-02 23:24:20 +02:00
|
|
|
(defsubst --subdirs (path &optional include-self)
|
|
|
|
"Get list of subdirectories in PATH, including PATH is INCLUDE-SELF is
|
|
|
|
non-nil."
|
|
|
|
(let ((result (if include-self (list path) (list))))
|
|
|
|
(mapc (lambda (file)
|
|
|
|
(when (file-directory-p file)
|
|
|
|
(push file result)))
|
|
|
|
(ignore-errors (directory-files path t "^[^.]" t)))
|
|
|
|
result))
|
|
|
|
|
2016-05-20 22:37:30 -04:00
|
|
|
(defun doom-reload ()
|
2016-10-02 23:24:20 +02:00
|
|
|
"Reload `load-path' and `custom-theme-load-path', in case you updated cask
|
|
|
|
while emacs was open!"
|
2016-04-04 12:06:47 -04:00
|
|
|
(interactive)
|
2016-10-06 17:20:13 +02:00
|
|
|
(let* ((-packages-path (--subdirs doom-packages-dir))
|
|
|
|
(-load-path
|
|
|
|
(append (list doom-private-dir doom-core-dir doom-modules-dir doom-packages-dir)
|
|
|
|
(--subdirs doom-core-dir t)
|
|
|
|
(--subdirs doom-modules-dir t)
|
|
|
|
-packages-path
|
|
|
|
(--subdirs (expand-file-name (format "../../%s/bootstrap" emacs-version)
|
|
|
|
doom-packages-dir))
|
|
|
|
doom--load-path))
|
|
|
|
(-custom-theme-load-path
|
|
|
|
(append (--subdirs doom-themes-dir t)
|
|
|
|
custom-theme-load-path)))
|
2016-10-02 23:24:20 +02:00
|
|
|
(setq load-path -load-path
|
|
|
|
custom-theme-load-path -custom-theme-load-path)
|
|
|
|
(if (called-interactively-p 'interactive)
|
|
|
|
(message "Reloaded!")
|
2016-10-06 17:20:13 +02:00
|
|
|
(list -load-path
|
|
|
|
-custom-theme-load-path
|
|
|
|
(mapcar '--subdirs -packages-path)))))
|
2016-03-26 01:19:31 -04:00
|
|
|
|
2016-05-20 22:37:30 -04:00
|
|
|
(defun doom-reload-autoloads ()
|
2016-10-02 23:26:29 +02:00
|
|
|
"Regenerate and reload autoloads.el."
|
2016-04-08 15:39:36 -04:00
|
|
|
(interactive)
|
2016-05-20 22:37:30 -04:00
|
|
|
(let ((generated-autoload-file (concat doom-core-dir "/autoloads.el")))
|
2016-04-08 15:39:36 -04:00
|
|
|
(when (file-exists-p generated-autoload-file)
|
2016-05-23 06:26:28 -04:00
|
|
|
(delete-file generated-autoload-file)
|
|
|
|
(message "Deleted old autoloads.el"))
|
2016-04-08 15:39:36 -04:00
|
|
|
(mapc (lambda (dir)
|
|
|
|
(update-directory-autoloads (concat dir "/defuns"))
|
|
|
|
(message "Scanned: %s" dir))
|
2016-05-20 22:37:30 -04:00
|
|
|
(list doom-core-dir doom-modules-dir))
|
2016-04-12 15:38:58 -04:00
|
|
|
(when (called-interactively-p 'interactive)
|
2016-06-04 23:28:47 -04:00
|
|
|
(load "autoloads"))
|
2016-04-08 15:39:36 -04:00
|
|
|
(message "Done!")))
|
|
|
|
|
2016-05-28 21:51:21 -04:00
|
|
|
(defun doom-byte-compile (&optional minimal)
|
2016-10-02 23:26:29 +02:00
|
|
|
"Byte compile the core and library .el files in ~/.emacs.d. If MINIMAL is nil,
|
|
|
|
only byte compile a few important files. If t, compile all files too. If 'basic,
|
|
|
|
only compile defun libraries."
|
2016-05-22 06:25:04 -04:00
|
|
|
(interactive)
|
2016-05-29 00:40:44 -04:00
|
|
|
(mapc (lambda (f) (byte-compile-file (concat doom-emacs-dir "/" f) t))
|
2016-06-19 14:44:28 -04:00
|
|
|
'("init.el" "core/core.el" "core/core-defuns.el" "core/core-ui.el"
|
2016-09-09 08:55:38 +02:00
|
|
|
"core/core-modeline.el" "core/core-os.el" "core/core-os-osx.el"
|
|
|
|
"core/core-os-win32.el" "core/core-os-linux.el"
|
|
|
|
"private/my-commands.el" "private/my-bindings.el"))
|
2016-06-18 00:58:34 -04:00
|
|
|
(unless (eq minimal 'basic)
|
|
|
|
(unless minimal
|
|
|
|
(byte-recompile-directory doom-core-dir 0 t)
|
|
|
|
(byte-recompile-directory doom-modules-dir 0 t))
|
|
|
|
(when minimal
|
|
|
|
(byte-recompile-directory (concat doom-core-dir "/defuns") 0 t)
|
2016-10-04 22:53:07 +02:00
|
|
|
(byte-recompile-directory (concat doom-modules-dir "/defuns") 0 t)))
|
|
|
|
(message "Compiled!"))
|
2016-05-22 06:25:04 -04:00
|
|
|
|
2015-06-06 06:40:33 -04:00
|
|
|
(provide 'core-defuns)
|
|
|
|
;;; core-defuns.el ends here
|