From 8b94772e9aaca4398b050bfdfa93d5c6bbd3bf1c Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 5 Dec 2020 08:58:46 +0100 Subject: [PATCH] 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. --- init.d/basics/appearance.el | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/init.d/basics/appearance.el b/init.d/basics/appearance.el index 4869df3..7c80c53 100644 --- a/init.d/basics/appearance.el +++ b/init.d/basics/appearance.el @@ -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