From c65ea59920d11e9feffd13025a5774072cb8b8e7 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sun, 28 Aug 2022 22:17:46 +0700 Subject: [PATCH] Use custom-file to save last used theme --- .emacs.bankruptcy/init.org | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.emacs.bankruptcy/init.org b/.emacs.bankruptcy/init.org index 2aae63e..b8620b1 100644 --- a/.emacs.bankruptcy/init.org +++ b/.emacs.bankruptcy/init.org @@ -140,8 +140,7 @@ Don't let emacs add customised settings to init.el, which in our case is worse s literate file. #+begin_src emacs-lisp -(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) -(load custom-file t) + #+end_src This avoids those annoying *#backup#* files that get added and eventually slow down loading the file again. @@ -195,37 +194,33 @@ Use Dashboard.el. First load `all-the-icons` for nicer rendering #+begin_src emacs-lisp (straight-use-package 'olivetti) +(require 'olivetti) (setq olivetti-minimum-body-width 100) (global-set-key (kbd "C-x x o") 'olivetti-mode) #+end_src *** Themes -Simple functions to remember the last chosen theme. +sanityinc-tomorrow-light is really good #+begin_src emacs-lisp - (straight-use-package 'doom-themes) (straight-use-package 'color-theme-sanityinc-tomorrow) (setq custom-safe-themes t) +#+end_src + +Save the last used theme when exiting emacs and then reload it. + +#+begin_src emacs-lisp +(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) +(load custom-file) (defun joe/save-current-theme () - (let ((filename (expand-file-name "data" user-emacs-directory))) - (with-temp-buffer - (print `((last-used-theme . ,custom-enabled-themes)) (current-buffer)) - (if (file-writable-p filename) - (write-file filename) - (message (format "Cannot save themes because %s is not writable" filename)))))) + (customize-save-variable 'custom-enabled-themes custom-enabled-themes)) (add-hook 'kill-emacs-hook #'joe/save-current-theme) - -(let ((filename (expand-file-name "data" user-emacs-directory))) - (if (file-readable-p filename) - (let ((theme-data (with-temp-buffer - (insert-file-contents filename) - (buffer-string)))) - (mapc 'load-theme (cdr (car (read theme-data))))))) #+end_src + *** Other Setup other stuff