makefile: reload running Emacs after tasks + refactor

This commit is contained in:
Henrik Lissner 2017-02-06 00:12:44 -05:00
parent 9a126a1274
commit f1208e9179
4 changed files with 64 additions and 49 deletions

View file

@ -4,18 +4,22 @@ all: install update autoloads
install: init.el
@$(EMACS) --batch -l core/core.el -f 'doom/packages-install'
@$(EMACSCLIENT) -e '(doom/reload)' >/dev/null 2>&1 || true
update: init.el
@$(EMACS) --batch -l core/core.el -f 'doom/packages-update'
@$(EMACSCLIENT) -e '(doom/reload)' >/dev/null 2>&1 || true
clean: init.el
@$(EMACS) --batch -l core/core.el -f 'doom/packages-autoremove'
@$(EMACSCLIENT) -e '(doom/reload)' >/dev/null 2>&1 || true
autoloads: init.el
@$(EMACS) --batch -l core/core.el -f 'doom/refresh-autoloads'
@$(EMACS) --batch -l init.el -f 'doom/refresh-autoloads'
@$(EMACSCLIENT) -e '(doom/reload)' >/dev/null 2>&1 || true
compile: init.el clean-elc
@$(EMACS) --batch -l core/core.el -f 'doom/byte-compile'
@$(EMACS) --batch -l init.el -f 'doom/byte-compile'
compile-all: init.el clean-elc
@$(EMACS) --batch -l core/core.el --eval '(doom/byte-compile t)'

View file

