Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RafalLukawiecki opened this issue Mar 11, 2017 · 3 comments
Open

Comments

@RafalLukawiecki
Copy link

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
Copy link

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
Copy link
Author

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants