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

Fringe and line numbers appear in opposite (dark vs light) colour #199

Open RafalLukawiecki opened 7 years ago

RafalLukawiecki commented 7 years ago

I really like your theme adaption, thank you for making it available. I use it with GNU Emacs 25.1.1 and with the GUI GNU Emacs.app, both on macOS 10.12 Sierra. I have added a couple of lines to automatically select the dark vs light variant depending on the current terminal colour (iTerm2), for which I am also using the Solarized scheme.

(setq frame-background-mode (if (equal "12;8" (getenv "COLORFGBG")) 'dark 'light))
(load-theme 'solarized)

This code works well when calling emacs in the terminal, but when I call the GUI GNU Emacs.app (or other GUI emacs ports) the fringe and the line numbers appear in the wrong (opposite) colour. However, as soon as I toggle the colour scheme twice (via kbd ) everything is good. Also, if I evaluate (load-theme 'solarized t) it also fixes the issue. However, even though this is done in my .emacs, even more than once, it does not work on its own from there. I tried putting it in after-init hooks, iterating through frames, all to no avail... Only that manual evaluation or toggling the colours fixes this issue.

This is what it looks like:

screen shot 2017-03-11 at 21 41 58

and:

screen shot 2017-03-11 at 21 43 08

I would be grateful for any suggestions how to diagnose it further, or how to fix it. Thank you and regards from Ireland.

phoenixanimations commented 6 years ago

I've stumble across this problem myself as well. I eventually found out that the easiest way to play nice with emacs theming system, is to deactivate a specific theme and then load a specific theme. So if you were to start emacs with just solarized installed (and nothing else in your init.el) and wanted to create two functions to switch between light and dark it would be something like:

(defun my-solarized-dark-load ()
  (interactive)
  (disable-theme solarized-light)
  (load-theme solarized-dark))

(defun my-solarized-light-load ()
  (interactive)
  (disable-theme solarized-dark)
  (load-theme solarized-light))

If you want a more universal disable-theme I use this: (dolist (theme custom-enabled-themes) (disable-theme theme)) instead of (disable-theme solarized-light/dark). custom-enabled-themes is all the themes you have loaded (these won't include any kind of setting you do outside a theme though like for example change the frame-background-mode). For your toggle code, one thing that quickly comes to mind would be something like:

(defvar theme-dark-toggle nil)
(defun toggle-theme-background ()
  (interactive)
  (if theme-dark-toggle
      (my-solarized-dark-load)
    (my-solarized-light-load))
  (setq theme-dark-toggle (not theme-dark-toggle)))

Hopefully this helps a little, let me know if I missed something.

RafalLukawiecki commented 6 years ago

Thank you @phoenixanimations, much appreciated. I ended up using a variant of the Solarized theme which avoids the issue (but causes others). It has been a while since I tried to rectify it in this version of the theme, so my mind is a bit off the topic, but I will try again with your fix and I will report back. Thanks!

phoenixanimations commented 6 years ago

No problem I responded casually and didn't realize it was so long ago haha. Figure I would mention disable-theme as I'm a big fan of switching themes and for the longest time didn't know about that function.