Emacs: Don't reload the theme each time a frame is created.

Load the theme on init, fix the colors that need fixing when a frame is
created, stop if the code ran in a GUI frame before.
This commit is contained in:
tastytea 2020-12-05 08:58:46 +01:00
parent 8785bb905d
commit 8b94772e9a
1 changed files with 20 additions and 15 deletions

View File

@ -1,6 +1,6 @@
;;; appearance.el --- Configure appearance. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-11-30T20:02:17+0100>
;; Time-stamp: <2020-12-05T08:55:31+0100>
;;; Commentary:
@ -67,19 +67,24 @@
:custom ((doom-themes-treemacs-theme "doom-colors")
(doom-themes-treemacs-enable-variable-pitch nil))
:config (progn
(defun my/reload-theme ()
(load-theme 'doom-outrun-electric t)
(when (display-graphic-p)
(set-face-background 'scroll-bar (face-background 'default))
(set-face-foreground 'scroll-bar (face-foreground 'shadow)))
(when (fboundp #'my/ruler-set-colors)
(my/ruler-set-colors))
(when (fboundp #'my/volatile-highlights-reset-color)
(my/volatile-highlights-reset-color))
(when (fboundp #'markdown-mode)
(set-face-background 'markdown-code-face
(face-background 'hl-line))))
(my/reload-theme)
(defvar my/run-fix-theme t)
(defun my/fix-theme ()
"Fix some colors, needed the for the first frame after server start."
(when my/run-fix-theme
(when (display-graphic-p)
(set-face-background 'scroll-bar (face-background 'default))
(set-face-foreground 'scroll-bar (face-foreground 'shadow)))
(when (fboundp #'my/ruler-set-colors)
(my/ruler-set-colors))
(when (fboundp #'my/volatile-highlights-reset-color)
(my/volatile-highlights-reset-color))
(when (fboundp #'markdown-mode)
(set-face-background 'markdown-code-face
(face-background 'hl-line)))
(when (display-graphic-p)
(setq my/run-fix-theme nil))))
(load-theme 'doom-outrun-electric t)
(my/fix-theme)
(doom-themes-visual-bell-config) ; Flash modeline on error.
;; No icons in TUI, see
@ -105,7 +110,7 @@
(set-window-fringes (selected-window) 8))
(advice-add #'doom-themes-hide-fringes-maybe
:after #'my/treemacs-reset-fringe))
:hook (server-after-make-frame . my/reload-theme))
:hook (server-after-make-frame . my/fix-theme))
;; Neat modeline.
(use-package doom-modeline