about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-11-25T18·36-0800
committerwpcarro <wpcarro@gmail.com>2022-11-28T19·07+0000
commit89e37ee87755339d113fb631ddae3682e5cddffc (patch)
treef3af323c27848516b33d9fc48b6db3bdbffd33c1
parent22c2c5ba46bde2ac3f62811eb5caaffede7ceed8 (diff)
feat(wpcarro/emacs): Package theme.el r/5347
**TL;DR:**
- Rename `colorscheme.el` to `theme.el` to align with Emacs's nomenclature.
- Prune dependencies:
  - `cl-lib`
  - `>`
  - `prelude`

Change-Id: I15f225671b4096ab08913583b7b464e316c95298
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7412
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/colorscheme.el85
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el15
-rw-r--r--users/wpcarro/emacs/default.nix1
-rw-r--r--users/wpcarro/emacs/pkgs/theme/default.nix14
-rw-r--r--users/wpcarro/emacs/pkgs/theme/theme.el78
5 files changed, 106 insertions, 87 deletions
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/colorscheme.el b/users/wpcarro/emacs/.emacs.d/wpc/colorscheme.el
deleted file mode 100644
index 20d209f895..0000000000
--- a/users/wpcarro/emacs/.emacs.d/wpc/colorscheme.el
+++ /dev/null
@@ -1,85 +0,0 @@
-;;; colorscheme.el --- Syntax highlight and friends -*- lexical-binding: t -*-
-
-;; Author: William Carroll <wpcarro@gmail.com>
-;; Version: 0.0.1
-;; Package-Requires: ((emacs "24.3"))
-
-;;; 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)
-(require '>)
-(require 'cl-lib)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Library
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defcustom colorscheme-whitelist
-  (cycle-from-list
-   (->> (custom-available-themes)
-        (list-map #'symbol-name)
-        (list-filter (>-> (s-starts-with? "doom-")))
-        (list-map #'intern)))
-  "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 t)
-    (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-set 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))
-
-(provide 'colorscheme)
-;;; colorscheme.el ends here
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el b/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el
index 9384648ee9..c05585786e 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el
@@ -17,11 +17,13 @@
 (require 'prelude)
 (require 'al)
 (require 'fonts)
-(require 'colorscheme)
+(require 'theme)
 (require 'device)
 (require 'laptop-battery)
 (require 'modeline)
 (require 'general)
+(require 'dash)
+(require '>)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Configuration
@@ -162,7 +164,16 @@
 ;; during initialization?
 (when (device-laptop?) (laptop-battery-display))
 
-(colorscheme-whitelist-set 'doom-peacock)
+(setq theme-whitelist
+      (->> (custom-available-themes)
+           (list-map #'symbol-name)
+           (list-filter (>-> (s-starts-with? "doom-")))
+           (list-map #'intern)
+           cycle-from-list))
+(setq theme-linum-color-override "da5478")
+(add-hook 'theme-after-change
+          (lambda () (prelude-set-line-number-color "#da5478")))
+(theme-whitelist-set 'doom-flatwhite)
 
 (when window-system
   ;; On OSX, JetBrainsMono is installed as "JetBrains Mono", and I'm
diff --git a/users/wpcarro/emacs/default.nix b/users/wpcarro/emacs/default.nix
index 145d267c22..4ba737d752 100644
--- a/users/wpcarro/emacs/default.nix
+++ b/users/wpcarro/emacs/default.nix
@@ -53,6 +53,7 @@ let
       string
       struct
       symbol
+      theme
       tuple
       vterm-mgt
       zle
diff --git a/users/wpcarro/emacs/pkgs/theme/default.nix b/users/wpcarro/emacs/pkgs/theme/default.nix
new file mode 100644
index 0000000000..aea6394369
--- /dev/null
+++ b/users/wpcarro/emacs/pkgs/theme/default.nix
@@ -0,0 +1,14 @@
+{ pkgs, depot, ... }:
+
+pkgs.callPackage
+  ({ emacsPackages }:
+  emacsPackages.trivialBuild {
+    pname = "theme";
+    version = "1.0.0";
+    src = ./theme.el;
+    packageRequires =
+      (with depot.users.wpcarro.emacs.pkgs; [
+        cycle
+      ]);
+  })
+{ }
diff --git a/users/wpcarro/emacs/pkgs/theme/theme.el b/users/wpcarro/emacs/pkgs/theme/theme.el
new file mode 100644
index 0000000000..32f2c89a4d
--- /dev/null
+++ b/users/wpcarro/emacs/pkgs/theme/theme.el
@@ -0,0 +1,78 @@
+;;; theme.el --- Colors and stuff -*- lexical-binding: t -*-
+
+;; Author: William Carroll <wpcarro@gmail.com>
+;; Version: 0.0.1
+;; Package-Requires: ((emacs "24.3"))
+
+;;; Commentary:
+;;
+;; Cycle through a whitelist of themes.
+
+;;; Code:
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Dependencies
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(require 'cycle)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Library
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defgroup theme nil
+  "Customization options for `theme'."
+  :group 'theme)
+
+(defcustom theme-whitelist
+  (cycle-from-list (custom-available-themes))
+  "The whitelist of themes through which to cycle."
+  :type '(cycle symbol)
+  :group 'theme)
+
+(defcustom theme-after-change
+  nil
+  "Hook invoked after a new theme is loaded"
+  :type 'hook
+  :group 'theme)
+
+(defun theme-whitelist-set (theme)
+  "Focus the THEME in the `theme-whitelist' cycle."
+  (cycle-focus! (lambda (x) (equal x theme)) theme-whitelist)
+  (theme--set (cycle-current theme-whitelist)))
+
+(defun theme-select ()
+  "Load a theme using `completing-read'."
+  (interactive)
+  (let ((theme (completing-read "Theme: " (cycle-to-list theme-whitelist))))
+    (theme--disable-all)
+    (theme--set (intern theme))))
+
+(defun theme-next ()
+  "Disable the currently active theme and load the next theme."
+  (interactive)
+  (disable-theme (cycle-current theme-whitelist))
+  (theme--set (cycle-next! theme-whitelist))
+  (message (format "Active theme: %s" (cycle-current theme-whitelist))))
+
+(defun theme-prev ()
+  "Disable the currently active theme and load the previous theme."
+  (interactive)
+  (disable-theme (cycle-current theme-whitelist))
+  (theme--set (cycle-prev! theme-whitelist))
+  (message (format "Active theme: %s" (cycle-current theme-whitelist))))
+
+(defun theme--disable-all ()
+  "Disable all currently enabled themes."
+  (interactive)
+  (dolist (x custom-enabled-themes)
+    (disable-theme x)))
+
+(defun theme--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 t)
+    (run-hooks 'theme-after-change))
+
+(provide 'theme)
+;;; theme.el ends here