sellout / emacs-color-theme-solarized

Emacs highlighting using Ethan Schoonover’s Solarized color scheme
http://ethanschoonover.com/solarized
MIT License
1.16k stars 202 forks source link

Add global color variables and related functions #133

Closed mattduck closed 9 years ago

mattduck commented 9 years ago

Make color values accessible as solarized-base01, solarized-blue etc, and add a solarized-theme-hook that runs when those variables are updated (plus some other related functions). You can then use the color variables in ad-hoc situations:

(defun my-custom-org-setup ()
  (setq org-todo-keyword-faces
    `(("TODO" . (:foreground ,solarized-orange))
      ("HOLD" . (:foreground ,solarized-base3))
      ("DONE" . (:foreground ,solarized-base01))))
  (font-lock-fontify-buffer))
(add-hook 'solarized-theme-hook 'my-custom-org-setup)

I'm not certain this should be merged, it's clumsy and I'm not too familiar with the customization system. It's a solution to this situation:

Is there a more elegant / proper way of achieving this?

sellout commented 9 years ago

I want to have something like this, so I’m glad you’ve tried something.

One issue that comes to mind is that the colors mapped to base3, etc. may be different for each frame (EG, a GUI frame with a light background will have #002b36, while a frame running in a 16-color terminal in the same Emacs instance will have brightwhite), so you may want to add custom frame parameters to fake frame-local bindings.

Now, I don’t know what will happen if you reference those frame parameters in my-custom-org-setup. Does it get the value from whichever frame happens to be frontmost? I would guess so.

It would also be nice to expose something like create-face-spec (which should probably be called solarized-create-face-spec) that does just the spec part (without consing on name), so that maybe you could do

(setq org-todo-keyword-faces
  `(("TODO" . ,(sol-spec '(:foreground solarized-orange)))
    ("HOLD" . ,(sol-spec '(:foreground solarized-base3)))
    ("DONE" . ,(sol-spec '(:foreground solarized-base01)))))

and have (sol-spec '(:foreground solarized-orange)) expand into

((((background dark) (type graphic)) (:foreground "#cb4b16"))
 (((background dark) (type tty) (min-colors 256)) (:foreground "brightred"))
 (((background dark) (type tty) (min-colors 16)) (:foreground "brightred"))
 (((background dark) (type tty) (min-colors 8)) (:foreground "red"))
 (((background light) (type graphic)) (:foreground "#cb4b16"))
 (((background light) (type tty) (min-colors 256)) (:foreground "brightred"))
 (((background light) (type tty) (min-colors 16)) (:foreground "brightred"))
 (((background light) (type tty) (min-colors 8)) (:foreground "red")))
  1. yes, that’s what’s currently generated for each face;
  2. I realize (just now) that for certain faces it could be reduced (EG, in this case, we only need three entries) but doing that might take some work; and
  3. I don’t know if org-todo-keyword-faces will accept a full spec like that.

Anyway, this is just more stuff to think about. I haven’t done anything in this direction myself, and I appreciate that you have.

mattduck commented 9 years ago

@sellout Thanks for your thoughts here, some things that I hadn't considered (eg. supporting tty and gui frames).

At some point I will get back to this and write something that fits with the updates you've made this year, but I don't know when it will be yet. In the meantime, as long as #113 is open for discussion, it might make sense to close this PR.