@ -38,7 +38,7 @@
select-enable-clipboard t
select-enable-primary t)
(let ((inhibit-message t))
(unless noninteractive
;; Save point across sessions
(require 'saveplace)
(setq save-place-file (concat doom-cache-dir "saveplace")
@ -50,8 +50,7 @@
(require 'savehist)
(setq savehist-file (concat doom-cache-dir "savehist")
savehist-save-minibuffer-history t
savehist-additional-variables
'(kill-ring search-ring regexp-search-ring))
savehist-additional-variables '(kill-ring search-ring regexp-search-ring))
(savehist-mode 1)
;; Remove text-property cruft from history
@ -76,7 +75,7 @@
recentf-max-saved-items 250
recentf-auto-cleanup 600
recentf-filename-handlers '(abbreviate-file-name))
(recentf-mode 1)
(quiet! (recentf-mode 1))
;; Ediff
(add-hook! ediff-load
@ -131,8 +130,8 @@
'css-mode "/*" "*/" :post-handlers '(("[d-3]||\n[i]" "RET") ("| " "SPC")))
(sp-local-pair '(sh-mode markdown-mode) "`" nil
:unless '(sp-point-before-word-p sp-point-before-same-p))
(sp-with-modes '(xml-mode nxml-mode php-mode)
(sp-local-pair "<!--" "-->" :post-handlers '(("| " "SPC")))))
(sp-local-pair '(xml-mode nxml-mode php-mode)
"<!--" "-->" :post-handlers '(("| " "SPC"))))
;;
@ -191,7 +190,7 @@
(package! wgrep
:commands (wgrep-setup wgrep-change-to-wgrep-mode)
:config
(def-popup! ("^\\*ivy-occur counsel-ag" :size 25 :select t :regexp t))
(set! :popup ("^\\*ivy-occur counsel-ag" :size 25 :select t :regexp t))
(setq wgrep-auto-save-buffer t)
(advice-add 'wgrep-abort-changes :after 'doom/popup-close)
(advice-add 'wgrep-finish-edit :after 'doom/popup-close))

View file

@ -6,6 +6,7 @@
(require 'dash)
(require 'f)
(require 's)
(eval-when-compile (require 'cl-lib))
(package! anaphora
:commands (awhen aif acond awhile))
@ -44,6 +45,13 @@ during compilation."
'with-no-warnings)
(with-eval-after-load ',feature ,@forms)))
(defmacro quiet! (&rest forms)
"Run FORMS without making any noise (no messages)."
`(cl-letf (((symbol-function 'load-file) (lambda (file) (load file nil t)))
((symbol-function 'message) (lambda (&rest _)))
(inhibit-message t))
,@forms))
(defmacro add-hook! (hook &rest func-or-forms)
"A convenience macro for `add-hook'.

View file

@ -1,7 +1,7 @@
;;; core-packages.el
;;
;; Emacs package management is opinionated. Unfortunately, so am I. So I
;; combined `use-package`, quelpa and package.el to manage my plugins.
;; combined `use-package', `quelpa' and package.el to manage my plugins.
;;
;; Why all the trouble? Because:
;; 1. Scriptability: I want my plugins managable from the command line (as well
@ -57,7 +57,7 @@ if you have byte-compiled your configuration (as intended).")
quelpa-dir (expand-file-name "quelpa" doom-packages-dir)
;; ssh, no tears. Only compiling.
byte-compile-warnings
'(unresolved callargs obsolete noruntime cl-functions make-local constants suspicious))
'(redefine callargs obsolete cl-functions interactive-only mapcar constants suspicious))
;;
@ -143,12 +143,16 @@ avoided to speed up startup."
(and load-file-name (f-dirname load-file-name))
(and buffer-file-name (f-dirname buffer-file-name))
default-directory
(and (bound-and-true-p byte-compile-current-file)
(f-dirname byte-compile-current-file))
(error "__DIR__ is unset")))
(defun __FILE__ ()
(or __FILE__
load-file-name
buffer-file-name
(and (bound-and-true-p byte-compile-current-file)
byte-compile-current-file)
(error "__FILE__ is unset")))
(defmacro use-package! (name &rest plist)
@ -237,34 +241,37 @@ Examples:
;;
(defun doom/reload ()
"Reload `load-path' by reinitializing package.el. Run this if you ran update
or delete packages from outside of Emacs."
"Reload `load-path', `doom-enabled-modules' and `doom-packages' by
reinitializing doom and parsing config files for `package!' and `doom!' calls.
There are few reasons to use this."
(interactive)
(doom-initialize t)
(doom-read-packages t)
(doom-initialize-autoloads)
(message "Reloaded %s packages" (length package-alist)))
(defun doom/refresh-autoloads ()
"Refreshes the autoloads.el file, which tells Emacs where to find all the
autoloaded functions in the modules you use or among the core libraries.
autoloaded functions in the modules you use or among the core libraries, e.g.
core/autoload/*.el.
In modules, checks for modules/*/autoload.el and modules/*/autoload/*.el.
In modules, checks modules/*/autoload.el and modules/*/autoload/*.el.
Rerun this whenever you modify your init.el (or use `make autoloads` from the
command line)."
Rerun this whenever init.el is modified. You can also use `make autoloads` from
the commandline."
(interactive)
(doom-read-packages nil t)
(let ((generated-autoload-file (concat doom-local-dir "autoloads.el"))
(autoload-files
(append (-flatten (mapcar (lambda (dir)
(let ((auto-dir (f-expand "autoload" dir))
(auto-file (f-expand "autoload.el" dir)))
(let ((generated-autoload-file doom-autoload-file)
autoload-files)
(setq autoload-files
(append (-flatten (--map (let ((auto-dir (f-expand "autoload" it))
(auto-file (f-expand "autoload.el" it)))
(cond ((f-directory-p auto-dir)
(f-glob "*.el" auto-dir))
((f-exists-p auto-file)
auto-file))))
auto-file)))
(--map (doom-module-path (car it) (cdr it))
doom-enabled-modules)))
(f-glob "autoload/*.el" doom-core-dir))))
(f-glob "autoload/*.el" doom-core-dir)))
(when (f-exists-p generated-autoload-file)
(f-delete generated-autoload-file)
(message "Deleted old autoloads.el"))
@ -276,27 +283,25 @@ command line)."
(eval-buffer))
(message "Done!")))
(defun doom/byte-compile (&optional comprehensive-p)
"Byte (re)compile the important files in your emacs configuration (i.e.
init.el, core/*.el and modules/*/*/config.el) DOOM Emacs was designed to benefit
a lot from this.
(defun doom/byte-compile (&optional simple-p)
"Byte (re)compile the important files in your emacs configuration (init.el &
core/*.el). DOOM Emacs was designed to benefit from this.
If COMPREHENSIVE-P is non-nil, then compile modules/*/*/*.el (except for
packages.el files) -- this will likely take a long time."
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."
(interactive)
(doom-read-packages)
(let ((targets (append
(list (f-expand "init.el" doom-emacs-dir)
(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)
(unless simple-p
(-flatten
(--map (f--entries (doom-module-path (car it) (cdr it))
(and (f-ext-p it "el")
(or comprehensive-p
(string= (f-base it) "config")
(or (string= (f-base it) "config")
(string-prefix-p "+" (f-base it))))
t)
doom-enabled-modules))))
doom-enabled-modules)))))
(n 0)
results)
(dolist (file targets)
@ -353,7 +358,6 @@ packages.el files) -- this will likely take a long time."
(setq forms (append forms plist)))
forms))
;;;###autoload
(defun doom-read-packages (&optional force-p nopackages)
"Parses your Emacs config to keep track of packages declared with `package!'
in `doom-packages' and enabled modules in `doom-enabled-modules'."