-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathstimmung-themes.el
147 lines (118 loc) · 5.38 KB
/
stimmung-themes.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
;;; stimmung-themes.el --- Themes tuned to inner harmonies -*- lexical-binding: t -*-
;; Copyright © 2019
;; Author: Love Lagerkvist
;; URL: https://github.com/motform/stimmung-themes
;; Package-Requires: ((emacs "25"))
;; Created: 2019-12-20
;; Version: 2021-03-20
;; Keywords: faces
;; This file is NOT part of GNU Emacs.
;;; License:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Stimmung (dark and light) is a pair of monochrome Emacs themes
;; with minimal syntax highlighting. They are inspired by Tonsky's
;; Alabaster theme (https://github.com/tonsky/sublime-scheme-alabaster),
;; following the maxim that a theme that highlights everything
;; paradoxically highlights nothing. Text backgrounds (comments,
;; strings and constants) and font variations (definitions) are used
;; as alternatives to text colors, ensuring a harmonious reading
;; experience. Use `stimmung-themes-dark-highlight-color' and
;; `stimmung-themes-light-highlight-color' to customize the highlight.
;;
;; Screenshots are available at: https://github.com/motform/stimmung-themes
;;; Code:
;;; Theme loading/toggle inspired/sourced from the fantastic `protesilaos/modus-themes'
(defgroup stimmung-themes nil
"Stimmung settings.
You have to re-load the theme for these changes to take effect."
:group 'faces
:prefix "stimmung-theme-"
:link '(url-link "https://github.com/motform/stimmung-themes"))
;;; Highlight colors
(defcustom stimmung-themes-dark-highlight-color "#40382b" ; I dub this shade "Japanese gravy"
"The dark theme color for highlights, the only non-monochrome color in code."
:type 'string
:group 'stimmung-themes)
(defcustom stimmung-themes-dark-highlight-color-foreground "bisque1"
"The dark theme color for highlights that are defined as 'foreground.
There are no 'foreground colors active by default."
:type 'string
:group 'stimmung-themes)
(defcustom stimmung-themes-light-highlight-color "cornsilk1"
"The light theme color for highlights, the only non-monochrome color in code."
:type 'string
:group 'stimmung-themes)
(defcustom stimmung-themes-light-highlight-color-foreground "dark goldenrod"
"The light theme color for highlights that are defined as 'foreground.
There are no 'foreground colors active by default."
:type 'string
:group 'stimmung-themes)
;;; font-lock faces
(defmacro stimmung-themes--font-lock-face (name default)
"Register the custom font-lock-face for NAME with value DEFAULT."
(let ((custom-name (intern (concat "stimmung-themes-" name))))
`(defcustom ,custom-name ,default
,(format "The type of highlighting used for %s." name)
:type 'symbol
:group 'stimmung-themes
:options '('background 'foreground 'none))))
(stimmung-themes--font-lock-face "builtin" 'background)
(stimmung-themes--font-lock-face "comment" 'background)
(stimmung-themes--font-lock-face "doc" 'background)
(stimmung-themes--font-lock-face "constant" 'background)
(stimmung-themes--font-lock-face "string" 'background)
(stimmung-themes--font-lock-face "markup" 'background)
(stimmung-themes--font-lock-face "type" 'none)
(stimmung-themes--font-lock-face "function-name" 'none)
(stimmung-themes--font-lock-face "keyword" 'none)
(stimmung-themes--font-lock-face "variable-name" 'none)
(stimmung-themes--font-lock-face "preprocessor" 'none)
(stimmung-themes--font-lock-face "regex" 'none)
;;;; Interactive functions
;;;###autoload
(defun stimmung-themes-load-dark ()
"Load `stimmung-dark' and disable `stimmung-light'."
(interactive)
(disable-theme 'stimmung-themes-light)
(load-theme 'stimmung-themes-dark t))
;;;###autoload
(defun stimmung-themes-load-light ()
"Load `stimmung-light' and disable `stimmung-dark'."
(interactive)
(disable-theme 'stimmung-themes-dark)
(load-theme 'stimmung-themes-light t))
;;;###autoload
(defun stimmung-themes--toggle-prompt ()
"Helper for `stimmung-themes-toggle'."
(let ((theme (intern (completing-read "Load Stimmung theme: "
'(stimmung-themes-light stimmung-themes-dark) nil t))))
(mapc #'disable-theme custom-enabled-themes) ; make sure to disable any non-stimmung themes to ignore accidental face-overlap
(pcase theme
('stimmung-themes-light (stimmung-themes-load-light))
('stimmung-themes-dark (stimmung-themes-load-dark)))))
;;;###autoload
(defun stimmung-themes-toggle ()
"Toggle between the dark and light version of `stimmung-themes'.
Prompt the user for which to pick in case none is enabled.
Currently assumes the themes is loaded, which might be an issue.
Inspired by stimmung-themes."
(interactive)
(pcase (car custom-enabled-themes)
('stimmung-themes-light (stimmung-themes-load-dark))
('stimmung-themes-dark (stimmung-themes-load-light))
(_ (stimmung-themes--toggle-prompt))))
(provide 'stimmung-themes)
;; Local Variables:
;; no-byte-compile: t
;; End:
;;; stimmung-themes.el ends here