From ef2b07cffcac374241676aff08dd67e4e6878daf Mon Sep 17 00:00:00 2001 From: mtmn Date: Sat, 5 Sep 2026 12:53:33 +0200 Subject: [PATCH] persist theme on restart --- lisp/setup-core.el | 6 ++++++ lisp/setup-ui.el | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lisp/setup-core.el b/lisp/setup-core.el index 97eb77a..c44d086 100644 --- a/lisp/setup-core.el +++ b/lisp/setup-core.el @@ -7,6 +7,7 @@ ;;; Code: (require 'subr-x) ; string-remove-prefix +(require 'savehist) (declare-function undo-fu-session-global-mode "undo-fu-session" (&optional arg)) @@ -77,6 +78,11 @@ mirrored path as relative; its parent directories are created." url-configuration-directory (mine-cache-subdir "url") eshell-directory-name (mine-cache-subdir "eshell")) +(defvar mine-last-ef-theme nil + "Persist selected theme after restart.") + +(add-to-list 'savehist-additional-variables 'mine-last-ef-theme) + (savehist-mode 1) (recentf-mode 1) diff --git a/lisp/setup-ui.el b/lisp/setup-ui.el index 9dae534..086fd7d 100644 --- a/lisp/setup-ui.el +++ b/lisp/setup-ui.el @@ -77,6 +77,15 @@ ;; Move underlines to the descent line to reduce glyph clipping. (setopt x-underline-at-descent-line t)) +(defun mine-ef-theme--record () + "Persist selected theme on restart." + (when (display-graphic-p) + (catch 'found + (dolist (theme custom-enabled-themes) + (when (memq theme ef-themes-items) + (setq mine-last-ef-theme theme) + (throw 'found t)))))) + (use-package modus-themes :unless (display-graphic-p) :demand t @@ -87,7 +96,8 @@ :if (display-graphic-p) :demand t :config - (load-theme 'ef-winter t)) + (add-hook 'ef-themes-after-load-theme-hook #'mine-ef-theme--record) + (load-theme (or mine-last-ef-theme 'ef-winter) t)) (setopt display-line-numbers-width 3) -- 2.54.0