summaryrefslogtreecommitdiffhomepage
path: root/themes/jao-themes.el
blob: faa1c3fe59ad9ceb9a0cabfb2822db67dad76206 (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
(require 'cl)

;;; palette
(defvar jao-themes--face-family "Inconsolata")
(defvar jao-themes--fg "black")
(defvar jao-themes--bg "white")
(defvar jao-themes--box "grey75")
(defvar jao-themes--hilite nil)
(defvar jao-themes--italic '(it))
(defvar jao-themes--button '(ul))
(defvar jao-themes--strike-through '(:strike-through t))
(defvar jao-themes--outline '((c "darkslategrey")))
(defvar jao-themes--outline-1 '((p outline)))
(defvar jao-themes--outline-2 '((p outline-1)))
(defvar jao-themes--outline-3 '((p outline-2)))
(defvar jao-themes--outline-4 '((p outline-3)))
(defvar jao-themes--outline-5 '((p outline-4)))
(defvar jao-themes--outline-6 '((p outline-5)))
(defvar jao-themes--outline-7 '((p outline-6)))
(defvar jao-themes--outline-8 '((p outline-7)))
(defvar jao-themes--link '((c "darkgoldenrod4")))
(defvar jao-themes--visited-link '((c "darkolivegreen4") nul))
(defvar jao-themes--gnus-mail '(dfg))
(defvar jao-themes--gnus-news '(dfg))
(defvar jao-themes--tab-sel '((c nil "grey90") bx))
(defvar jao-themes--tab-unsel '((c "grey30" "grey85") nbf bx))
(defvar jao-themes--comment '((c "grey30")))
(defvar jao-themes--warning '((c "indianred3") nbf))
(defvar jao-themes--error '((c "indianred3") bf))
(defvar jao-themes--constant '((c "darkolivegreen") nbf))
(defvar jao-themes--function '((c "darkolivegreen") nbf))
(defvar jao-themes--keyword '((c "darkslategrey") nbf))
(defvar jao-themes--string '((c "skyblue4")))
(defvar jao-themes--type '((c "darkslategrey")))
(defvar jao-themes--variable-name '((c "DodgerBlue4")))
(defvar jao-themes--dimm '((c "grey30") nbf))
(defvar jao-themes--f00 '((c "dodgerblue4")))
(defvar jao-themes--f01 '((c "cadetblue4")))
(defvar jao-themes--f02 '((c "darkslategrey")))
(defvar jao-themes--f10 '((c "dodgerblue4")))
(defvar jao-themes--f11 '((c "cadetblue4")))
(defvar jao-themes--f12 '((c "darkslategrey")))

(defsubst jao-themes--palette-face (face)
  (intern (format "jao-themes--%s" face)))

(defun jao-themes--normalize-body (body)
  (dolist (p '(:inverse-video :underline :inherit) body)
    (unless (member p body)
      (setq body (append body (list p nil))))))

(defun jao-themes--parse-face-body (f)
  (cond ((null f) nil)
        ((listp f)
         (jao-themes--normalize-body
          (apply 'append (mapcar 'jao-themes--parse-face-sym f))))))

(defvar jao-themes--default-cidxs
  '("#000000" "#cd0000" "#00cd00" "#cdcd00"
    "#0000cd" "#cd00cd" "#00cdcd" "#e5e5e5"
    "#4d4d4d" "#ff0000" "#00ff00" "#ffff00"
    "#0000ff" "#ff00ff" "#00ffff" "#ffffff"
    "#000000" "#00002a" "#000055" "#000080"
    "#0000aa" "#0000d4" "#002a00" "#002a2a"
    "#002a55" "#002a80" "#002aaa" "#002ad4"
    "#005500" "#00552a" "#005555" "#005580"
    "#0055aa" "#0055d4" "#008000" "#00802a"
    "#008055" "#008080" "#0080aa" "#0080d4"
    "#00aa00" "#00aa2a" "#00aa55" "#00aa80"
    "#00aaaa" "#00aad4" "#00d400" "#00d42a"
    "#00d455" "#00d480" "#00d4aa" "#00d4d4"
    "#2a0000" "#2a002a" "#2a0055" "#2a0080"
    "#2a00aa" "#2a00d4" "#2a2a00" "#2a2a2a"
    "#2a2a55" "#2a2a80" "#2a2aaa" "#2a2ad4"
    "#2a5500" "#2a552a" "#2a5555" "#2a5580"
    "#2a55aa" "#2a55d4" "#2a8000" "#2a802a"
    "#2a8055" "#2a8080" "#2a80aa" "#2a80d4"
    "#2aaa00" "#2aaa2a" "#2aaa55" "#2aaa80"
    "#2aaaaa" "#2aaad4" "#2ad400" "#2ad42a"
    "#2ad455" "#2ad480" "#2ad4aa" "#2ad4d4"
    "#550000" "#55002a" "#550055" "#550080"
    "#5500aa" "#5500d4" "#552a00" "#552a2a"
    "#552a55" "#552a80" "#552aaa" "#552ad4"
    "#555500" "#55552a" "#555555" "#555580"
    "#5555aa" "#5555d4" "#558000" "#55802a"
    "#558055" "#558080" "#5580aa" "#5580d4"
    "#55aa00" "#55aa2a" "#55aa55" "#55aa80"
    "#55aaaa" "#55aad4" "#55d400" "#55d42a"
    "#55d455" "#55d480" "#55d4aa" "#55d4d4"
    "#800000" "#80002a" "#800055" "#800080"
    "#8000aa" "#8000d4" "#802a00" "#802a2a"
    "#802a55" "#802a80" "#802aaa" "#802ad4"
    "#805500" "#80552a" "#805555" "#805580"
    "#8055aa" "#8055d4" "#808000" "#80802a"
    "#808055" "#808080" "#8080aa" "#8080d4"
    "#80aa00" "#80aa2a" "#80aa55" "#80aa80"
    "#80aaaa" "#80aad4" "#80d400" "#80d42a"
    "#80d455" "#80d480" "#80d4aa" "#80d4d4"
    "#aa0000" "#aa002a" "#aa0055" "#aa0080"
    "#aa00aa" "#aa00d4" "#aa2a00" "#aa2a2a"
    "#aa2a55" "#aa2a80" "#aa2aaa" "#aa2ad4"
    "#aa5500" "#aa552a" "#aa5555" "#aa5580"
    "#aa55aa" "#aa55d4" "#aa8000" "#aa802a"
    "#aa8055" "#aa8080" "#aa80aa" "#aa80d4"
    "#aaaa00" "#aaaa2a" "#aaaa55" "#aaaa80"
    "#aaaaaa" "#aaaad4" "#aad400" "#aad42a"
    "#aad455" "#aad480" "#aad4aa" "#aad4d4"
    "#d40000" "#d4002a" "#d40055" "#d40080"
    "#d400aa" "#d400d4" "#d42a00" "#d42a2a"
    "#d42a55" "#d42a80" "#d42aaa" "#d42ad4"
    "#d45500" "#d4552a" "#d45555" "#d45580"
    "#d455aa" "#d455d4" "#d48000" "#d4802a"
    "#d48055" "#d48080" "#d480aa" "#d480d4"
    "#d4aa00" "#d4aa2a" "#d4aa55" "#d4aa80"
    "#d4aaaa" "#d4aad4" "#d4d400" "#d4d42a"
    "#d4d455" "#d4d480" "#d4d4aa" "#d4d4d4"
    "#080808" "#121212" "#1c1c1c" "#262626"
    "#303030" "#3a3a3a" "#444444" "#4e4e4e"
    "#585858" "#626262" "#6c6c6c" "#767676"
    "#808080" "#8a8a8a" "#949494" "#9e9e9e"
    "#a8a8a8" "#b2b2b2" "#bcbcbc" "#c6c6c6"
    "#d0d0d0" "#dadada" "#e4e4e4" "#eeeeee"))

(defvar jao-themes--cidxs nil)
(defvar jao-themes--x-colors nil)

(defvar *jao-themes--color-names* nil)

(defun jao-themes--color (clr)
  (cond ((stringp clr) clr)
        ((numberp clr) (or (nth clr jao-themes--cidxs)
                           (nth clr jao-themes--default-cidxs)
                           (format "color-%s" clr)))
        ((symbolp clr) (or (cadr (assoc clr *jao-themes--color-names*))
                           'unspecified))
        (t 'unspecified)))

(defun jao-themes--parse-face-sym (s)
  (cond ((listp s)
         (case (car s)
           (c `(:foreground ,(jao-themes--color (cadr s))
                :background ,(jao-themes--color (caddr s))))
           (p (let ((var (jao-themes--palette-face (cadr s))))
                (when (boundp var)
                  (let ((val (symbol-value var)))
                    (if (listp val)
                        (jao-themes--parse-face-body val)
                      val)))))
           (~ (cdr (assq (cadr s) *jao--parsed-faces*)))
           (t (list s))))
        ((atom s)
         (case s
           (~ '(:inherit))
           (dbg `(:background ,jao-themes--bg))
           (dfg `(:foreground ,jao-themes--fg))
           (link (jao-themes--parse-face-body jao-themes--link))
           (vlink (jao-themes--parse-face-body jao-themes--visited-link))
           (bf '(:bold t :weight bold))
           (nbf '(:bold t :weight normal))
           (it '(:italic t :slant italic))
           (nit '(:italic nil :slant normal))
           (iv '(:inverse-video t))
           (niv '(:inverse-video nil))
           (ul '(:underline t))
           (nul '(:underline nil))
           (st '(:strike-through t))
           (ex '(:extend t))
           (nex '(:extend nil))
           (bx `(:box (:line-width -1 :color ,jao-themes--box)))
           (t (list s))))))

(defun jao-themes--make-faces (fs &optional cidxs)
  (let ((*jao--parsed-faces* nil)
        (jao-themes--cidxs (or cidxs jao-themes--default-cidxs))
        (result nil))
    (dolist (f (sort (jao-themes--dfs fs) 'jao--cmp-faces) (reverse result))
      (let ((body (jao-themes--parse-face-body (cdr f))))
        (push (cons (car f) body) *jao--parsed-faces*)
        (push (list (car f) body) result)))))

(defun jao-themes-parse-face (f)
  `(,(car f) ((t ,(jao-themes--parse-face-body (cdr f))))))

(defun jao-themes-parse-faces (fs)
  (let ((*jao--parsed-faces* nil))
    (mapcar (lambda (f)
              (let ((fp (jao-themes--parse-face-body (cdr f))))
                (push (cons (car f) fp) *jao--parsed-faces*)
                `(,(car f) ((t ,fp)))))
            fs)))


(defun jao--cmp-faces (a b)
  (let ((ai (cadr (assq '~ a)))
        (bi (cadr (assq '~ b))))
    (cond ((and ai (not bi)) nil)
          ((and bi (not ai)) t)
          ((eq (car a) bi) t)
          ((eq (car b) ai) nil)
          (t (string< (symbol-name (car a))
                      (symbol-name (car b)))))))

(defun jao-themes--dfs (fs)
  (let ((dfs
         (append
          `((aw-background-face (p dimm))
            (aw-leading-char-face (~ error) :height 1.5))
          `((bbdb-company)
            (bbdb-field-name bf)
            (bbdb-field-value nil)
            (bbdb-name ul)
            (bmk-mgr-bookmark-face nil)
            (bmk-mgr-folder-face bf)
            (bmk-mgr-sel-bookmark-face link)
            (bmk-mgr-sel-folder-face bf)
            (bold bf)
            (bold-italic bf)
            (border (c nil nil))
            (buffer-menu-buffer bf)
            (button (p button)))
          `((calendar-holiday-marker (p f00))
            (circe-highlight-nick-face (p warning))
            (circe-originator-face (p f00))
            (circe-my-message-face (p f10))
            (circe-server-face (p dimm))
            (clojure-test-failure-face (p warning) ul)
            (clojure-test-error-face (p error) ul)
            (cursor (p error)))
          `((diredp-compressed-file-suffix (~ diredp-file-suffix))
            (diredp-date-time (p f01))
            (diredp-deletion (p error))
            (diredp-deletion-file-name (~ diredp-deletion))
            (diredp-dir-heading bf dfg dbg)
            (diredp-dir-name (p f10))
            (diredp-dir-priv dfg dbg bf)
            (diredp-display-msg (p f00))
            (diredp-exec-priv dfg dbg bf)
            (diredp-executable-tag (p error))
            (diredp-file-name dfg dbg)
            (diredp-file-suffix (~ diredp-file-name))
            (diredp-flag-mark (p f00) bf)
            (diredp-flag-mark-line (p hilite))
            (diredp-ignored-file-name (p dimm))
            (diredp-link-priv (~ diredp-symlink))
            (diredp-no-priv (~ diredp-read-priv))
            (diredp-other-priv dfg dbg)
            (diredp-rare-priv dfg dfg)
            (diredp-read-priv dfg dbg bf)
            (diredp-symlink (p warning))
            (diredp-write-priv dfg dbg bf))
          `((change-log-acknowledgement (p f02))
            (change-log-conditionals (p f02))
            (change-log-date (p f01))
            (change-log-email (p f00))
            (change-log-file (p f10))
            (change-log-function (p function))
            (change-log-list (p f11))
            (change-log-name (p keyword))
            (cider-stacktrace-face (~ highlight) ex)
            (cider-test-error-face (p warning) ex)
            (cider-test-failure-face  (p error))
            (cider-test-success-face (p f01))
            (comint-highlight-input (p f01) nbf)
            (comint-highlight-prompt (p f00))
            (clojure-keyword-face (p keyword))
            (company-echo-common (p warning))
            (company-scrollbar-bg (p hilite))
            (company-scrollbar-fg (p warning))
            (company-tooltip (~ highlight))
            (company-tooltip-annotation (~ company-tooltip) it)
            (company-tooltip-annotation-selection (~ company-tooltip) it ul)
            (company-tooltip-selection (~ company-tooltip) ul)
            (company-tooltip-common (~ company-tooltip) bf)
            (company-tooltip-common-selection
             (~ company-tooltip-selection) bf)
            (company-preview (~ highlight))
            (company-preview-common (~ company-preview) bf)
            (compilation-column-number (p f00) nul)
            (compilation-error nbf (p error) nul)
            (compilation-info nbf (p f02) nul)
            (compilation-line-number (p f01) nul)
            (compilation-mode-line-fail (p error))
            (compilation-mode-line-exit (p f01) nbf)
            (compilation-mode-line-run (p warning))
            (compilation-warning nbf (p warning) nul)
            (completions-common-part nbf :width normal)
            (completions-first-difference bf dfg dbg)
            (cursor dfg dbg)
            (custom-button (~ button))
            (custom-button-mouse (~ button))
            (custom-button-pressed (~ button))
            (custom-button-pressed-unraised (~ button))
            (custom-button-unraised (~ button))
            (custom-changed (p warning))
            (custom-comment (p string))
            (custom-comment-tag (p keyword))
            (custom-documentation (p string))
            (custom-face-tag nbf)
            (custom-group-tag bf (p f00) :height 11)
            (custom-group-tag-1 bf :family ,jao-themes--face-family
                                (p f00) :height 11)
            (custom-invalid (p error))
            (custom-link link)
            (custom-modified (p f10))
            (custom-rogue (p error))
            (custom-saved ul)
            (custom-set (p f11))
            (custom-state (p f12))
            (custom-themed (p f00))
            (custom-variable-button (~ button))
            (custom-variable-tag (p variable-name) bf)
            (cvs-handled (p dimm)))
          `((darcsum-change-line-face (p warning))
            (darcsum-filename-face (p f00))
            (darcsum-header-face (p f01))
            (darcsum-marked-face (p f00) bf)
            (darcsum-need-action-face (p warning))
            (darcsum-need-action-marked-face bf (p warning))
            (diary (p f02))
            (dictionary-button-face (p link))
            (dictionary-reference-face (p f11))
            (dictionary-word-definition-face nil)
            (dictionary-word-entry-face (p f10))
            (diff-added (p warning) ex)
            (diff-changed (p f02) nul)
            (diff-context (p dimm))
            (diff-file-header dfg dbg nbf)
            (diff-function (p function))
            (diff-header nbf dfg dbg)
            (diff-hl-change (p dimm))
            (diff-hl-insert (p dimm))
            (diff-hl-delete (p warn))
            (diff-hunk-header (~ diff-file-header))
            (diff-index bf dfg dbg)
            (diff-indicator-added (~ diff-added))
            (diff-indicator-changed (~ diff-changed))
            (diff-indicator-removed (~ diff-removed))
            (diff-nonexistent bf (p error))
            (diff-refine-added (~ diff-added))
            (diff-refine-change (~ diff-changed))
            (diff-refine-removed (~ diff-removed))
            (diff-removed (p error) ex)
            (dired-directory (p f02))
            (dired-flagged bf)
            (dired-header (p f01))
            (dired-ignored (p dimm))
            (dired-mark (p f00) bf)
            (dired-marked bf (p f00))
            (dired-symlink (p f11))
            (dired-warn-writable (p warning))
            (dired-warning (p warning))
            (diredp-number (p f11)))
          `((ediff-current-diff-A (~ diff-added) ex)
            (ediff-current-diff-Ancestor (c nil ,jao-themes--box))
            (ediff-current-diff-B (~ ediff-current-diff-A) ex)
            (ediff-current-diff-C (~ ediff-current-diff-A) ex)
            (ediff-even-diff-A (~ diff-added) bf ex)
            (ediff-even-diff-Ancestor (c nil ,jao-themes--box) ex)
            (ediff-even-diff-B (~ ediff-even-diff-A))
            (ediff-even-diff-C (~ ediff-even-diff-A))
            (ediff-fine-diff-A (~ ediff-current-diff-A) nbf ul)
            (ediff-fine-diff-Ancestor (c nil ,jao-themes--box) ex)
            (ediff-fine-diff-B (~ ediff-fine-diff-A))
            (ediff-fine-diff-C (~ ediff-fine-diff-A))
            (ediff-odd-diff-A (~ ediff-even-diff-A))
            (ediff-odd-diff-Ancestor (~ ediff-odd-diff-A) nbf)
            (ediff-odd-diff-B (~ ediff-odd-diff-A))
            (ediff-odd-diff-C (~ ediff-odd-diff-A))
            (emms-browser-album-face (p f00) :height 1.0)
            (emms-browser-artist-face (p f01) :height 1.0)
            (emms-browser-composer-face (p f02) :height 1.0)
            (emms-browser-track-face (p f10) :height 1.0)
            (emms-browser-year/genre-face (p f11) :height 1.0)
            (emms-metaplaylist-mode-current-face (p f00) bf)
            (emms-metaplaylist-mode-face (p f00))
            (emms-playlist-selected-face (p f00) bf)
            (emms-playlist-track-face (p f00) nbf)
            (emms-stream-name-face (p f00))
            (emms-stream-url-face link)
            (enwc-connected (p warning))
            (epa-field-body)
            (epa-field-name bf)
            (epa-mark bf (p f00))
            (epa-string (p f01))
            (epa-validity-disabled)
            (epa-validity-high bf)
            (epa-validity-low)
            (epa-validity-medium)
            (erc-action-face (p f02))
            (erc-button (p link))
            (erc-current-nick-face (p error))
            (erc-direct-msg-face (p warning))
            (erc-error-face (p error))
            (erc-header-line (~ header))
            (erc-input-face (p f01))
            (erc-my-nick-face (p warning))
            (erc-nick-default-face (p f00))
            (erc-nick-msg-face (p warning))
            (erc-notice-face (p dimm))
            (erc-pal-face (p warning))
            (erc-prompt-face (f 01))
            (erc-timestamp-face (p dimm))
            (error (p error))
            (escape-glyph (p dimm))
            (eshell-ls-archive (p f12))
            (eshell-ls-backup (p dimm))
            (eshell-ls-clutter (p dimm))
            (eshell-ls-directory (p f02))
            (eshell-ls-executable (p warning))
            (eshell-ls-missing (p dimm))
            (eshell-ls-product (p f01))
            (eshell-ls-readonly (p f01) bf)
            (eshell-ls-special bf (p f10))
            (eshell-ls-symlink bf (p f11))
            (eshell-ls-unreadable (p dimm))
            (eshell-prompt (p f00)))
          `((factor-font-lock-comment (~ font-lock-comment-face))
            (factor-font-lock-constructor (~ font-lock-function-name-face))
            (factor-font-lock-declaration (~ font-lock-type-face))
            (factor-font-lock-getter-word (~ font-lock-function-name-face))
            (factor-font-lock-parsing-word (~ font-lock-keyword-face))
            (factor-font-lock-setter-word (~ font-lock-function-name-face))
            (factor-font-lock-stack-effect (~ font-lock-comment-face))
            (factor-font-lock-string (~ font-lock-string-face))
            (factor-font-lock-symbol (~ font-lock-keyword-face))
            (factor-font-lock-symbol-definition (~ font-lock-builtin-face))
            (factor-font-lock-type-definition (~ font-lock-type-face))
            (factor-font-lock-type-name (~ font-lock-type-face))
            (factor-font-lock-vocabulary-name (~ font-lock-constant-face))
            (factor-font-lock-word (~ font-lock-function-name-face))
            (ffap)
            (file-name-shadow (p dimm))
            (fill-column-indicator (p dimm))
            (fixed-pitch :family ,jao-themes--face-family)
            (flyspell-duplicate nbf (p warning))
            (flyspell-incorrect nbf (p error))
            (font-latex-sectioning-1-face (~ outline-1))
            (font-latex-sectioning-2-face (~ outline-2))
            (font-latex-sectioning-3-face (~ outline-3))
            (font-latex-sectioning-4-face (~ outline-4))
            (font-latex-sectioning-5-face (~ outline-5))
            (font-latex-slide-title-face (p f11))
            (font-latex-warning-face (p warning))
            (font-lock-builtin-face (p keyword))
            (font-lock-comment-delimiter-face (p comment))
            (font-lock-comment-face (p comment))
            (font-lock-constant-face (p constant))
            (font-lock-doc-face (p comment))
            (font-lock-function-name-face (p function))
            (font-lock-keyword-face (p keyword))
            (font-lock-negation-char-face nil)
            (font-lock-preprocessor-face (p constant))
            (font-lock-regexp-grouping-backslash bf)
            (font-lock-regexp-grouping-construct bf)
            (font-lock-string-face (p string))
            (font-lock-type-face (p type))
            (font-lock-variable-name-face (p variable-name))
            (font-lock-warning-face (p warning))
            (fringe (p dimm))
            (fuel-font-lock-debug-error (p error) nul)
            (fuel-font-lock-debug-info (p f01) nul)
            (fuel-font-lock-stack-region (p hilite))
            (fuel-font-lock-xref-link link nul)
            (fuel-font-lock-xref-vocab italic nul)
            (fuel-font-lock-markup-link link)
            (fuel-font-lock-markup-title (~ outline-1))
            (fuel-font-lock-markup-emphasis (~ italic))
            (fuel-font-lock-markup-heading (~ outline-1))
            (fuel-font-lock-markup-strong (~ bold)))
          `((geiser-font-lock-autodoc-current-arg (~ highlight))
            (geiser-font-lock-autodoc-identifier
             (~ font-lock-function-name-face))
            (geiser-font-lock-doc-button (~ button))
            (geiser-font-lock-doc-link link)
            (geiser-font-lock-doc-title bf)
            (geiser-font-lock-xref-header bf)
            (geiser-font-lock-xref-link link nul)
            (git-commit-summary-face (p f10))
            (git-gutter-fr:added (~ fringe) nbf)
            (git-gutter-fr:deleted (~ fringe) nbf)
            (git-gutter-fr:modified (~ fringe) nbf)
            (gnus-button (~ button))
            (gnus-cite-attribution nil)
            (gnus-cite-1 (p f10))
            (gnus-cite-2 (p f11))
            (gnus-cite-3 (p f12))
            (gnus-cite-4 (p dimm))
            (gnus-cite-5 (p dimm))
            (gnus-cite-6 (p dimm))
            (gnus-cite-7 (p dimm))
            (gnus-cite-8 (p dimm))
            (gnus-cite-9 (p dimm))
            (gnus-cite-10 (p dimm))
            (gnus-cite-11 (p dimm))
            (gnus-emphasis-bold bf)
            (gnus-emphasis-bold-italic bf)
            (gnus-emphasis-highlight-words (p hilite))
            (gnus-emphasis-italic nil)
            (gnus-emphasis-strikethru st)
            (gnus-emphasis-underline ul)
            (gnus-emphasis-underline-bold bf ul)
            (gnus-emphasis-underline-bold-italic bf ul)
            (gnus-emphasis-underline-italic ul)
            (gnus-group-mail-1 (p gnus-mail) bf)
            (gnus-group-mail-1-empty (p gnus-mail) nbf)
            (gnus-group-mail-2 (~ gnus-group-mail-1))
            (gnus-group-mail-2-empty (~ gnus-group-mail-1-empty))
            (gnus-group-mail-3 (~ gnus-group-mail-1))
            (gnus-group-mail-3-empty (~ gnus-group-mail-1-empty))
            (gnus-group-mail-4 (~ gnus-group-mail-1))
            (gnus-group-mail-4-empty (~ gnus-group-mail-1-empty))
            (gnus-group-mail-5 (p f00) bf)
            (gnus-group-mail-5-empty (p f00))
            (gnus-group-mail-6 (p dimm) bf)
            (gnus-group-mail-6-empty (p dimm))
            (gnus-group-mail-low bf (p dimm))
            (gnus-group-mail-low-empty (p dimm))
            (gnus-group-news-low bf (p dimm))
            (gnus-group-news-low-empty (p dimm))
            (gnus-group-news-1 (p gnus-news) bf)
            (gnus-group-news-1-empty (p gnus-news) nbf)
            (gnus-group-news-2 (~ gnus-group-news-1))
            (gnus-group-news-2-empty (~ gnus-group-news-1-empty))
            (gnus-group-news-3 (~ gnus-group-news-1))
            (gnus-group-news-3-empty (~ gnus-group-news-1-empty))
            (gnus-group-news-4 (~ gnus-group-news-1))
            (gnus-group-news-4-empty (~ gnus-group-news-1-empty))
            (gnus-group-news-5 (p f00) bf)
            (gnus-group-news-5-empty (p f00))
            (gnus-group-news-6 (p dimm) bf)
            (gnus-group-news-6-empty (p dimm))
            (gnus-header-content (p f02))
            (gnus-header-from (p f01))
            (gnus-header-name nbf (p f02))
            (gnus-header-newsgroups (p dimm))
            (gnus-header-subject (p f00) nbf)
            (gnus-mouse-face nil)
            (gnus-server-agent nbf)
            (gnus-server-closed (p warning))
            (gnus-server-denied bf (p error))
            (gnus-server-offline (p dimm))
            (gnus-server-opened bf)
            (gnus-signature nit (p f10))
            (gnus-splash dfg dbg)
            (gnus-summary-high-undownloaded bf nit dfg dbg)
            (gnus-summary-cancelled (p strike-through))
            (gnus-summary-high-unread bf nit)
            (gnus-summary-normal-ancient (p dimm))
            (gnus-summary-normal-read (p dimm))
            (gnus-summary-high-ticked bf nit dfg dbg)
            (gnus-summary-low-ancient (p dimm))
            (gnus-summary-low-read (p dimm) st)
            (gnus-summary-low-ticked (p dimm))
            (gnus-summary-low-unread (p dimm))
            (gnus-summary-low-undownloaded (p dimm))
            (gnus-summary-normal-ancient (p dimm))
            (gnus-summary-normal-read (p dimm))
            (gnus-summary-normal-ticked (p f10) nbf)
            (gnus-summary-normal-undownloaded bf dfg dbg)
            (gnus-summary-normal-unread dfg dbg)
            (gnus-summary-selected (p hilite))
            (gnus-x-face)
            (google-translate-listen-button-face (~ button))
            (google-translate-phonetic-face (~ default))
            (google-translate-suggestion-face (p f00))
            (google-translate-suggestion-label-face (p f01))
            (google-translate-text-face (~ default))
            (google-translate-translation-face bf)
            (gui-button-face (~ button))
            (gui-element (~ gui-button-face)))
          `((header-line (~ mode-line-inactive))
            (help-argument-name)
            (helm-selection (p hilite))
            (helm-separator (p dimm))
            (helm-source-header (~ outline-1))
            (helm-ls-git-added-copied-face dfg dbg)
            (helm-ls-git-conflict-face (p error))
            (helm-ls-git-deleted-and-staged-face (p dimm))
            (helm-ls-git-deleted-not-staged-face dfg dbg)
            (helm-ls-git-modified-and-staged-face (p f10))
            (helm-ls-git-modified-not-staged-face (p warning))
            (helm-ls-git-renamed-modified-face (p warning))
            (helm-ls-git-untracked-face (p error))
            (highlight (p hilite)))
          `((ido-first-match (p warning))
            (ido-first-match-face (p warning))
            (ido-incomplete-regexp (p error))
            (ido-indicator (p error) nbf)
            (ido-only-match (p error))
            (ido-subdir (p f01))
            (info-header-node bf dfg)
            (info-header-xref dfg)
            (info-menu-header bf)
            (info-menu-star bf dfg)
            (info-node (p f00))
            (info-title-1 (~ outline-1) bf)
            (info-title-2 (~ outline-2) bf)
            (info-title-3 (~ outline-3) bf)
            (info-title-4 (~ outline-4) bf)
            (Info-quoted (p f01))
            (info-xref link)
            (info-xref-visited vlink)
            (isearch bf (p hilite))
            (isearch-fail (p error))
            (italic (p italic))
            (ivy-confirm (p f01))
            (ivy-current-match (p hilite) ex)
            (ivy-highlight-face (p hilite))
            (ivy-match-required-face (p warning))
            (ivy-minibuffer-match-highlight (c nil nil) ul)
            (ivy-minibuffer-match-face-1 (p error))
            (ivy-minibuffer-match-face-2 (p error))
            (ivy-minibuffer-match-face-3 (p error))
            (ivy-minibuffer-match-face-4 (p error))
            (ivy-modified-buffer it)
            (ivy-subdir (p f12)))
          `((jabber-activity-face dbg dfg nbf)
            (jabber-activity-personal-face (p warning) nbf)
            (jabber-chat-error (p error))
            (jabber-chat-prompt-foreign (p f00) nbf)
            (jabber-chat-prompt-local (p f01) nbf)
            (jabber-chat-prompt-system (p f02) nbf)
            (jabber-rare-time-face (p dimm))
            (jabber-roster-user-away (p dimm))
            (jabber-roster-user-dnd (p dimm))
            (jabber-roster-user-chatty (p warning) nbf)
            (jabber-roster-user-offline (p dimm))
            (jabber-roster-user-online (p f01) nbf)
            (jabber-roster-user-xa (p dimm))
            (jabber-title-large (~ default) bf)
            (jabber-title-medium bf)
            (jabber-title-roster bf (p warning))
            (jao-emms-font-lock-album (p f01))
            (jao-emms-font-lock-artist (p f02))
            (jao-emms-font-lock-title (p f01))
            (jao-emms-font-lock-track dfg dbg)
            (jao-frm-from-face (p f00))
            (jao-frm-mailbox-face bf)
            (jao-frm-subject-face (p f01))
            (jao-frm-mailno-face bf)
            (jao-gnus-face-tree (p dimm))
            (jde-java-font-lock-constant-face (~ font-lock-constant-face))
            (jde-java-font-lock-doc-tag-face (p f02))
            (jde-java-font-lock-package-face (p f02))
            (jde-java-font-lock-link-face (p link))
            (jde-java-font-lock-number-face (~ font-lock-constant-face))
            (jde-java-font-lock-public-face (~ font-lock-keyword-face))
            (jde-java-font-lock-private-face (~ font-lock-keyword-face))
            (jde-java-font-lock-protected-face (~ font-lock-keyword-face))
            (jde-java-font-lock-modifier-face (~ font-lock-keyword-face)))
          `((lazy-highlight (p hilite))
            (line-number (p dimm))
            (line-number-current-line (p hilite))
            (link link nul)
            (link-visited vlink nul)
            (lui-button-face (p link))
            (lui-highlight-face (p warning))
            (lui-time-stamp-face (p dimm))
            (lui-track-bar (p hilite) :height 0.1))
          `((magit-branch (p f00))
            (magit-cherry-equivalent (p warning))
            (magit-diff-add (~ diff-added))
            (magit-diff-context-highlight (p hilite) ex)
            (magit-diff-del (~ diff-removed))
            (magit-diff-file-heading (p keyword))
            (magit-diff-file-header (~ diff-file-header))
            (magit-diff-hunk-header (~ diff-hunk-header))
            (magit-diff-none (p dimm))
            (magit-hash (p f12))
            (magit-item-highlight (~ mm-uu-extract) ex)
            (magit-item-mark (p warning))
            (magit-log-head-label (p keyword) bf)
            (magit-log-head-label-head (p keyword) nbf ul)
            (magit-log-head-label-default (p keyword) nbf)
            (magit-log-head-label-local (p keyword) nbf)
            (magit-log-head-label-remote (p function) bf)
            (magit-log-head-label-tags (p warning) nbf)
            (magit-log-graph (p f11))
            (magit-log-tag-label (p keyword))
            (magit-section-highlight (p hilite) ex)
            (magit-section-heading (~ outline-2))
            (magit-section-title (~ outline-2))
            (match (p hilite))
            (markdown-pre-face (~ font-lock-constant-face))
            (markdown-code-face (p keyword))
            (markdown-inline-code-face (p function))
            (markdown-italic-face (~ italic))
            (menu nil)
            (message-cited-text (p f01) nbf)
            (message-header-cc (p f00) nbf)
            (message-header-name (p f01) nbf)
            (message-header-newsgroups (p dimm) nbf)
            (message-header-other (p f00) nbf)
            (message-header-subject (p f00) nbf)
            (message-header-to (p f00) nbf)
            (message-header-xheader (p f00) nbf)
            (message-mml (p warning) nbf)
            (message-separator (p warning) nbf)
            (mm-uu-extract (p hilite) ex)
            (minibuffer-prompt (p f00))
            (mode-line-buffer-id nbf (c nil nil))
            (mode-line-emphasis (p warning))
            (mode-line-highlight (~ mode-line))
            ;; (modeline-mousable (~ mode-line-active))
            ;; (modeline-mousable-minor-mode (~ modeline-mousable))
            (moinmoin-table-pi (p f02))
            (mouse dfg dbg ul)
            (mpdel-playlist-current-song-face (p hilite) ex)
            (mpdel-tablist-song-name-face (p f00))
            (mpdel-tablist-track-face (~ default))
            (mpdel-tablist-album-face (p f01))
            (mpdel-tablist-disk-face (~ default))
            (mpdel-tablist-date-face (~ default))
            (mpdel-tablist-artist-face (p f01))
            (muse-bad-link (p warning))
            (muse-header-1 (~ outline-1))
            (muse-header-2 (~ outline-2))
            (muse-header-3 (~ outline-3))
            (muse-header-4 (~ outline-4))
            (muse-header-5 (~ outline-5))
            (muse-link link)
            (muse-verbatim (p f02)))
          `((next-error (p hilite))
            (nobreak-space dbg dfg ul)
            (nrepl-error-face (p error))
            (nrepl-input-face (p f01))
            (nrepl-output-face (p f02))
            (nrepl-prompt-face (p f00))
            (nrepl-result-face nil))
          `((org-agenda-date-today (p hilite) nul)
            (org-agenda-date-weekend (p dimm))
            (org-agenda-done (p dimm))
            (org-agenda-restriction-lock (~ default))
            (org-agenda-structure (p f00))
            (org-archived (p dimm))
            (org-code (p f02))
            (org-column dfg dbg :height 1.0)
            (org-date (p f02) nul)
            (org-done (p dimm) nbf niv)
            (org-drawer (p f02))
            (org-ellipsis (p dimm))
            (org-formula (p f02))
            (org-headline-done (p dimm))
            (org-hide (c ,jao-themes--bg))
            (org-latex-and-export-specials (~ default))
            (org-level-1 (~ outline-1))
            (org-level-2 (~ outline-2))
            (org-level-3 (~ outline-3))
            (org-level-4 (~ outline-4))
            (org-level-5 (~ outline-5))
            (org-level-6 (~ outline-6))
            (org-level-7 (~ outline-7))
            (org-level-8 (~ outline-8))
            (org-link link)
            (org-noter-notes-exist-face it)
            (org-property-value nil)
            (org-scheduled (p f01))
            (org-scheduled-previously (p f00) nbf)
            (org-scheduled-today (p f01))
            (org-sexp-date (p f01))
            (org-special-keyword (p keyword))
            (org-table (p f01))
            (org-tag (p dimm) nbf)
            (org-target ul)
            (org-time-grid dfg dbg)
            (org-todo nbf niv (p error))
            (org-upcoming-deadline (p f02))
            (org-verbatim  (p hilite))
            (org-warning bf (p warning))
            (outline-1 bf (p outline-1))
            (outline-2 bf (p outline-2))
            (outline-3 bf (p outline-3))
            (outline-4 bf (p outline-4))
            (outline-5 nbf ul (p outline-5))
            (outline-6 nbf ul (p outline-6))
            (outline-7 nbf ul (p outline-7))
            (outline-8 nbf ul (p outline-8)))
          `((powerline-active1 (~ mode-line))
            (powerline-active2 (~ mode-line-inactive))
            (powerline-inactive1 (~ mode-line-inactive))
            (powerline-inactive2 (~ mode-line)))
          `((query-replace bf (p hilite)))
          `((rcirc-bright-nick (p hilite))
            (rcirc-my-nick (p warning))
            (rcirc-nick-in-message (p warning))
            (rcirc-nick-in-message-full-line (~ rcirc-nick-in-message))
            (rcirc-other-nick (p keyword))
            (rcirc-prompt bf)
            (rcirc-server (p dimm))
            (rcirc-timestamp (p dimm))
            (rcirc-track-keyword (p warning))
            (rcirc-track-nick (~ rcirc-my-nick) niv)
            (rcirc-url nbf link)
            (reb-match-0 (p hilite))
            (reb-match-1 (~ secondary-selection))
            (reb-match-2 (~ secondary-selection) bf)
            (reb-match-3 (~ secondary-selection) ul)
            (region (p hilite) ex)
            (rst-level-1-face (~ outline-1))
            (rst-level-2-face (~ outline-2))
            (rst-level-3-face (~ outline-3))
            (rst-level-4-face (~ outline-4))
            (rst-level-5-face (~ outline-5))
            (rst-level-6-face (~ outline-6))
            (rst-level-7-face (~ outline-7))
            (rst-level-8-face (~ outline-8)))
          `((secondary-selection (p hilite) ex)
            (sh-quoted-exec (p f00))
            (show-paren-match (p hilite))
            (show-paren-mismatch (p error))
            (signel-contact-face (p f11))
            (signel-notice-face (p dimm))
            (signel-notification-face (p warning))
            (signel-prompt-face bf)
            (signel-timestamp-face (p dimm))
            (slack-channel-button-face (~ link))
            (slack-message-action-face (~ link))
            (slack-message-mention-face (p f01))
            (slack-message-mention-keyword-face (p f01))
            (slack-message-mention-me-face (p error))
            (slack-message-output-header (p f00) it)
            (slack-message-output-text nil)
            (slack-new-message-marker-face (p warning))
            (slack-preview-face (p f11))
            (slack-search-result-message-header-face it)
            (slack-user-profile-header-face (p f01))
            (slack-user-profile-property-name-face bf)
            (sldb-frame-line-face (p f00))
            (sldb-frame-label-face (p f01))
            (sldb-condition-face (p f02))
            (slime-repl-prompt-face (p f00))
            (slime-repl-input-face (p f00) bf)
            (slime-repl-inputed-output-face (p f02))
            (slime-repl-output-face (p string))
            (sp-show-pair-enclosing nil)
            (sp-show-pair-match-face (p hilite))
            (sp-show-pair-mismatch-face (p error))
            (spaceline-highlight-face-default (p f00))
            (spaceline-highlight-face-modified (p f01))
            (spaceline-highlight-face (p f02))
            (spaceline-modified (p f10) iv)
            (spaceline-unmodified (p f11) iv)
            (spaceline-read-only (p f12) iv)
            (speedbar-directory-face (~ diredp-dir-heading))
            (speedbar-file-face (~ diredp-file-name))
            (speedbar-highlight-face (p hilite))
            (speedbar-selected-face ul)
            (speedbar-separator-face (p f00))
            (scroll-bar nil)
            (shadow nil)
            (success (p success))
            (sunshine-forecast-date-face nil)
            (sunshine-forecast-day-divider-face (p dimm))
            (sunshine-forecast-headline-face (~ header-line)))
          `((term nil)
            (tool-bar nil)
            (tooltip :family ,jao-themes--face-family (c nil "lightyellow"))
            (trailing-whitespace (p error))
            (treemacs-root-face nul bf :scale 1.1)
            (twittering-uri-face (~ link))
            (twittering-username-face (p f01)))
          `((underline nul))
          `((variable-pitch :family ,jao-themes--face-family :height 110)
            (vertical-border (c ,jao-themes--box nil) :inherit default))
          `((w3m-anchor link)
            (w3m-arrived-anchor vlink)
            (w3m-bold bf dbg dfg)
            (w3m-current-anchor nbf ul)
            (w3m-form dfg dbg ul)
            (w3m-form-button (~ button))
            (w3m-form-button-mouse (~ custom-button-mouse))
            (w3m-form-button-pressed (~ custom-button-pressed))
            (w3m-header-line-location-content
             :box (:line-width 3 :color ,jao-themes--bg) dfg dbg)
            (w3m-header-line-location-title
             :box (:line-width 3 :color ,jao-themes--bg) dfg dbg)
            (w3m-header-line-content
             :box (:line-width 3 :color ,jao-themes--bg) dfg dbg)
            (w3m-header-line-title
             :box (:line-width 3 :color ,jao-themes--bg) dfg dbg)
            (w3m-history-current-url (c nil nil) ul)
            (w3m-image (p f10))
            (w3m-image-anchor (c nil nil))
            (w3m-insert (p f12))
            (w3m-italic (~ italic))
            (w3m-linknum-match (p warning))
            (w3m-linknum-minibuffer-prompt (~ minibuffer-prompt))
            (w3m-session-select (p f10))
            (w3m-session-selected bf nul (p f10))
            (w3m-strike-through st)
            (w3m-tab-background nul (c nil nil))
            (w3m-tab-mouse nil)
            (w3m-tab-selected (p tab-sel))
            (w3m-tab-selected-background nil)
            (w3m-tab-selected-retrieving (p tab-sel) it)
            (w3m-tab-unselected (p tab-unsel))
            (w3m-tab-unselected-retrieving (p tab-unsel) it)
            (w3m-tab-unselected-unseen (p tab-unsel))
            (w3m-underline ul)
            (warning (p warning))
            (wg-brace-face nil)
            (wg-command-face (p f00))
            (wg-current-workgroup-face (p f11) bf)
            (wg-divider-face nil)
            (wg-filename-face nil)
            (wg-frame-face nil)
            (wg-message-face (p string))
            (wg-mode-line-face nil)
            (wg-previous-workgroup-face (p f00))
            (widget-button (~ button))
            (widget-button-pressed nbf (~ custom-button-pressed))
            (widget-button-face (~ button))
            (widget-button-pressed-face (~ button))
            (widget-documentation (p dimm))
            (widget-field (p hilite) bx)
            (widget-inactive (p dimm))
            (Widget-single-line-field (~ widget-field))
            (woman-bold (p f00) bf)
            (woman-italic (p f01) nul nit)
            (woman-italic-no-ul (p f01) nul nit)))))
    (dolist (df dfs fs)
      (when (not (assq (car df) fs))
        (push df fs)))))

(defsubst jao-themes--let-palette (palette xp)
  (mapcar (lambda (f)
            `(,(jao-themes--palette-face (car f))
              ',(or (and xp (caddr f)) (cadr f))))
          palette))

(defun jao-themes--extract-faces (t-faces x-faces)
  (let ((result))
    (dolist (f t-faces (reverse result))
      (let ((xfb (cdr (assq (car f) x-faces))))
        (push `(,(car f) ((((type x ns)) ,@xfb)
                          (t ,@(cdr f)))) result)))))

(defun jao-themes--set-fbg (kind)
  (let* ((kvs (cdr (assoc kind window-system-default-frame-alist)))
         (f-alist (assq-delete-all 'background-color kvs))
         (f-alist (assq-delete-all 'foreground-color f-alist)))
    (when jao-themes--fg
      (push (cons 'foreground-color jao-themes--fg) f-alist))
    (when jao-themes--bg
      (push (cons 'background-color jao-themes--bg) f-alist))
    (setq window-system-default-frame-alist
          (cons
           (cons kind f-alist)
           (assq-delete-all kind window-system-default-frame-alist)))))

(defmacro jao-define-custom-theme (name &rest args)
  (let* ((t-faces (make-symbol "t-faces"))
         (xfaces (make-symbol "xfaces"))
         (tx-faces (make-symbol "tx-faces"))
         (palette (cdr (assoc :palette args)))
         (faces (cdr (assoc :faces args)))
         (x-faces (cdr (assoc :x-faces args)))
         (x-colors (cdr (assoc :x-colors args)))
         (a-colors (cdr (assoc :ansi-colors args)))
         (ansi-colors (when a-colors
                        (apply 'vector (butlast a-colors
                                                (- (length a-colors) 8))))))
    `(progn
       (setq ansi-color-names-vector ,ansi-colors)
       (ansi-color-map-update 'ansi-color-names-vector ,ansi-colors)
       (custom-make-theme-feature ',name)
       (deftheme ,name)
       (let ((*jao-themes--color-names* ',(cdr (assoc :names args))))
         (let* ,(jao-themes--let-palette palette nil)
           (jao-themes--set-fbg nil)
           (let ((,t-faces (jao-themes--make-faces ',faces)))
             (let* ,(jao-themes--let-palette palette t)
               (jao-themes--set-fbg 'x)
               (let* ((,xfaces (jao-themes--make-faces ',x-faces ',x-colors))
                      (,tx-faces (jao-themes--extract-faces ,t-faces ,xfaces)))
                 (put ',name 'theme-immediate t)
                 (apply 'custom-theme-set-faces (cons ',name ,tx-faces)))))
           (provide-theme ',name))))))

(put 'jao-define-custom-theme 'lisp-indent-function 1)

(when load-file-name
  (add-to-list 'custom-theme-load-path (file-name-directory load-file-name)))



(provide 'jao-themes)