5

Is there any extension or easy way to invert colors in emacs?

I tend to show code a lot through screen sharing and often a light theme is better while the dark is more comfortable for me to work alone.

Rafa de Castro
  • 1,231
  • 10
  • 14

3 Answers3

4

You could use two different color themes and switch between them.

(global-set-key [f5] (lambda () (interactive) (load-theme 'sanityinc-tomorrow-day t)))
(global-set-key [f6] (lambda () (interactive) (load-theme 'sanityinc-tomorrow-night t)))
max0r
  • 280
  • 3
  • 12
  • 1
    You cannot switch to themes directly using their names. An elisp call to load a theme is of the type (load-theme 'THEME-NAME t). That has to be wrapped in (lambda () (interactive) .. ) if binding directly to a key. – Kaushal Modi Jun 16 '15 at 10:24
  • @kaushalmodi In case of color-theme-sanityinc-tomorrow-... this works. But I've changed my answer as you suggested. – max0r Jun 16 '15 at 10:36
  • Ah. That theme then might have those wrapper functions built in. Generally theme packages do not have such wrapper functions. – Kaushal Modi Jun 16 '15 at 10:39
  • You could also just use M-x enable-theme – Jordon Biondo Jun 16 '15 at 14:04
2

There's a -rv switch you can use to boot up Emacs in reverse video mode, however I've found it not to work in combination with custom themes.

wasamasa
  • 22,178
  • 1
  • 66
  • 99
2

Your question asks about "inverting colors", which I interpret as "complementing colors". But then you also talk about themes.

  • You can use library Palette (palette.el) to obtain the complement of any color in a WYSIWYG way (so you can easily tweak the result if you like).

  • You can use library hexrgb.el to obtain the complement of any color programmatically (command hexrgb-complement).

  • You can use library Do Re Mi or library Icicles to incrementally adjust colors or face foregrounds/backgrounds.

  • You can use these things (above) to define a new theme starting from an existing theme.

  • You can use library Icicles to cycle among existing themes (color themes or custom themes).

Drew
  • 77,472
  • 10
  • 114
  • 243