Commit 68d5e4b8ae7a

Vincent Demeester <vincent@sbr.pm>
2020-05-03 14:22:38
config-appearance.el: modus-themes customize 🥒
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent cd7cabf
Changed files (1)
tools
tools/emacs/config/config-appearance.el
@@ -45,10 +45,6 @@
   (global-unset-key (kbd "C-x C-z"))
   (global-unset-key (kbd "C-h h")))
 
-;; SafeTheme
-(setq custom-safe-themes t)    ; Treat themes as safe
-;; -SafeTheme
-
 ;; LoadTheme
 (defadvice load-theme (before clear-previous-themes activate)
   "Clear existing theme settings instead of layering them."
@@ -60,6 +56,33 @@
   :config
   (setq custom-safe-themes t)
 
+  (defvar contrib/after-load-theme-hook nil
+    "Hook run after a color theme is loaded using `load-theme'.")
+
+  (defun contrib/run-after-load-theme-hook (&rest _)
+    "Run `contrib/after-load-theme-hook'."
+    (run-hooks 'contrib/after-load-theme-hook))
+
+  (advice-add #'load-theme :after #'contrib/run-after-load-theme-hook)
+
+  (defcustom sbr/modus-themes-toggle-hook nil
+    "Hook that runs after `prot/modus-themes-toggle' is invoked."
+    :type 'hook)
+
+  (defun sbr/modus-themes-toggle ()
+    "Toggle between `sbr/modus-operandi' and `sbr/modus-vivendi'.
+Also run `sbr/modus-themes-toggle-hook'."
+    (interactive)
+    (if (eq (car custom-enabled-themes) 'modus-operandi)
+        (sbr/modus-vivendi)
+      (sbr/modus-operandi))
+    (run-hooks 'sbr/modus-themes-toggle-hook))
+
+  :bind ("<f10>" . sbr/modus-themes-toggle)
+  :hook ((after-init-hook . sbr/modus-operandi)))
+
+(use-package modus-operandi-theme
+  :config
   (defun sbr/modus-operandi ()
     "Enable some Modus Operandi variables and load the theme.
 This is used internally by `sbr/modus-themes-toggle'."
@@ -78,7 +101,24 @@ This is used internally by `sbr/modus-themes-toggle'."
           modus-operandi-theme-scale-3 1.15
           modus-operandi-theme-scale-4 1.2)
     (load-theme 'modus-operandi t))
+  (defun sbr/modus-operandi-custom ()
+    "Customize modus-operandi theme"
+    (message "fooo")
+    (if (member 'modus-operandi custom-enabled-themes)
+        (modus-operandi-theme-with-color-variables ; this macro allows us to access the colour palette
+         (custom-theme-set-faces
+          'modus-operandi
+          `(whitespace-tab ((,class (:background "#ffffff" :foreground "#cccccc"))))
+          `(whitespace-space ((,class (:background "#ffffff" :foreground "#cccccc"))))
+          `(whitespace-hspace ((,class (:background "#ffffff" :foreground "#cccccc"))))
+          `(whitespace-newline ((,class (:background "#ffffff" :foreground "#cccccc"))))
+          `(whitespace-indentation ((,class (:background "#ffffff" :foreground "#cccccc"))))
+          ))))
+  (add-hook 'contrib/after-load-theme-hook 'sbr/modus-operandi-custom)
+  (sbr/modus-operandi))
 
+(use-package modus-vivendi-theme
+  :config
   (defun sbr/modus-vivendi ()
     "Enable some Modus Vivendi variables and load the theme.
 This is used internally by `sbr/modus-themes-toggle'."
@@ -97,22 +137,20 @@ This is used internally by `sbr/modus-themes-toggle'."
           modus-vivendi-theme-scale-3 1.15
           modus-vivendi-theme-scale-4 1.2)
     (load-theme 'modus-vivendi t))
-
-  (defcustom sbr/modus-themes-toggle-hook nil
-    "Hook that runs after `prot/modus-themes-toggle' is invoked."
-    :type 'hook)
-
-  (defun sbr/modus-themes-toggle ()
-    "Toggle between `sbr/modus-operandi' and `sbr/modus-vivendi'.
-Also run `sbr/modus-themes-toggle-hook'."
-    (interactive)
-    (if (eq (car custom-enabled-themes) 'modus-operandi)
-        (sbr/modus-vivendi)
-      (sbr/modus-operandi))
-    (run-hooks 'sbr/modus-themes-toggle-hook))
-  :bind ("<f10>" . sbr/modus-themes-toggle)
-  :hook (after-init-hook . sbr/modus-operandi))
-;; -UseTheme0
+  (defun sbr/modus-vivendi-custom ()
+    "Customize modus-vivendi theme"
+    (if (member 'modus-vivendi custom-enabled-themes)
+        (modus-vivendi-theme-with-color-variables ; this macro allows us to access the colour palette
+         (custom-theme-set-faces
+          'modus-vivendi
+          `(whitespace-tab ((,class (:background "#000000" :foreground "#666666"))))
+          `(whitespace-space ((,class (:background "#000000" :foreground "#666666"))))
+          `(whitespace-hspace ((,class (:background "#000000" :foreground "#666666"))))
+          `(whitespace-newline ((,class (:background "#000000" :foreground "#666666"))))
+          `(whitespace-indentation ((,class (:background "#000000" :foreground "#666666"))))
+          ))))
+  (add-hook 'contrib/after-load-theme-hook 'sbr/modus-vivendi-custom))
+;; -UseTheme
 
 (use-package emacs
   :config