import json
""" This file reads the JSON file in root directory and converts it to emacs color theme. The theme is written on stdout and can be copied into a file and loaded in emacs without any modifications. """
background = " "
foreground = " "
colors = [ ]
with open ( " ../JSON " , ' r ' ) as f :
d = json . loads ( f . read ( ) )
background = d [ ' background ' ]
foreground = d [ ' foreground ' ]
colors = d [ ' color ' ]
print ( " ;; foreground : " + foreground )
print ( " ;; background : " + background )
i = 0
for c in colors :
print ( " ;; color " + str ( i ) + " " + c )
i + = 1
print ( """
( deftheme { theme_name }
" Add some description here " )
( let ( ( class ' ( ( class color ) ( min - colors 89 ) ) ) )
( custom - theme - set - faces
' {theme_name}
` ( default ( ( , class ( : background " {bg} " : foreground " {fg} " ) ) ) )
` ( cursor ( ( , class ( : background " {fg} " : foreground " {fg} " ) ) ) )
; ; Highlighting faces
` ( fringe ( ( , class ( : background " {bg} " ) ) ) )
` ( highlight ( ( , class ( : background " {bg} " : underline t ) ) ) )
; ; background during selection , this tends to be weird so feel free to experiment
` ( region ( ( t ( : background " {bright_black} " : foreground " {bright_white} " ) ) ) )
` ( secondary - selection ( ( , class ( : background " {bg} " ) ) ) )
` ( isearch ( ( , class ( : background " {bg} " : foreground " {blue} " : weight bold ) ) ) )
` ( isearch - fail ( ( t ( : foreground " {fg} " : background " {red} " ) ) ) )
` ( lazy - highlight ( ( , class ( : background " {bg} " : foreground " {yellow} " : weight bold ) ) ) )
; ; Mode line faces
` ( mode - line ( ( , class ( : background " {black} " : foreground " {white} " ) ) ) )
` ( mode - line - inactive ( ( , class ( : background " {bright_black} " : foreground " {bright_white} " ) ) ) )
; ; Escape and prompt faces
` ( minibuffer - prompt ( ( , class ( : foreground " {cyan} " ) ) ) )
` ( escape - glyph ( ( , class ( : foreground " {yellow} " : weight bold ) ) ) )
` ( homoglyph ( ( , class ( : foreground " {green} " : weight bold ) ) ) )
; ; Font lock faces , this is where all source file highlighing is done
` ( font - lock - builtin - face ( ( , class ( : foreground " {fg} " : weight bold ) ) ) )
` ( font - lock - comment - face ( ( , class ( : foreground " {green} " ) ) ) )
` ( font - lock - constant - face ( ( , class ( : foreground " {green} " ) ) ) )
` ( font - lock - function - name - face ( ( , class ( : foreground " {cyan} " ) ) ) )
` ( font - lock - keyword - face ( ( , class ( : foreground " {bright_red} " : weight bold ) ) ) )
` ( font - lock - string - face ( ( , class ( : foreground " {green} " ) ) ) )
` ( font - lock - type - face ( ( , class ( : foreground " {bright_yellow} " : weight bold ) ) ) )
` ( font - lock - variable - name - face ( ( , class ( : foreground " {white} " ) ) ) )
` ( font - lock - warning - face ( ( , class ( : foreground " {red} " : weight bold ) ) ) )
; ; Button and link faces
` ( link ( ( , class ( : foreground " {blue} " : underline t ) ) ) )
` ( link - visited ( ( , class ( : foreground " {bright_blue} " : underline t ) ) ) )
` ( button ( ( , class ( : background " {bright_black} " : foreground " {bright_white} " ) ) ) )
` ( header - line ( ( , class ( : background " {bg} " : foreground " {bright_yellow} " ) ) ) )
; ; Gnus faces
; ; ` ( gnus - group - news - 1 ( ( , class ( : weight bold : foreground " #95e454 " ) ) ) )
; ; ` ( gnus - group - news - 1 - low ( ( , class ( : foreground " #95e454 " ) ) ) )
; ; ` ( gnus - group - news - 2 ( ( , class ( : weight bold : foreground " #cae682 " ) ) ) )
; ; ` ( gnus - group - news - 2 - low ( ( , class ( : foreground " #cae682 " ) ) ) )
; ; ` ( gnus - group - news - 3 ( ( , class ( : weight bold : foreground " #ccaa8f " ) ) ) )
; ; ` ( gnus - group - news - 3 - low ( ( , class ( : foreground " #ccaa8f " ) ) ) )
; ; ` ( gnus - group - news - 4 ( ( , class ( : weight bold : foreground " #99968b " ) ) ) )
; ; ` ( gnus - group - news - 4 - low ( ( , class ( : foreground " #99968b " ) ) ) )
; ; ` ( gnus - group - news - 5 ( ( , class ( : weight bold : foreground " #cae682 " ) ) ) )
; ; ` ( gnus - group - news - 5 - low ( ( , class ( : foreground " #cae682 " ) ) ) )
; ; ` ( gnus - group - news - low ( ( , class ( : foreground " #99968b " ) ) ) )
; ; ` ( gnus - group - mail - 1 ( ( , class ( : weight bold : foreground " #95e454 " ) ) ) )
; ; ` ( gnus - group - mail - 1 - low ( ( , class ( : foreground " #95e454 " ) ) ) )
; ; ` ( gnus - group - mail - 2 ( ( , class ( : weight bold : foreground " #cae682 " ) ) ) )
; ; ` ( gnus - group - mail - 2 - low ( ( , class ( : foreground " #cae682 " ) ) ) )
; ; ` ( gnus - group - mail - 3 ( ( , class ( : weight bold : foreground " #ccaa8f " ) ) ) )
; ; ` ( gnus - group - mail - 3 - low ( ( , class ( : foreground " #ccaa8f " ) ) ) )
; ; ` ( gnus - group - mail - low ( ( , class ( : foreground " #99968b " ) ) ) )
; ; ` ( gnus - header - content ( ( , class ( : foreground " #8ac6f2 " ) ) ) )
; ; ` ( gnus - header - from ( ( , class ( : weight bold : foreground " #95e454 " ) ) ) )
; ; ` ( gnus - header - subject ( ( , class ( : foreground " #cae682 " ) ) ) )
; ; ` ( gnus - header - name ( ( , class ( : foreground " #8ac6f2 " ) ) ) )
; ; ` ( gnus - header - newsgroups ( ( , class ( : foreground " #cae682 " ) ) ) )
; ; set ansi - colors
` ( ansi - color - black ( ( t ( : foreground " {black} " ) ) ) )
` ( ansi - color - white ( ( t ( : foreground " {white} " ) ) ) )
` ( ansi - color - red ( ( t ( : foreground " {red} " ) ) ) )
` ( ansi - color - yellow ( ( t ( : foreground " {yellow} " ) ) ) )
` ( ansi - color - green ( ( t ( : foregrounB " {green} " ) ) ) )
` ( ansi - color - cyan ( ( t ( : foreground " {cyan} " ) ) ) )
` ( ansi - color - blue ( ( t ( : foreground " {blue} " ) ) ) )
` ( ansi - color - magenta ( ( t ( : foregrou0E " {magenta} " ) ) ) )
` ( ansi - color - bright - black ( ( t ( : foreground " {bright_black} " ) ) ) )
` ( ansi - color - bright - white ( ( t ( : foreground " {bright_white} " ) ) ) )
` ( ansi - color - bright - red ( ( t ( : foreground " {bright_red} " ) ) ) )
` ( ansi - color - bright - yellow ( ( t ( : foreground " {bright_yellow} " ) ) ) )
` ( ansi - color - bright - green ( ( t ( : foreground " {bright_green} " ) ) ) )
` ( ansi - color - bright - cyan ( ( t ( : foreground " {bright_cyan} " ) ) ) )
` ( ansi - color - bright - blue ( ( t ( : foreground " {bright_blue} " ) ) ) )
` ( ansi - color - bright - magenta ( ( t ( : foreground " {bright_magenta} " ) ) ) )
; ; Message faces
; ; ` ( message - header - name ( ( , class ( : foreground " #8ac6f2 " : weight bold ) ) ) )
; ; ` ( message - header - cc ( ( , class ( : foreground " #95e454 " ) ) ) )
; ; ` ( message - header - other ( ( , class ( : foreground " #95e454 " ) ) ) )
; ; ` ( message - header - subject ( ( , class ( : foreground " #cae682 " ) ) ) )
; ; ` ( message - header - to ( ( , class ( : foreground " #cae682 " ) ) ) )
; ; ` ( message - cited - text ( ( , class ( : foreground " #99968b " ) ) ) )
` ( message - separator ( ( , class ( : foreground " {white} " : weight bold ) ) ) ) ) )
( provide - theme ' {theme_name} )
""" .format(theme_name= " anmol-test " ,bg=background, fg=foreground, black=colors[0], red=colors[1], green=colors[2], yellow=colors[3], blue=colors[4], magenta=colors[5], cyan=colors[6], white=colors[7], bright_black=colors[8], bright_red=colors[9], bright_green=colors[10], bright_yellow=colors[11], bright_blue=colors[12], bright_magenta=colors[13], bright_cyan=colors[14], bright_white=colors[15]))