forked from dawranliou/sketch-themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch-themes.el
150 lines (126 loc) · 5.73 KB
/
sketch-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
148
149
150
;;; sketch-themes.el --- Sketch color themes -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Daw-Ran Liou
;; Author: Daw-Ran Liou <hi@dawranliou.com>
;; URL: https://github.com/dawranliou/sketch-themes/
;; Version: 1.0
;; Package-Requires: ((emacs "26.1"))
;; Keywords: faces
;; 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 of the License, 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.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; This file is not part of Emacs.
;;; Commentary:
;; A collection of (almost) grayscale Emacs themes. A lot of the code and
;; concepts were inspired by [@cryon](https://github.com/cryon)'s [Almost Mono
;; Themes](https://github.com/cryon/almost-mono-themes). Mostly what I did is
;; tweaking the color slightly to fit my tastes. Huge thanks to him!
;;; Code:
(defconst sketch-themes-colors
'((white . ((fg . "#212121")
(bg . "#FAFAFA")
(weak . "#888888")
(weaker . "#dddddd")
(weakest . "#efefef")
(highlight . "#fee761")
(success . "#63c74d")
(warning . "#e43b44")))
(black . ((fg . "#f0f6f0")
(bg . "#222323")
(weak . "#6E706E")
(weaker . "#555755")
(weakest . "#2F302F")
(highlight . "#7D5DC1")
;; (highlight . "#CC7F22") ; An alternative highlighting color
(success . "#63c74d")
(warning . "#e43b44")))))
(defmacro sketch-themes--variant-with-colors (variant &rest body)
"Execute BODY in a scope where the different colors for given
VARIANT is bound."
`(let* ((colors (or (cdr (assoc ,variant sketch-themes-colors))
(error "No such theme variant")))
(bg (cdr (assoc 'bg colors)))
(fg (cdr (assoc 'fg colors)))
(weak (cdr (assoc 'weak colors)))
(weaker (cdr (assoc 'weaker colors)))
(weakest (cdr (assoc 'weakest colors)))
(highlight (cdr (assoc 'highlight colors)))
(warning (cdr (assoc 'warning colors)))
(success (cdr (assoc 'success colors)))
(string (cdr (assoc 'string colors))))
,@body))
(defmacro sketch-themes--faces-spec ()
"Provide the faces specification."
(quote
(mapcar
(lambda (entry) (list (car entry) `((t ,@(cdr entry)))))
`(
;; default
(default (:background ,bg :foreground ,fg))
(fringe (:background ,bg :foreground ,weak))
(shadow (:background ,weakest))
(highlight (:foreground ,fg :background ,highlight))
(region (:foreground ,fg :background ,highlight))
(show-paren-match (:background ,highlight :bold t))
(show-paren-mismatch (:background ,warning :bold t))
(minibuffer-prompt (:bold t :foreground ,fg))
(isearch (:bold t :foreground ,fg :background ,weak :bold t))
(lazy-highlight (:foreground ,fg :background ,weaker))
(link (:underline t))
(parenthesis (:foreground ,weak))
(trailing-whitespace (:foreground nil :background ,warning))
(cursor (:background ,fg :foreground ,bg))
(vertical-border (:foreground ,weaker))
(default-italic (:italic t))
(line-number (:background ,bg :foreground ,weaker))
(line-number-current-line (:background ,bg :foreground ,fg))
;; mode line
(mode-line (:foreground ,fg :background ,weakest))
(mode-line-inactive (:foreground ,weaker :background ,weakest))
;; font lock
(font-lock-builtin-face (:foreground ,fg))
(font-lock-comment-face (:inherit font-lock-string-face))
(font-lock-negation-char-face (:foreground ,fg))
(font-lock-reference-face (:foreground ,fg))
(font-lock-constant-face (:bold t))
(font-lock-doc-face (:inherit font-lock-comment-face))
(font-lock-function-name-face (:foreground ,fg :bold t))
(font-lock-keyword-face (:foreground ,fg))
(font-lock-string-face (:foreground ,weak))
(font-lock-type-face (:foreground ,fg))
(font-lock-variable-name-face (:foreground ,fg :bold t))
(font-lock-warning-face (:underline (:color ,warning :style wave)))
(fill-column-indicator (:foreground ,weakest))
;; clojure mode
(clojure-keyword-face (:foreground ,fg))
;; hl line
(hl-line (:background ,weakest))
;; hl fill column
(hl-fill-column-face (:background ,weaker))))))
(defun sketch-themes--variant-name (variant)
"Create symbol for color theme variant VARIANT."
(intern (format "sketch-%s" (symbol-name variant))))
(defmacro sketch-themes--define-theme (variant)
"Define a theme for the sketch variant VARIANT."
(let ((name (sketch-themes--variant-name variant))
(doc (format "Sketch Theme (%s version)" variant)))
`(progn
(deftheme ,name ,doc)
(put ',name 'theme-immediate t)
(sketch-themes--variant-with-colors
',variant
(apply 'custom-theme-set-faces ',name
(sketch-themes--faces-spec)))
(provide-theme ',name))))
;;;###autoload
(when (and (boundp 'custom-theme-load-path) load-file-name)
(add-to-list 'custom-theme-load-path
(file-name-as-directory (file-name-directory load-file-name))))
(provide 'sketch-themes)
;;; sketch-themes.el ends here