about summary refs log tree commit diff
path: root/configs/shared/.emacs.d/wpc/colorscheme.el
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2019-10-09T11·13+0100
committerWilliam Carroll <wpcarro@gmail.com>2019-12-24T15·21+0000
commit6b456c1b7a4f6899f063a6e65355af51901d9c7a (patch)
treecfc70d74818ae9fabdbbfb0cf16cce092e4c1a09 /configs/shared/.emacs.d/wpc/colorscheme.el
parenta7c72adb2ebec1e497fc040eaf3551d564d61a5b (diff)
Massive configuration overhaul
Currently paying the price of months of non-diligent git usage.

Here's what has changed.

- Theming support in Gvcci and wpgtk
- Dropping support for i3
- Supporting EXWM
- Many Elisp modules
- Collapsed redundant directories in ./configs
Diffstat (limited to 'configs/shared/.emacs.d/wpc/colorscheme.el')
-rw-r--r--configs/shared/.emacs.d/wpc/colorscheme.el91
1 files changed, 91 insertions, 0 deletions
diff --git a/configs/shared/.emacs.d/wpc/colorscheme.el b/configs/shared/.emacs.d/wpc/colorscheme.el
new file mode 100644
index 0000000000..349d6f8e7e
--- /dev/null
+++ b/configs/shared/.emacs.d/wpc/colorscheme.el
@@ -0,0 +1,91 @@
+;;; colorscheme.el --- Syntax highlight and friends -*- lexical-binding: t -*-
+;; Author: William Carroll <wpcarro@gmail.com>
+
+;;; Commentary:
+;;
+;; TODO: Clarify this.
+;; Since I have my own definition of "theme", which couples wallpaper, font,
+;; with Emacs's traditional notion of the word "theme", I'm choosing to use
+;; "colorscheme" to refer to *just* the notion of syntax highlight etc.
+
+;;; Code:
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Dependencies
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(require 'cycle)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Constants
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defcustom colorscheme/install-kbds? t
+  "If non-nil, enable the keybindings.")
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Library
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defcustom colorscheme/whitelist
+  (cycle/from-list
+   (custom-available-themes))
+  "The whitelist of colorschemes through which to cycle.")
+
+(defun colorscheme/current ()
+  "Return the currently enabled colorscheme."
+  (cycle/current colorscheme/whitelist))
+
+(defun colorscheme/disable-all ()
+  "Disable all currently enabled colorschemes."
+  (interactive)
+  (->> custom-enabled-themes
+       (list/map #'disable-theme)))
+
+(defun colorscheme/set (theme)
+    "Call `load-theme' with `THEME', ensuring that the line numbers are bright.
+There is no hook that I'm aware of to handle this more elegantly."
+    (load-theme theme)
+    (prelude/set-line-number-color "#da5468"))
+
+(defun colorscheme/whitelist-set (colorscheme)
+  "Focus the COLORSCHEME in the `colorscheme/whitelist' cycle."
+  (cycle/focus (lambda (x) (equal x colorscheme)) colorscheme/whitelist)
+  (colorscheme/set (colorscheme/current)))
+
+(defun colorscheme/ivy-select ()
+  "Load a colorscheme using ivy."
+  (interactive)
+  (let ((theme (ivy-read "Theme: " (cycle/to-list colorscheme/whitelist))))
+    (colorscheme/disable-all)
+    (colorscheme/set (intern theme))))
+
+(cl-defun colorscheme/cycle (&key forward?)
+  "Cycle next if `FORWARD?' is non-nil.
+Cycle prev otherwise."
+  (disable-theme (cycle/current colorscheme/whitelist))
+  (let ((theme (if forward?
+                   (cycle/next colorscheme/whitelist)
+                 (cycle/prev colorscheme/whitelist))))
+    (colorscheme/load theme)
+    (message (s-concat "Active theme: " (symbol/to-string theme)))))
+
+(defun colorscheme/next ()
+  "Disable the currently active theme and load the next theme."
+  (interactive)
+  (colorscheme/cycle :forward? t))
+
+(defun colorscheme/prev ()
+  "Disable the currently active theme and load the previous theme."
+  (interactive)
+  (colorscheme/cycle :forward? nil))
+
+;; Keybindings
+;; TODO: Prefer minor mode definition with a custom keymap.
+(when colorscheme/install-kbds?
+  (evil-leader/set-key
+    "Ft" #'colorscheme/next
+    "Pt" #'colorscheme/prev))
+
+(provide 'colorscheme)
+;;; colorscheme.el ends here