Refactor DOOM init & add new init hooks
+ Add doom-init-hook and doom-post-init-hook to simplify Emacs init hooks into less ambiguous ones. + Attach former after-init-hook and emacs-startup-hook hooks to new doom init hooks. + Vastly improves daemon and tty support: preventing incorrect colors from bleeding across face class barriers, and into GUI Emacs and vice versa, when spawned with emacsclient. + Fix persp-mode breaking Emacs daemon, and ensuring that initialization is done properly in terminal Emacs (and emacsclient frames).
This commit is contained in:
parent
d3054f4679
commit
4984a548d1
17 changed files with 121 additions and 80 deletions
42
core/core.el
42
core/core.el
|
@ -124,8 +124,15 @@ melodramatic ex-vimmer disappointed with the text-editor status quo."
|
|||
initial-major-mode 'fundamental-mode
|
||||
initial-scratch-message nil)
|
||||
|
||||
;; Custom init hooks; clearer than `after-init-hook', `emacs-startup-hook', and
|
||||
;; `window-setup-hook'.
|
||||
(defvar doom-init-hook nil
|
||||
"A list of hooks run when DOOM is initialized, before `doom-post-init-hook'.")
|
||||
|
||||
(defvar doom-post-init-hook nil
|
||||
"A list of hooks run after DOOM initialization is complete, and after
|
||||
`doom-init-hook'.")
|
||||
|
||||
;;;
|
||||
;; Automatic minor modes
|
||||
(defvar doom-auto-minor-mode-alist '()
|
||||
"Alist mapping filename patterns to corresponding minor mode functions, like
|
||||
|
@ -153,7 +160,7 @@ enable multiple minor modes for the same regexp.")
|
|||
|
||||
|
||||
;;;
|
||||
;; Bootstrap
|
||||
;; Initialize
|
||||
(eval-and-compile
|
||||
(defvar doom--file-name-handler-alist file-name-handler-alist)
|
||||
(setq gc-cons-threshold 402653184
|
||||
|
@ -170,7 +177,25 @@ enable multiple minor modes for the same regexp.")
|
|||
(setq load-path (eval-when-compile load-path)
|
||||
doom--package-load-path (eval-when-compile doom--package-load-path))
|
||||
|
||||
;;; Let 'er rip
|
||||
(defun doom|finalize ()
|
||||
(unless doom-init-p
|
||||
(run-hooks 'doom-init-hook)
|
||||
(run-hooks 'doom-post-init-hook)
|
||||
|
||||
;; Don't keep gc-cons-threshold too high. It helps to stave off the GC while
|
||||
;; Emacs starts up, but afterwards it causes stuttering and random freezes.
|
||||
;; So reset it to a reasonable default.
|
||||
(setq gc-cons-threshold 16777216
|
||||
gc-cons-percentage 0.1
|
||||
file-name-handler-alist doom--file-name-handler-alist
|
||||
doom-init-p t)))
|
||||
|
||||
(add-hook! '(emacs-startup-hook doom-reload-hook)
|
||||
#'doom|finalize)
|
||||
|
||||
|
||||
;;;
|
||||
;; Bootstrap
|
||||
(load! core-os) ; consistent behavior across Oses
|
||||
(with-demoted-errors "AUTOLOAD ERROR: %s"
|
||||
(require 'autoloads doom-autoload-file t))
|
||||
|
@ -182,16 +207,5 @@ enable multiple minor modes for the same regexp.")
|
|||
(load! core-projects) ; making Emacs project-aware
|
||||
(load! core-keybinds)) ; centralized keybind system + which-key
|
||||
|
||||
(defun doom|init ()
|
||||
;; Don't keep gc-cons-threshold too high. It helps to stave off the GC while
|
||||
;; Emacs starts up, but afterwards it causes stuttering and random freezes. So
|
||||
;; reset it to a reasonable default.
|
||||
(setq gc-cons-threshold 16777216
|
||||
gc-cons-percentage 0.1
|
||||
file-name-handler-alist doom--file-name-handler-alist))
|
||||
|
||||
(add-hook! '(emacs-startup-hook doom-reload-hook)
|
||||
#'doom|init)
|
||||
|
||||
(provide 'core)
|
||||
;;; core.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue