Skip to content

Commit 0c9f7ab

Browse files
Use display-color-cells to enable 24-bit color terminal support (#88)
In order to fix "unable to load color x" errors when running Emacs in daemon-mode, the defined theme colors are now tested against the `display-color-cells` "display feature testing" function [1] to support 24-bit color terminals with a fallback to the `display-graphic-p` function. This is a first step to fix the problems described in GH-59. Related to GH-59
1 parent d334299 commit 0c9f7ab

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

nord-theme.el

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -93,39 +93,43 @@
9393
Please see https://github.com/arcticicestudio/nord-emacs/issues/73 for more details."
9494
"0.4.0")
9595

96+
(defun nord-display-truecolor-or-graphic-p ()
97+
"Returns whether the display can display nord colors"
98+
(or (= (display-color-cells) 16777216) (display-graphic-p)))
99+
96100
;;;; Color Constants
97101
(let ((class '((class color) (min-colors 89)))
98-
(nord0 (if (display-graphic-p) "#2E3440" nil))
99-
(nord1 (if (display-graphic-p) "#3B4252" "black"))
100-
(nord2 (if (display-graphic-p) "#434C5E" "#434C5E"))
101-
(nord3 (if (display-graphic-p) "#4C566A" "brightblack"))
102-
(nord4 (if (display-graphic-p) "#D8DEE9" "#D8DEE9"))
103-
(nord5 (if (display-graphic-p) "#E5E9F0" "white"))
104-
(nord6 (if (display-graphic-p) "#ECEFF4" "brightwhite"))
105-
(nord7 (if (display-graphic-p) "#8FBCBB" "cyan"))
106-
(nord8 (if (display-graphic-p) "#88C0D0" "brightcyan"))
107-
(nord9 (if (display-graphic-p) "#81A1C1" "blue"))
108-
(nord10 (if (display-graphic-p) "#5E81AC" "brightblue"))
109-
(nord11 (if (display-graphic-p) "#BF616A" "red"))
110-
(nord12 (if (display-graphic-p) "#D08770" "brightyellow"))
111-
(nord13 (if (display-graphic-p) "#EBCB8B" "yellow"))
112-
(nord14 (if (display-graphic-p) "#A3BE8C" "green"))
113-
(nord15 (if (display-graphic-p) "#B48EAD" "magenta"))
114-
(nord-annotation (if (display-graphic-p) "#D08770" "brightyellow"))
115-
(nord-attribute (if (display-graphic-p) "#8FBCBB" "cyan"))
116-
(nord-class (if (display-graphic-p) "#8FBCBB" "cyan"))
117-
(nord-comment (if (display-graphic-p) (nord-theme--brightened-comment-color nord-comment-brightness) "brightblack"))
118-
(nord-escape (if (display-graphic-p) "#D08770" "brightyellow"))
119-
(nord-method (if (display-graphic-p) "#88C0D0" "brightcyan"))
120-
(nord-keyword (if (display-graphic-p) "#81A1C1" "blue"))
121-
(nord-numeric (if (display-graphic-p) "#B48EAD" "magenta"))
122-
(nord-operator (if (display-graphic-p) "#81A1C1" "blue"))
123-
(nord-preprocessor (if (display-graphic-p) "#5E81AC" "brightblue"))
124-
(nord-punctuation (if (display-graphic-p) "#D8DEE9" "#D8DEE9"))
125-
(nord-regexp (if (display-graphic-p) "#EBCB8B" "yellow"))
126-
(nord-string (if (display-graphic-p) "#A3BE8C" "green"))
127-
(nord-tag (if (display-graphic-p) "#81A1C1" "blue"))
128-
(nord-variable (if (display-graphic-p) "#D8DEE9" "#D8DEE9"))
102+
(nord0 (if (nord-display-truecolor-or-graphic-p) "#2E3440" nil))
103+
(nord1 (if (nord-display-truecolor-or-graphic-p) "#3B4252" "black"))
104+
(nord2 (if (nord-display-truecolor-or-graphic-p) "#434C5E" "#434C5E"))
105+
(nord3 (if (nord-display-truecolor-or-graphic-p) "#4C566A" "brightblack"))
106+
(nord4 (if (nord-display-truecolor-or-graphic-p) "#D8DEE9" "#D8DEE9"))
107+
(nord5 (if (nord-display-truecolor-or-graphic-p) "#E5E9F0" "white"))
108+
(nord6 (if (nord-display-truecolor-or-graphic-p) "#ECEFF4" "brightwhite"))
109+
(nord7 (if (nord-display-truecolor-or-graphic-p) "#8FBCBB" "cyan"))
110+
(nord8 (if (nord-display-truecolor-or-graphic-p) "#88C0D0" "brightcyan"))
111+
(nord9 (if (nord-display-truecolor-or-graphic-p) "#81A1C1" "blue"))
112+
(nord10 (if (nord-display-truecolor-or-graphic-p) "#5E81AC" "brightblue"))
113+
(nord11 (if (nord-display-truecolor-or-graphic-p) "#BF616A" "red"))
114+
(nord12 (if (nord-display-truecolor-or-graphic-p) "#D08770" "brightyellow"))
115+
(nord13 (if (nord-display-truecolor-or-graphic-p) "#EBCB8B" "yellow"))
116+
(nord14 (if (nord-display-truecolor-or-graphic-p) "#A3BE8C" "green"))
117+
(nord15 (if (nord-display-truecolor-or-graphic-p) "#B48EAD" "magenta"))
118+
(nord-annotation (if (nord-display-truecolor-or-graphic-p) "#D08770" "brightyellow"))
119+
(nord-attribute (if (nord-display-truecolor-or-graphic-p) "#8FBCBB" "cyan"))
120+
(nord-class (if (nord-display-truecolor-or-graphic-p) "#8FBCBB" "cyan"))
121+
(nord-comment (if (nord-display-truecolor-or-graphic-p) (nord-theme--brightened-comment-color nord-comment-brightness) "brightblack"))
122+
(nord-escape (if (nord-display-truecolor-or-graphic-p) "#D08770" "brightyellow"))
123+
(nord-method (if (nord-display-truecolor-or-graphic-p) "#88C0D0" "brightcyan"))
124+
(nord-keyword (if (nord-display-truecolor-or-graphic-p) "#81A1C1" "blue"))
125+
(nord-numeric (if (nord-display-truecolor-or-graphic-p) "#B48EAD" "magenta"))
126+
(nord-operator (if (nord-display-truecolor-or-graphic-p) "#81A1C1" "blue"))
127+
(nord-preprocessor (if (nord-display-truecolor-or-graphic-p) "#5E81AC" "brightblue"))
128+
(nord-punctuation (if (nord-display-truecolor-or-graphic-p) "#D8DEE9" "#D8DEE9"))
129+
(nord-regexp (if (nord-display-truecolor-or-graphic-p) "#EBCB8B" "yellow"))
130+
(nord-string (if (nord-display-truecolor-or-graphic-p) "#A3BE8C" "green"))
131+
(nord-tag (if (nord-display-truecolor-or-graphic-p) "#81A1C1" "blue"))
132+
(nord-variable (if (nord-display-truecolor-or-graphic-p) "#D8DEE9" "#D8DEE9"))
129133
(nord-region-highlight-foreground (if (or
130134
(string= nord-region-highlight "frost")
131135
(string= nord-region-highlight "snowstorm")) "#2E3440" nil))

0 commit comments

Comments
 (0)