thirdparty/color-theme-solarized/solarized-definitions.el
changeset 47 3415a60d5fd0
child 48 f17ebf233431
equal deleted inserted replaced
46:2c6b198426df 47:3415a60d5fd0
       
     1 (eval-when-compile
       
     2   (require 'cl))
       
     3 
       
     4 (defconst solarized-description
       
     5   "Color theme by Ethan Schoonover, created 2011-03-24.
       
     6 Ported to Emacs by Greg Pfeil, http://ethanschoonover.com/solarized.")
       
     7 
       
     8 (defcustom solarized-degrade nil
       
     9   "For test purposes only; when in GUI mode, forces Solarized to use the 256
       
    10 degraded color mode to test the approximate color values for accuracy."
       
    11   :type 'boolean
       
    12   :group 'solarized)
       
    13 
       
    14 (defcustom solarized-bold t
       
    15   "Stops Solarized from displaying bold when nil."
       
    16   :type 'boolean
       
    17   :group 'solarized)
       
    18 
       
    19 (defcustom solarized-underline t
       
    20   "Stops Solarized from displaying underlines when nil."
       
    21   :type 'boolean
       
    22   :group 'solarized)
       
    23 
       
    24 (defcustom solarized-italic t
       
    25   "Stops Solarized from displaying italics when nil."
       
    26   :type 'boolean
       
    27   :group 'solarized)
       
    28 
       
    29 (defcustom solarized-termcolors 16
       
    30   "This setting applies to emacs in terminal (non-GUI) mode.
       
    31 If set to 16, emacs will use the terminal emulator's colorscheme (best option as
       
    32 long as you've set your emulator's colors to the Solarized palette). If set to
       
    33 256 and your terminal is capable of displaying 256 colors, emacs will use the
       
    34 256 degraded color mode."
       
    35   :type 'integer
       
    36   :options '(16 256)
       
    37   :group 'solarized)
       
    38 
       
    39 (defcustom solarized-contrast 'normal
       
    40   "Stick with normal! It's been carefully tested. Setting this option to high or
       
    41 low does use the same Solarized palette but simply shifts some values up or down
       
    42 in order to expand or compress the tonal range displayed."
       
    43   :type 'symbol
       
    44   :options '(high normal low)
       
    45   :group 'solarized)
       
    46 
       
    47 (defcustom solarized-broken-srgb (if (eq system-type 'darwin) t nil)
       
    48   "Emacs bug #8402 results in incorrect color handling on Macs. If this is t
       
    49 (the default on Macs), Solarized works around it with alternative colors.
       
    50 However, these colors are not totally portable, so you may be able to edit the
       
    51 \"Gen RGB\" column in solarized-definitions.el to improve them further."
       
    52   :type 'boolean
       
    53   :group 'solarized)
       
    54 
       
    55 ;; FIXME: The Generic RGB colors will actually vary from device to device, but
       
    56 ;;        hopefully these are closer to the intended colors than the sRGB values
       
    57 ;;        that Emacs seems to dislike
       
    58 (defvar solarized-colors
       
    59   ;; name    sRGB      Gen RGB   degraded  ANSI(Solarized terminal)
       
    60   '((base03  "#002b36" "#042028" "#1c1c1c" "#7f7f7f")
       
    61     (base02  "#073642" "#0a2832" "#262626" "#000000")
       
    62     (base01  "#586e75" "#465a61" "#4e4e4e" "#00ff00")
       
    63     (base00  "#657b83" "#52676f" "#585858" "#ffff00")
       
    64     (base0   "#839496" "#708183" "#808080" "#5c5cff")
       
    65     (base1   "#93a1a1" "#81908f" "#8a8a8a" "#00ffff")
       
    66     (base2   "#eee8d5" "#e9e2cb" "#d7d7af" "#e5e5e5")
       
    67     (base3   "#fdf6e3" "#fcf4dc" "#ffffd7" "#ffffff")
       
    68     (yellow  "#b58900" "#a57705" "#af8700" "#cdcd00")
       
    69     (orange  "#cb4b16" "#bd3612" "#d75f00" "#ff0000")
       
    70     (red     "#dc322f" "#c60007" "#af0000" "#cd0000")
       
    71     (magenta "#d33682" "#c61b6e" "#af005f" "#cd00cd")
       
    72     (violet  "#6c71c4" "#5859b7" "#5f5faf" "#ff00ff")
       
    73     (blue    "#268bd2" "#2075c7" "#0087ff" "#0000ee")
       
    74     (cyan    "#2aa198" "#259185" "#00afaf" "#00cdcd")
       
    75     (green   "#859900" "#728a05" "#5f8700" "#00cd00"))
       
    76   "This is a table of all the colors used by the Solarized color theme. Each
       
    77    column is a different set, one of which will be chosen based on term
       
    78    capabilities, etc.")
       
    79 
       
    80 (defun solarized-color-definitions (mode)
       
    81   (flet ((find-color (name)
       
    82            (let ((index (if window-system
       
    83                             (if solarized-degrade
       
    84                                 3
       
    85 			      (if solarized-broken-srgb 2 1))
       
    86 			  (if (= solarized-termcolors 256)
       
    87 			      3
       
    88 			    4))))
       
    89              (nth index (assoc name solarized-colors)))))
       
    90     (let ((base03    (find-color 'base03))
       
    91           (base02    (find-color 'base02))
       
    92           (base01    (find-color 'base01))
       
    93           (base00    (find-color 'base00))
       
    94           (base0     (find-color 'base0))
       
    95           (base1     (find-color 'base1))
       
    96           (base2     (find-color 'base2))
       
    97           (base3     (find-color 'base3))
       
    98           (yellow    (find-color 'yellow))
       
    99           (orange    (find-color 'orange))
       
   100           (red       (find-color 'red))
       
   101           (magenta   (find-color 'magenta))
       
   102           (violet    (find-color 'violet))
       
   103           (blue      (find-color 'blue))
       
   104           (cyan      (find-color 'cyan))
       
   105           (green     (find-color 'green))
       
   106           (bold      (if solarized-bold 'bold 'normal))
       
   107           (underline (if solarized-underline t nil))
       
   108           (opt-under nil)
       
   109           (italic    (if solarized-italic 'italic 'normal)))
       
   110       (when (eq 'light mode)
       
   111         (rotatef base03 base3)
       
   112         (rotatef base02 base2)
       
   113         (rotatef base01 base1)
       
   114         (rotatef base00 base0))
       
   115       (let ((back base03))
       
   116         (cond ((eq 'high solarized-contrast)
       
   117                (let ((orig-base3 base3))
       
   118                  (rotatef base01 base00 base0 base1 base2 base3)
       
   119                  (setf base3 orig-base3)))
       
   120               ((eq 'low solarized-contrast)
       
   121                (setf back      base02
       
   122                      opt-under t)))
       
   123         `((;; basic
       
   124            (default ((t (:foreground ,base0 ,:background ,back))))
       
   125            (cursor
       
   126             ((t (:foreground ,base0 :background ,base03 :inverse-video t))))
       
   127            (escape-glyph-face ((t (:foreground ,red))))
       
   128            (fringe ((t (:foreground ,base01 :background ,base02))))
       
   129            (linum ((t (:foreground ,base01 :background ,base02))))
       
   130            (header-line ((t (:foreground ,base0 :background ,base2))))
       
   131            (highlight ((t (:background ,base02))))
       
   132            (hl-line ((t (:background ,base02))))
       
   133            (isearch ((t (:foreground ,yellow :inverse-video t))))
       
   134            (lazy-highlight ((t (:background ,base2 :foreground ,base00))))
       
   135            (link ((t (:foreground ,violet :underline ,underline))))
       
   136            (link-visited ((t (:foreground ,magenta :underline ,underline))))
       
   137            (menu ((t (:foreground ,base0 :background ,base02))))
       
   138            (minibuffer-prompt ((t (:foreground ,blue))))
       
   139            (mode-line
       
   140             ((t (:foreground ,base1 :background ,base02
       
   141                              :box (:line-width 1 :color ,base1)))))
       
   142            (mode-line-buffer-id ((t (:foreground ,base1))))
       
   143            (mode-line-inactive
       
   144             ((t (:foreground ,base0  :background ,base02
       
   145                              :box (:line-width 1 :color ,base02)))))
       
   146            (region ((t (:background ,base02))))
       
   147            (secondary-selection ((t (:background ,base02))))
       
   148            (trailing-whitespace ((t (:foreground ,red :inverse-video t))))
       
   149            (vertical-border ((t (:foreground ,base0))))
       
   150            ;; comint
       
   151            (comint-highlight-prompt ((t (:foreground ,blue))))
       
   152            ;; compilation
       
   153            (compilation-info ((t (:foreground ,green :weight ,bold))))
       
   154            (compilation-warning ((t (:foreground ,orange :weight ,bold))))
       
   155            ;; customize
       
   156            (custom-button
       
   157             ((t (:background ,base02
       
   158                              :box (:line-width 2 :style released-button)))))
       
   159            (custom-button-mouse
       
   160             ((t (:inherit custom-button :foreground ,base1))))
       
   161            (custom-button-pressed
       
   162             ((t (:inherit custom-button-mouse
       
   163                           :box (:line-width 2 :style pressed-button)))))
       
   164            (custom-comment-tag ((t (:background ,base02))))
       
   165            (custom-comment-tag ((t (:background ,base02))))
       
   166            (custom-documentation ((t (:inherit default))))
       
   167            (custom-group-tag ((t (:foreground ,orange :weight ,bold))))
       
   168            (custom-link ((t (:foreground ,violet))))
       
   169            (custom-state ((t (:foreground ,green))))
       
   170            (custom-variable-tag ((t (:foreground ,orange :weight ,bold))))
       
   171            ;; diff
       
   172            (diff-added ((t (:foreground ,green :inverse-video t))))
       
   173            (diff-changed ((t (:foreground ,yellow :inverse-video t))))
       
   174            (diff-removed ((t (:foreground ,red :inverse-video t))))
       
   175            (diff-header ((t (:background ,base01))))
       
   176            (diff-file-header
       
   177             ((t (:background ,base1 :foreground ,base01 :weight ,bold))))
       
   178            (diff-refine-change ((t (:background ,base1))))
       
   179            ;; IDO
       
   180            (ido-only-match ((t (:foreground ,green))))
       
   181            (ido-subdir ((t (:foreground ,blue))))
       
   182            (ido-first-match ((t (:foreground ,green :weight ,bold))))
       
   183            ;; emacs-wiki
       
   184            (emacs-wiki-bad-link-face
       
   185             ((t (:foreground ,red :underline ,underline))))
       
   186            (emacs-wiki-link-face
       
   187             ((t (:foreground ,blue :underline ,underline))))
       
   188            (emacs-wiki-verbatim-face
       
   189             ((t (:foreground ,base00 :underline ,underline))))
       
   190            ;; eshell
       
   191            (eshell-prompt ((t (:foreground ,green :weight ,bold))))
       
   192            ;; font-lock
       
   193            (font-lock-builtin-face ((t (:foreground ,green))))
       
   194            (font-lock-comment-face ((t (:foreground ,base01 :slant ,italic))))
       
   195            (font-lock-constant-face ((t (:foreground ,cyan))))
       
   196            (font-lock-function-name-face ((t (:foreground ,blue))))
       
   197            (font-lock-keyword-face ((t (:foreground ,green))))
       
   198            (font-lock-string-face ((t (:foreground ,cyan))))
       
   199            (font-lock-type-face ((t (:foreground ,yellow))))
       
   200            (font-lock-variable-name-face ((t (:foreground ,blue))))
       
   201            (font-lock-warning-face ((t (:foreground ,red :weight ,bold))))
       
   202            (font-lock-doc-face ((t (:foreground ,cyan :slant ,italic))))
       
   203            (font-lock-color-constant-face ((t (:foreground ,green))))
       
   204            (font-lock-comment-delimiter-face
       
   205             ((t (:foreground ,base01 :weight ,bold))))
       
   206            (font-lock-doc-string-face ((t (:foreground ,green))))
       
   207            (font-lock-preprocessor-face ((t (:foreground ,orange))))
       
   208            (font-lock-reference-face ((t (:foreground ,cyan))))
       
   209            (font-lock-negation-char-face ((t (:foreground ,red))))
       
   210            (font-lock-other-type-face ((t (:foreground ,blue :slant ,italic))))
       
   211            (font-lock-regexp-grouping-construct    ((t (:foreground ,orange))))
       
   212            (font-lock-special-keyword-face ((t (:foreground ,magenta))))
       
   213            (font-lock-exit-face ((t (:foreground ,red))))
       
   214            (font-lock-other-emphasized-face
       
   215             ((t (:foreground ,violet :weight ,bold :slant ,italic))))
       
   216            (font-lock-regexp-grouping-backslash ((t (:foreground ,yellow))))
       
   217            ;; info
       
   218            (info-xref ((t (:foreground ,blue :underline ,underline))))
       
   219            (info-xref-visited ((t (:inherit info-xref :foreground ,magenta))))
       
   220            ;; org
       
   221            (org-hide ((t (:foreground ,base03))))
       
   222            (org-todo ((t (:foreground ,base03 :background ,red :weight ,bold))))
       
   223            (org-done ((t (:foreground ,green :weight ,bold))))
       
   224            (org-todo-kwd-face ((t (:foreground ,red :background ,base03))))
       
   225            (org-done-kwd-face ((t (:foreground ,green :background ,base03))))
       
   226            (org-project-kwd-face
       
   227             ((t (:foreground ,violet :background ,base03))))
       
   228            (org-waiting-kwd-face
       
   229             ((t (:foreground ,orange :background ,base03))))
       
   230            (org-someday-kwd-face ((t (:foreground ,blue :background ,base03))))
       
   231            (org-started-kwd-face
       
   232             ((t (:foreground ,yellow :background ,base03))))
       
   233            (org-cancelled-kwd-face
       
   234             ((t (:foreground ,green :background ,base03))))
       
   235            (org-delegated-kwd-face
       
   236             ((t (:foreground ,cyan :background ,base03))))
       
   237            ;; show-paren
       
   238            (show-paren-match-face ((t (:background ,cyan :foreground ,base3))))
       
   239            (show-paren-mismatch-face
       
   240             ((t (:background ,red :foreground ,base3))))
       
   241            ;; widgets
       
   242            (widget-field
       
   243             ((t (:box (:line-width 1 :color ,base00) :inherit default))))
       
   244            (widget-single-line-field ((t (:inherit widget-field))))
       
   245            ;; extra modules
       
   246            ;; -------------
       
   247            ;; gnus
       
   248            (gnus-cite-1 ((t (:foreground ,magenta))))
       
   249            (gnus-cite-2 ((t (:foreground ,base2))))
       
   250            (gnus-cite-3 ((t (:foreground ,base3))))
       
   251            (gnus-cite-4 ((t (:foreground ,base1))))
       
   252            (gnus-cite-5 ((t (:foreground ,magenta))))
       
   253            (gnus-cite-6 ((t (:foreground ,base2))))
       
   254            (gnus-cite-7 ((t (:foreground ,base3))))
       
   255            (gnus-cite-8 ((t (:foreground ,base1))))
       
   256            (gnus-cite-9 ((t (:foreground ,base2))))
       
   257            (gnus-cite-10 ((t (:foreground ,base3))))
       
   258            (gnus-cite-11 ((t (:foreground ,blue))))
       
   259            (gnus-group-mail-1 ((t (:foreground ,base3 :weight ,bold))))
       
   260            (gnus-group-mail-1-empty ((t (:foreground ,base3))))
       
   261            (gnus-group-mail-2 ((t (:foreground ,base2 :weight ,bold))))
       
   262            (gnus-group-mail-2-empty ((t (:foreground ,base2))))
       
   263            (gnus-group-mail-3 ((t (:foreground ,magenta :weight ,bold))))
       
   264            (gnus-group-mail-3-empty ((t (:foreground ,magenta))))
       
   265            (gnus-group-mail-low ((t (:foreground ,base00 :weight ,bold))))
       
   266            (gnus-group-mail-low-empty ((t (:foreground ,base00))))
       
   267            (gnus-group-news-1 ((t (:foreground ,base1 :weight ,bold))))
       
   268            (gnus-group-news-1-empty ((t (:foreground ,base1))))
       
   269            (gnus-group-news-2 ((t (:foreground ,blue :weight ,bold))))
       
   270            (gnus-group-news-2-empty ((t (:foreground ,blue))))
       
   271            (gnus-group-news-low ((t (:foreground ,violet :weight ,bold))))
       
   272            (gnus-group-news-low-empty ((t (:foreground ,violet))))
       
   273            (gnus-header-content ((t (:foreground ,cyan :slant ,italic))))
       
   274            (gnus-header-from ((t (:foreground ,base2))))
       
   275            (gnus-header-name ((t (:foreground ,blue))))
       
   276            (gnus-header-newsgroups ((t (:foreground ,green :slant ,italic))))
       
   277            (gnus-header-subject ((t (:foreground ,base1))))
       
   278            (gnus-server-agent ((t (:foreground ,base3 :weight ,bold))))
       
   279            (gnus-server-closed ((t (:foreground ,base1 :slant ,italic))))
       
   280            (gnus-server-denied ((t (:foreground ,base2 :weight ,bold))))
       
   281            (gnus-server-offline ((t (:foreground ,green :weight ,bold))))
       
   282            (gnus-server-opened ((t (:foreground ,cyan :weight ,bold))))
       
   283            (gnus-splash ((t (:foreground ,base2))))
       
   284            (gnus-summary-high-ancient
       
   285             ((t (:foreground ,magenta :weight ,bold))))
       
   286            (gnus-summary-high-read ((t (:foreground ,base1 :weight ,bold))))
       
   287            (gnus-summary-high-ticked ((t (:foreground ,base3 :weight ,bold))))
       
   288            (gnus-summary-high-undownloaded
       
   289             ((t (:foreground ,base2 :weight ,bold))))
       
   290            (gnus-summary-low-ancient
       
   291             ((t (:foreground ,magenta :slant ,italic))))
       
   292            (gnus-summary-low-read ((t (:foreground ,base1 :slant ,italic))))
       
   293            (gnus-summary-low-ticked ((t (:foreground ,base3 :slant ,italic))))
       
   294            (gnus-summary-low-undownloaded
       
   295             ((t (:foreground ,base2 :slant ,italic))))
       
   296            (gnus-summary-normal-ancient ((t (:foreground ,magenta))))
       
   297            (gnus-summary-normal-read ((t (:foreground ,base1))))
       
   298            (gnus-summary-normal-ticked ((t (:foreground ,base3))))
       
   299            (gnus-summary-normal-undownloaded ((t (:foreground ,base2))))
       
   300            ;; Flymake
       
   301            (flymake-errline ((t (:background ,orange))))
       
   302            (flymake-warnline ((t (:background ,violet))))
       
   303            ;; whitespace
       
   304            (whitespace-empty ((t (:foreground ,red))))
       
   305            (whitespace-hspace ((t (:foreground ,orange))))
       
   306            (whitespace-indentation ((t (:foreground ,base02))))
       
   307            (whitespace-space ((t (:foreground ,base02))))
       
   308            (whitespace-space-after-tab ((t (:foreground ,cyan))))
       
   309            (whitespace-space-before-tab ((t (:foreground ,red :weight ,bold))))
       
   310            (whitespace-tab ((t (:foreground ,base02))))
       
   311            (whitespace-trailing
       
   312             ((t (:background ,base02 :foreground ,red :weight ,bold))))
       
   313            (whitespace-highlight-face
       
   314             ((t (:background ,blue :foreground ,red))))
       
   315            ;; Message
       
   316            (message-mml ((t (:foreground ,blue))))
       
   317            (message-cited-text ((t (:foreground ,base2))))
       
   318            (message-separator ((t (:foreground ,base3))))
       
   319            (message-header-xheader ((t (:foreground ,violet))))
       
   320            (message-header-name ((t (:foreground ,cyan))))
       
   321            (message-header-other ((t (:foreground ,red))))
       
   322            (message-header-newsgroups
       
   323             ((t (:foreground ,yellow :weight ,bold :slant ,italic))))
       
   324            (message-header-subject ((t (:foreground ,base00))))
       
   325            (message-header-cc ((t (:foreground ,green :weight ,bold))))
       
   326            (message-header-to ((t (:foreground ,base1 :weight ,bold)))))
       
   327           ((foreground-color . ,base0)
       
   328            (background-color . ,base03)
       
   329            (background-mode . ,mode)
       
   330            (cursor-color . ,base0)))))))
       
   331 
       
   332 (defmacro create-solarized-theme (mode)
       
   333   (let* ((theme-name (intern (concat "solarized-" (symbol-name mode))))
       
   334          (defs (solarized-color-definitions mode))
       
   335          (theme-vars (mapcar (lambda (def) (list (car def) (cdr def)))
       
   336                              (second defs)))
       
   337          (theme-faces (first defs)))
       
   338     `(progn
       
   339        (deftheme ,theme-name ,solarized-description)
       
   340        (apply 'custom-theme-set-variables ',theme-name ',theme-vars)
       
   341        (apply 'custom-theme-set-faces ',theme-name ',theme-faces)
       
   342        (provide-theme ',theme-name))))
       
   343 
       
   344 (provide 'solarized-definitions)