]> git.earman.xyz Git - emacsinit.git/commitdiff
Add two themes, use them, defun to switch between them
authorrearman <rearman@r717.net>
Wed, 25 Mar 2026 14:43:28 +0000 (10:43 -0400)
committerrearman <rearman@r717.net>
Wed, 25 Mar 2026 14:43:28 +0000 (10:43 -0400)
Default to mostly b&w theme, but able to swap between mono and color with a
function.  No binding, since it is more a curiosity to switch, and probably
per session, rather than per buffer.

init.el
re/8color-ansi-theme.el [new file with mode: 0644]
re/b&w-theme.el [new file with mode: 0644]

diff --git a/init.el b/init.el
index c95572a61421d0b43af5656da72fedbe6c890f03..79dd146f969f4f7def24c79dbd75ce9cd6b00cc8 100644 (file)
--- a/init.el
+++ b/init.el
 (setq bookmark-save-flag 1)
 \f
 ;; GUI Settings
-(set-face-attribute 'default nil :foreground "white" :background "black")
-(set-face-attribute 'error nil :foreground "red")
-(set-face-attribute 'highlight nil :background "darkseagreen2" :foreground "black")
-(set-face-attribute 'region nil :background "blue" :foreground "white" :extend t)
-;;; Mode Line
-(set-face-attribute 'mode-line nil :box t :foreground "white" :background "black")
-(set-face-attribute 'mode-line-inactive nil :box nil :foreground "white" :background "black")
-;;; Font-Lock
-(set-face-attribute 'font-lock-builtin-face nil :foreground "blue" :weight 'bold)
-(set-face-attribute 'font-lock-comment-face nil :foreground "red1")
-(set-face-attribute 'font-lock-constant-face nil :foreground "magenta")
-(set-face-attribute 'font-lock-function-name-face nil :foreground "blue" :weight 'bold)
-(set-face-attribute 'font-lock-keyword-face nil :foreground "cyan" :weight 'bold)
-(set-face-attribute 'font-lock-string-face nil :foreground "green")
-(set-face-attribute 'font-lock-type-face nil :foreground "green")
-(set-face-attribute 'font-lock-variable-name-face nil :foreground "yellow" :weight 'light)
-;;; Org
-(set-face-attribute 'org-agenda-structure nil :foreground "blue" :bold t)
-(set-face-attribute 'org-time-grid nil :foreground "yellow")
-(set-face-attribute 'org-todo nil :foreground "red" :bold t)
-(set-face-attribute 'org-done nil :foreground "green")
-(set-face-attribute 'org-agenda-done nil :foreground "green" : t)
-(set-face-attribute 'org-done nil :foreground "green")
-(set-face-attribute 'org-upcoming-deadline nil :foreground "pink" :bold t)
+(require '8color-ansi-theme)
+(require 'b&w-theme)
+(load-theme 'b&w t)
+
+(defun swap-theme ()
+  (interactive)
+  (let* ((theme (car custom-enabled-themes))
+        (new (if (equal theme 'b&w) '8color-ansi 'b&w)))
+    (disable-theme theme)
+    (load-theme new t)))
 
 (menu-bar-mode -1)
 (tool-bar-mode -1)
diff --git a/re/8color-ansi-theme.el b/re/8color-ansi-theme.el
new file mode 100644 (file)
index 0000000..421949b
--- /dev/null
@@ -0,0 +1,181 @@
+;;; 8color-ansi-theme.el --- -*- lexical-binding: t; -*-
+
+;;; Code:
+
+(deftheme 8color-ansi
+  "Simple dark color theme")
+
+(let ((class '((class color) (min-colors 89))))
+  (custom-theme-set-faces
+   '8color-ansi
+;;;; Special faces.
+   `(default
+     ((,class (:foreground "#fff" :background "#000"))))
+   `(error
+     ((,class (:foreground "#f00" :underline t))))
+   `(warning
+     ((,class (:foreground "#ff0"))))
+   `(success
+     ((,class (:foreground "#0f0"))))
+;;;; font-lock.
+   `(font-lock-comment-face
+     ((,class (:foreground "#f00" :slant italic :weight light))))
+   `(font-lock-string-face
+     ((,class (:foreground "#0ff"))))
+   `(font-lock-builtin-face
+     ((,class (:foreground "#08f"))))
+   `(font-lock-type-face
+     ((,class (:foreground "#08f"))))
+   `(font-lock-constant-face
+     ((,class (:foreground "#08f"))))
+   `(font-lock-function-name-face
+     ((,class (:foreground "#0f0"))))
+   `(font-lock-variable-name-face
+     ((,class (:foreground "#0f0"))))
+   `(font-lock-keyword-face
+     ((,class (:foreground "#ff0"))))
+   `(font-lock-number-face
+     ((,class (:foreground "#f0f"))))
+   `(font-lock-warning-face
+     ((,class (:foreground "f80" :underline nil))))
+;;;; Decorations.
+   `(vertical-border
+     ((,class (:foreground "#f00"))))
+   `(scroll-bar
+     ((,class (:foreground "#f00"))))
+   `(region
+     ((,class (:background "#08f" :foreground "fff"))))
+   `(shadow
+     ((,class (:foreground "#f00"))))
+   `(match
+     ((,class (:background "#f00"))))
+   `(highlight
+     ((,class (:background "#08f" :foreground "fff"))))
+   `(lazy-highlight
+     ((,class (:background "#08f" :foreground "fff"))))
+   `(isearch
+     ((,class (:foreground "#000" :background "#fff"))))
+   `(fringe
+     ((,class (:foreground "#f00" :background "#000"))))
+   `(line-number
+     ((,class (:foreground "#f00" :background "#000"))))
+   `(line-number-current-line
+     ((,class (:foreground "#000" :background "#f00" :weight bold))))
+   `(mode-line
+     ((,class (:foreground "#fff" :background "#000" :box t))))
+   `(mode-line-inactive
+     ((,class (:foreground "#888" :background "#000" :box t))))
+   `(mode-line-highlight
+     ((,class (:box (:line-width 1 :color "#0ff" :style released-button)))))
+;;; Org
+   `(org-document-title
+     ((,class (:foreground "#ff0" :weight bold))))
+   `(org-level-1
+     ((,class (:foreground "#0ff"))))
+   `(org-level-2
+     ((,class (:foreground "#0ff"))))
+   `(org-level-3
+     ((,class (:foreground "#0ff"))))
+   `(org-level-4
+     ((,class (:foreground "#0ff"))))
+   `(org-level-5
+     ((,class (:foreground "#0ff"))))
+   `(org-level-6
+     ((,class (:foreground "#0ff"))))
+   `(org-level-7
+     ((,class (:foreground "#0ff"))))
+   `(org-level-8
+     ((,class (:foreground "#0ff"))))
+   `(org-todo
+     ((,class (:foreground "#f00"))))
+   `(org-done
+     ((,class (:foreground "#0f0"))))
+   `(org-headline-done
+     ((,class (:foreground "#0ff"))))
+   `(org-ellipsis
+     ((,class (:foreground "#ff0" :underline nil))))
+   `(org-document-info-keyword
+     ((,class (:foreground "#0ff"))))
+   `(org-special-keyword
+     ((,class (:foreground "#0ff"))))
+   `(org-checkbox
+     ((,class (:foreground "#0ff" :background "#000" :box nil))))
+   `(org-tag
+     ((,class (:foreground "#ff0"))))
+   `(org-code
+     ((,class (:foreground "#00f"))))
+   `(org-verbatim
+     ((,class (:foreground "#00f" :box (:line-width 1 :color "#0ff" :style released-button)))))
+   `(org-table
+     ((,class (:foreground "#0ff"))))
+   `(org-formula
+     ((,class (:foreground "#0ff"))))
+   `(org-block
+     ((,class (:foreground "#fff"))))
+   `(org-block-begin-line
+     ((,class (:foreground "#00f"))))
+   `(org-block-end-line
+     ((,class (:foreground "#00f"))))
+   `(org-drawer
+     ((,class (:foreground "#00f"))))
+   `(org-priority
+     ((,class (:foreground "#00f"))))
+   `(org-footnote
+     ((,class (:foreground "#00f"))))
+   `(org-date
+     ((,class (:foreground "#00f"))))
+   `(org-link
+     ((,class (:foreground "#00f"))))
+;;; Org Agenda
+   `(header-line
+     ((,class (:foreground "#ff0" :background "#000" :weight bold :height 1.25))))
+   `(org-agenda-structure
+     ((,class (:foreground "#ff0" :background "#000" :box nil :weight bold :height 1.25))))
+   `(org-column
+     ((,class (:background "#000"))))
+   `(org-warning
+     ((,class (:foreground "#f0f"))))
+   `(org-agenda-done
+     ((,class (:foreground "#0f0" :slant normal))))
+   `(org-time-grid
+     ((,class (:foreground "#0ff"))))
+   `(calendar-weekday-header
+     ((,class (:foreground "#ff0"))))
+   `(org-agenda-calendar-event
+     ((,class (:foreground "#fff"))))
+   `(org-agenda-clocking
+     ((,class (:foreground "#0ff" :background "#f00"))))
+   `(org-agenda-date
+     ((,class (:foreground "#00f" :background "#000" :box nil :weight normal))))
+   `(org-agenda-date-weekend
+     ((,class (:foreground "#00f" :background "#000" :box nil :weight normal :underline nil))))
+   `(org-agenda-date-today
+     ((,class (:foreground "#ff0" :background "#000" :box nil :weight normal :slant normal :inverse-video nil))))
+   `(org-upcoming-distant-deadline
+     ((,class (:foreground "#f80"))))
+   `(org-upcoming-deadline
+     ((,class (:foreground "#f88"))))
+   `(org-imminent-deadline
+     ((,class (:foreground "#f00" :weight normal))))
+   `(org-scheduled
+     ((,class (:foreground "#0f0"))))
+   `(org-scheduled-today
+     ((,class (:foreground "#0f0"))))
+   `(org-scheduled-previously
+     ((,class (:foreground "#ff0"))))
+;;; Misc. other packages
+   `(corfu-default
+     ((,class (:foreground "#08f" :background "#000"))))
+   `(corfu-current
+     ((,class (:foreground "#000" :background "#08f"))))
+   `(dired-ignored
+     ((,class (:foreground "#0ff"))))))
+
+;;;###autoload
+(when load-file-name
+  (add-to-list 'custom-theme-load-path
+              (file-name-as-directory (file-name-directory load-file-name))))
+
+(provide-theme '8color-ansi)
+(provide '8color-ansi-theme)
+;;; 8color-ansi-theme.el ends here
diff --git a/re/b&w-theme.el b/re/b&w-theme.el
new file mode 100644 (file)
index 0000000..dd10af3
--- /dev/null
@@ -0,0 +1,185 @@
+;;; b&w-theme.el --- -*- lexical-binding: t; -*-
+
+;;; Code:
+
+(deftheme b&w
+  "Mostly monochrome dark color theme")
+
+(let ((class '((class color) (min-colors 89)))
+      (text "#fff")
+      (bg "#000")
+      (red "#f00")
+      (green "#0f0"))
+  (custom-theme-set-faces
+   'b&w
+;;;; Special faces.
+   `(default
+     ((,class (:foreground ,text :background ,bg))))
+   `(error
+     ((,class (:foreground ,text :underline t))))
+   `(warning
+     ((,class (:foreground ,text))))
+   `(success
+     ((,class (:foreground ,text))))
+;;;; font-lock.
+   `(font-lock-comment-face
+     ((,class (:foreground ,text :slant italic :weight light))))
+   `(font-lock-string-face
+     ((,class (:foreground ,text))))
+   `(font-lock-builtin-face
+     ((,class (:foreground ,text))))
+   `(font-lock-type-face
+     ((,class (:foreground ,text))))
+   `(font-lock-constant-face
+     ((,class (:foreground ,text))))
+   `(font-lock-function-name-face
+     ((,class (:foreground ,text))))
+   `(font-lock-variable-name-face
+     ((,class (:foreground ,text))))
+   `(font-lock-keyword-face
+     ((,class (:foreground ,text))))
+   `(font-lock-number-face
+     ((,class (:foreground ,text))))
+   `(font-lock-warning-face
+     ((,class (:foreground "fff" :underline nil))))
+;;;; Decorations.
+   `(vertical-border
+     ((,class (:foreground ,text))))
+   `(scroll-bar
+     ((,class (:foreground ,text))))
+   `(region
+     ((,class (:background ,text :foreground ,bg))))
+   `(shadow
+     ((,class (:foreground ,text))))
+   `(match
+     ((,class (:background ,text))))
+   `(highlight
+     ((,class (:background ,text :foreground ,bg))))
+   `(lazy-highlight
+     ((,class (:background ,text :foreground ,bg))))
+   `(isearch
+     ((,class (:foreground ,text :background ,bg))))
+   `(fringe
+     ((,class (:foreground ,text :background ,bg))))
+   `(line-number
+     ((,class (:foreground ,text :background ,bg))))
+   `(line-number-current-line
+     ((,class (:foreground ,bg :background ,text :weight bold))))
+   `(mode-line
+     ((,class (:foreground ,text :background ,bg :box t))))
+   `(mode-line-inactive
+     ((,class (:foreground "#888" :background ,bg :box t))))
+   `(mode-line-highlight
+     ((,class (:box (:line-width 1 :color ,text :style released-button)))))
+;;; Org
+   `(org-document-title
+     ((,class (:foreground ,text :weight bold))))
+   `(org-level-1
+     ((,class (:foreground ,text))))
+   `(org-level-2
+     ((,class (:foreground ,text))))
+   `(org-level-3
+     ((,class (:foreground ,text))))
+   `(org-level-4
+     ((,class (:foreground ,text))))
+   `(org-level-5
+     ((,class (:foreground ,text))))
+   `(org-level-6
+     ((,class (:foreground ,text))))
+   `(org-level-7
+     ((,class (:foreground ,text))))
+   `(org-level-8
+     ((,class (:foreground ,text))))
+   `(org-todo
+     ((,class (:foreground ,red :bold t))))
+   `(org-done
+     ((,class (:foreground ,green :italic t))))
+   `(org-headline-done
+     ((,class (:foreground ,green))))
+   `(org-ellipsis
+     ((,class (:foreground ,text :underline nil))))
+   `(org-document-info-keyword
+     ((,class (:foreground ,text))))
+   `(org-special-keyword
+     ((,class (:foreground ,text))))
+   `(org-checkbox
+     ((,class (:foreground ,text :background ,bg :box nil))))
+   `(org-tag
+     ((,class (:foreground ,text :bold t))))
+   `(org-code
+     ((,class (:foreground ,text))))
+   `(org-verbatim
+     ((,class (:foreground ,text :box (:line-width 1 :color ,text :style released-button)))))
+   `(org-table
+     ((,class (:foreground ,text))))
+   `(org-formula
+     ((,class (:foreground ,text))))
+   `(org-block
+     ((,class (:foreground ,text))))
+   `(org-block-begin-line
+     ((,class (:foreground ,text))))
+   `(org-block-end-line
+     ((,class (:foreground ,text))))
+   `(org-drawer
+     ((,class (:foreground ,text))))
+   `(org-priority
+     ((,class (:foreground ,text))))
+   `(org-footnote
+     ((,class (:foreground ,text))))
+   `(org-date
+     ((,class (:foreground ,text))))
+   `(org-link
+     ((,class (:foreground ,text))))
+;;; Org Agenda
+   `(header-line
+     ((,class (:foreground ,text :background ,bg :weight bold :height 1.25))))
+   `(org-agenda-structure
+     ((,class (:foreground ,text :background ,bg :box nil :weight bold :height 1.25))))
+   `(org-column
+     ((,class (:background ,bg))))
+   `(org-warning
+     ((,class (:foreground ,text))))
+   `(org-agenda-done
+     ((,class (:foreground ,text :italic t))))
+   `(org-time-grid
+     ((,class (:foreground ,text :bold t))))
+   `(calendar-weekday-header
+     ((,class (:foreground ,text))))
+   `(org-agenda-calendar-event
+     ((,class (:foreground ,text))))
+   `(org-agenda-clocking
+     ((,class (:foreground ,bg :background ,text))))
+   `(org-agenda-date
+     ((,class (:foreground ,text :background ,bg :box nil :weight normal))))
+   `(org-agenda-date-weekend
+     ((,class (:foreground ,text :background ,bg :box nil :weight normal :underline nil))))
+   `(org-agenda-date-today
+     ((,class (:foreground ,text :background ,bg :box nil :weight normal :slant normal :inverse-video nil))))
+   `(org-upcoming-distant-deadline
+     ((,class (:foreground ,text :italic t))))
+   `(org-upcoming-deadline
+     ((,class (:foreground ,text :italic t))))
+   `(org-imminent-deadline
+     ((,class (:foreground ,text :weight bold))))
+   `(org-scheduled
+     ((,class (:foreground ,text))))
+   `(org-scheduled-today
+     ((,class (:foreground ,text))))
+   `(org-scheduled-previously
+     ((,class (:foreground ,text))))
+;;; Misc. other packages
+   `(corfu-default
+     ((,class (:foreground ,text :background ,bg))))
+   `(corfu-current
+     ((,class (:foreground ,bg :background ,text))))
+   `(dired-ignored
+     ((,class (:foreground ,text))))))
+
+;;;###autoload
+(when load-file-name
+  (add-to-list 'custom-theme-load-path
+              (file-name-as-directory (file-name-directory load-file-name))))
+
+(provide-theme 'b&w)
+(provide 'b&w-theme)
+;;; b&w-theme.el ends here