From be7ab7767a3674c891c4c58783d70276bd423ab7 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 17 Aug 2023 08:17:01 +0200 Subject: emacs: Add my own custom Emacs theme --- .config/emacs/config.org | 68 ++++++++++------------ .config/emacs/mango-theme.el | 130 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 38 deletions(-) create mode 100644 .config/emacs/mango-theme.el (limited to '.config/emacs') diff --git a/.config/emacs/config.org b/.config/emacs/config.org index 20568ed..caa7dd2 100644 --- a/.config/emacs/config.org +++ b/.config/emacs/config.org @@ -859,44 +859,6 @@ display line numbers in certain modes. #+END_SRC -*** Emacs Theme - -The default theme is a light theme. I am not one of these weak-eyed retards -that cannot handle a light theme, but it is really, /really/ bad. Personally I -quite enjoy the /Sanity Inc./ themes, and they’re a lot less generic than the -Doom One theme that everyone and their grandmother uses. - -Personally I am not sure if I prefer ~tomorrow-night~ or ~tomorrow-eighties~, so -why not make it random? - -#+BEGIN_SRC elisp - - (use-package color-theme-sanityinc-tomorrow - :config - (let ((n (random 2))) - (cond ((eq n 0) (load-theme 'sanityinc-tomorrow-night t)) - ((eq n 1) (load-theme 'sanityinc-tomorrow-eighties t))))) - -#+END_SRC - -There is one issue though. I like to have ~vertico~ use the same color when -highlighting my current selection as I use to highlight the current line, and -that changes with each theme I use. For this reason we need some advice around -the ~load-theme~ function to fire a hook. - -#+BEGIN_SRC elisp - - (defvar mango-after-load-theme-hook nil - "Hook called after ‘load-theme’ is run.") - - (defun mango--run-after-load-theme-hook (&rest unused) - "Run the hooks in ‘mango-after-load-theme-hook’ after we load a new theme." - (run-hooks 'mango-after-load-theme-hook)) - - (advice-add 'load-theme :after #'mango--run-after-load-theme-hook) - -#+END_SRC - *** Fonts My favorite monospace font has got to be /Iosevka/. It’s good looking, it’s far @@ -957,6 +919,36 @@ every frame. We also can’t forget the frame that’s actually running this co #+END_SRC +*** Emacs Theme + +I previously ran the ~sanityinc-tomorrow-eighties~ theme, but I now run my own +custom theme. I do like to keep the older theme around though as a reference. + +#+BEGIN_SRC elisp + + (use-package color-theme-sanityinc-tomorrow) + (load-theme 'mango t) + +#+END_SRC + +There is one issue though. I like to have ~vertico~ use the same color when +highlighting my current selection as I use to highlight the current line, and +that changes with each theme I use. For this reason we need some advice around +the ~load-theme~ function to fire a hook. + +#+BEGIN_SRC elisp + + (defvar mango-after-load-theme-hook nil + "Hook called after ‘load-theme’ is run.") + + (defun mango--run-after-load-theme-hook (&rest unused) + "Run the hooks in ‘mango-after-load-theme-hook’ after we load a new theme." + (run-hooks 'mango-after-load-theme-hook)) + + (advice-add 'load-theme :after #'mango--run-after-load-theme-hook) + +#+END_SRC + *** Line Highlighting This is just something I personally like having. It makes it very easy for me diff --git a/.config/emacs/mango-theme.el b/.config/emacs/mango-theme.el new file mode 100644 index 0000000..7e74d17 --- /dev/null +++ b/.config/emacs/mango-theme.el @@ -0,0 +1,130 @@ +;;; mango-theme.el --- Just your average dark theme -*- lexical-binding: t -*- + +;; Copyright © 2023 Thomas Voss + +;; Author: Thomas Voss +;; Maintainer: Thomas Voss +;; URL: https://git.sr.ht/~mango/mango-theme +;; Mailing-List: https://lists.sr.ht/~mango/public-inbox + +;;; License: + +;; Permission to use, copy, modify, and/or distribute this software for any +;; purpose with or without fee is hereby granted. +;; +;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +;; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +;; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +;; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +;; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +;; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +;; PERFORMANCE OF THIS SOFTWARE. + +;;; Commentary: + +;; TODO + +;;; Code: + +(deftheme mango + "Just another dark theme because none of the other options out there were just +as I would like them. Why try to fix someone elses themes when I make my own?") + +(defun mango-theme--get-color (name) + "Get the RGB value of the color NAME from ‘mango-theme-palette’" + (cadr (assq name mango-theme-palette))) + +(defmacro mango-theme--generate-set-faces (&rest body) + "A macro to provide a much simpler syntax than what is expected by +‘custom-theme-set-faces’. This is possible because I only run Emacs +graphically, so I shouldn’t need to have multiple specs per face. + +\(fn SPEC...)" + (declare (indent 0)) + (let ((ret '('mango custom-theme-set-faces))) + (dolist (spec body) + (add-to-list 'ret `(backquote ,(list (car spec) `((t ,(cdr spec))))))) + (reverse ret))) + +(defconst mango-theme-palette + '((foreground "#C5C8C6") + (background "#2B303B") + (background-cool "#363C4A") + (background-faint "#414859") + (middleground "#4F5561") + (disabled "#999999") + (pale-azure "#9CDCFE") + (celestial-blue "#569CD6") + (violet "#E57AE5") + (khaki "#F0E68C") + (lime "#B8F182") + (orange "#F1B282") + (citron "#ED97F5"))) + +(mango-theme--generate-set-faces + ;; Standard Stuff + (default + :foreground ,(mango-theme--get-color 'foreground) + :background ,(mango-theme--get-color 'background)) + (fringe + :inherit default) + + ;; Lines + (hl-line + :background ,(mango-theme--get-color 'background-faint)) + (region + :background ,(mango-theme--get-color 'middleground)) + (mode-line + :background ,(mango-theme--get-color 'middleground)) + (mode-line-inactive + :background ,(mango-theme--get-color 'background-cool) + :weight light) + + ;; Line Numbers + (line-number + :background ,(mango-theme--get-color 'background-cool)) + (line-number-current-line + :background ,(mango-theme--get-color 'background-cool) + :weight bold) + + ;; Documentation + (font-lock-comment-face + :foreground ,(mango-theme--get-color 'disabled)) + (font-lock-doc-face + :inherit font-lock-comment-face) + + ;; Core Language + (font-lock-keyword-face + :foreground ,(mango-theme--get-color 'violet)) + (font-lock-type-face + :foreground ,(mango-theme--get-color 'celestial-blue)) + (font-lock-builtin-face + :inherit font-lock-preprocessor-face) + + ;; Function-likes + (font-lock-function-name-face + :foreground ,(mango-theme--get-color 'khaki)) + (font-lock-preprocessor-face + :foreground ,(mango-theme--get-color 'citron) + :weight bold) + + ;; Variables + (font-lock-variable-name-face + :foreground ,(mango-theme--get-color 'pale-azure)) + (font-lock-constant-face + :inherit font-lock-variable-name-face + :weight bold) + + ;; Org Mode + (org-code + :foreground ,(mango-theme--get-color 'orange)) + (org-verbatim + :foreground ,(mango-theme--get-color 'lime)) + (org-block + :background ,(mango-theme--get-color 'background-cool)) + (org-hide + :foreground ,(mango-theme--get-color 'background)) + + ;; Info Page + (Info-quoted + :inherit default)) -- cgit v1.2.3