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
|
@ -8,7 +8,7 @@
|
|||
(when theme
|
||||
(mapc #'disable-theme custom-enabled-themes))
|
||||
(load "doom-themes-common.el" nil t)
|
||||
(load-theme theme t)
|
||||
(+doom|init)
|
||||
(+doom|refresh-bright-buffers)))
|
||||
|
||||
;;;###autoload
|
||||
|
|
|
@ -16,17 +16,33 @@
|
|||
"Fallback font for unicode glyphs. Is ignored if :feature unicode is active.")
|
||||
|
||||
|
||||
;;; Set fonts
|
||||
(when (display-graphic-p)
|
||||
;; Getting themes to remain consistent across GUI Emacs, terminal Emacs and
|
||||
;; daemon Emacs is hairy.
|
||||
;;
|
||||
;; + Running `+doom|init' directly sorts out the initial GUI frame.
|
||||
;; + Attaching it to `after-make-frame-functions' sorts out daemon Emacs.
|
||||
;; + Terminal Emacs is a bit of a wildcard.
|
||||
(defun +doom|init (&optional frame)
|
||||
"Set the theme and load the font, in that order."
|
||||
(load-theme +doom-theme t)
|
||||
|
||||
(with-demoted-errors "FONT ERROR: %s"
|
||||
(set-frame-font +doom-font t t)
|
||||
(set-frame-font +doom-font nil (if frame (list frame) t))
|
||||
;; Fallback to `doom-unicode-font' for Unicode characters
|
||||
(unless (featurep! :ui unicode)
|
||||
(when +doom-unicode-font
|
||||
(set-fontset-font t 'unicode +doom-unicode-font)))
|
||||
(set-fontset-font t 'unicode +doom-unicode-font frame)))
|
||||
;; ...and for variable-pitch mode
|
||||
(when +doom-variable-pitch-font
|
||||
(set-face-attribute 'variable-pitch nil :font +doom-variable-pitch-font))))
|
||||
(set-face-attribute 'variable-pitch frame :font +doom-variable-pitch-font))))
|
||||
|
||||
(defun +doom|init-daemon (frame)
|
||||
(when (or (daemonp) (not (display-graphic-p)))
|
||||
(with-selected-frame frame
|
||||
(run-with-timer 0 nil #'+doom|init))))
|
||||
|
||||
(add-hook 'after-make-frame-functions #'+doom|init)
|
||||
(add-hook 'after-make-frame-functions #'+doom|init-daemon)
|
||||
|
||||
|
||||
;; doom-one: gives Emacs a look inspired by Dark One in Atom.
|
||||
|
@ -35,13 +51,11 @@
|
|||
:load-path "~/work/plugins/emacs-doom-themes/"
|
||||
:demand t
|
||||
:config
|
||||
(load-theme +doom-theme t)
|
||||
|
||||
(+doom|init)
|
||||
;; blink mode-line on errors
|
||||
(add-hook 'emacs-startup-hook #'doom-themes-visual-bell-config t)
|
||||
|
||||
(add-hook 'doom-post-init-hook #'doom-themes-visual-bell-config)
|
||||
;; Add file icons to doom-neotree
|
||||
(add-hook 'emacs-startup-hook #'doom-themes-neotree-config t)
|
||||
(add-hook 'doom-post-init-hook #'doom-themes-neotree-config)
|
||||
(setq doom-neotree-enable-variable-pitch t
|
||||
doom-neotree-file-icons 'simple
|
||||
doom-neotree-line-spacing 2)
|
||||
|
@ -52,11 +66,6 @@
|
|||
:foreground "#ffffff"
|
||||
:background (doom-color 'current-line))
|
||||
|
||||
;; Dark frames by default
|
||||
(when (display-graphic-p)
|
||||
(push (cons 'background-color (doom-color 'bg)) initial-frame-alist)
|
||||
(push (cons 'foreground-color (doom-color 'fg)) initial-frame-alist))
|
||||
|
||||
(after! neotree
|
||||
(defun +doom|neotree-fix-popup ()
|
||||
"Ensure the fringe settings are maintained on popup restore."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue