Use custom-file to save last used theme
This commit is contained in:
parent
fa37091109
commit
c65ea59920
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user