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

Most of the theme colors are broken for me #1269

Closed
ahmedelgabri opened this issue Apr 19, 2015 · 86 comments
Closed

Most of the theme colors are broken for me #1269

ahmedelgabri opened this issue Apr 19, 2015 · 86 comments

Comments

@ahmedelgabri
Copy link

Here is a screenshot trying to use base16-ocean theme

screen shot 2015-04-20 at 00 07 57

Monokai is the only one that is working nicely, how can I fix this? I'm using iTerm2

@trishume
Copy link
Contributor

You can fix it by using the GUI version. Most themes are borked in terminal, don't know why.

@GeauxEric
Copy link

put export TERM=xterm-256color in your ~/.bashrc or ~/.profile and try.

@ahmedelgabri
Copy link
Author

@ericting My terminal is already set as xterm-256color

@syl20bnr
Copy link
Owner

@ahmedelgabri can you open a helm-color buffer with SPC C l and tell us how many colors you see there ?

@ahmedelgabri
Copy link
Author

@syl20bnr I can see 100 colors

@tuhdo
Copy link
Contributor

tuhdo commented Apr 21, 2015

It should be 100 because Helm is limited to display 100 candidates. However, it means that you have 256 colors. Maybe you should give Zenburn a try? Or use stock Terminal app in OS X rather than Iterm 2 to see if there's any difference?

@ahmedelgabri
Copy link
Author

@tuhdo The same is happening on the terminal.app. Only Zenburn I don't like it and Monokai are the only ones that are working fine most of the rest if not all are broken.

@tuhdo
Copy link
Contributor

tuhdo commented Apr 21, 2015

Even Solarized look ugly? So I think probably your terminal and Emacs works fine, it's just that the themes are not well supported in terminal. Monokai actually defines another set of colors for terminal version.

@ahmedelgabri
Copy link
Author

@tuhdo Yeah even Solarized. Other than this everything looks like working well.

@Baltazore
Copy link

Does anyone know how to fix this issue? Any suggestions?
I already tried:
TERM=xterm-256color emacs
TERM=xterm-256color emacs -nw
emacs -nw
Still get so bad colours in terminal
Dark:
dark
Light:
light

@honza
Copy link

honza commented May 18, 2015

screen shot 2015-05-18 at 09 00 36

This is my setup with solarized dark in iTerm2 and tmux.

@boyanangelov
Copy link

I have this issue as well! Tried re-installing emacs and that didn't work (iterm2 + the default terminal.app). For now I guess we're stuck with the GUI version.

@madmod
Copy link

madmod commented Jun 9, 2015

Same issue here in both iTerm 2 and Terminal. Also the powerline is messed up even when I use a powerline patched font. I've set my iTerm 2 font to Source Code Pro with the "Report Terminal Type" option on all possible settings. I tried running emacs-24.5 also with the commands suggested above. Using the GUI version isn't a great option for me.

@cpaulik
Copy link
Contributor

cpaulik commented Jun 9, 2015

In the terminal you can only get one of the 256 colors listed here. This means that if the theme does not take care the colors set by the theme will go to the nearest color in terms of distance in color space.

AFAIK the only solution is to choose a theme with terminal support.

@Baltazore
Copy link

@cpaulik is there any port of solarized vim terminal theme for emacs?

@cpaulik
Copy link
Contributor

cpaulik commented Jun 10, 2015

I don't know why but the themes-megapack uses http://melpa.org/#/color-theme-sanityinc-solarized which does not seem to support color degradation properly.

http://melpa.org/#/color-theme-solarized on the other hand seems to handle this issue well

@syl20bnr Any reason for choosing the one over the other?

@madmod
Copy link

madmod commented Jun 10, 2015

It looks like someone got 24 bit color working with vim using a nightly build of iTerm 2. I don't know how to adapt this to spacemacs though.

@trishume
Copy link
Contributor

That's neat I didn't know iTerm supported that. There's 24 bit patched formulae for tmux and emacs here:
https://github.com/choppsv1/homebrew-term24

@ahmedelgabri
Copy link
Author

I'm already using iTerm nightly and that screenshot was from an iTerm nightly build.

@ahmedelgabri
Copy link
Author

Although it does support more colors and that fixed my issues when I use vim with base-16 but apparently not working with Emacs.

@syl20bnr
Copy link
Owner

@cpaulik the solarized version used in spacemacs is bbatsov's one.

I just realized that we could create a new dotvariable for spacemacs dotspacemacs-terminal-themes !!

@trishume
Copy link
Contributor

@ahmedelgabri you have to use both the right iTerm and a patched emacs. See the link I posted.

@cpaulik
Copy link
Contributor

cpaulik commented Jun 10, 2015

@syl20bnr ah ok. From a quick glance at the source code of this version it seems that it also does not have terminal support.

So we could add this version of solarized to the themes-megapack but how many different solarized themes do we want to have in spacemacs?

@madmod
Copy link

madmod commented Jun 10, 2015

Why does the current solarized theme work in the GUI emacs but not with true color in iTerm 2? Can we patch emacs or spacemacs so that it thinks iTerm is the GUI?

@trishume
Copy link
Contributor

@madmod Did you see the link I posted to a patched emacs that does exactly that?

@ahmedelgabri
Copy link
Author

@trishume was on my phone so I didn't check the link.

Checked it now, but why do we need to patch Emacs while it seems as other mentioned that the problem might be the themes themselves?

@madmod
Copy link

madmod commented Jun 10, 2015

@trishume sorry I missed that. After running the following commands in the latest nightly build of iTerm 2 I have 24 bit color working with the sublime-dark theme!

image

First I had to uninstall my previous version of emacs and then install the patched version.

brew uninstall emacs
brew tap choppsv1/term24
brew install choppsv1/term24/emacs

Also for anyone interested this is a fast way to install the nightly version of iTerm2. By default casks will install to ~/Applications. Run install with --appdir if you want it elsewhere. Cask usage

brew tap caskroom/versions
brew cask install iterm2-nightly

Then run emacs with the flag mentioned here.

ITERM_24BIT=1 emacs

The last thing I need to figure out is how to fix the bad characters at the bottom. I have iTerm set to use Source Code Pro for both the ASCII and non ASCII font.

Other minor things not working for me:

  • The cursor is not colored like in GUI emacs.
  • There is no highlight on mouseover for clickable items.

@ethanluoyc
Copy link

Actually I think the idea of having a separate variable for terminal theme is nice. @syl20bnr do you have plans to implement that?

@syl20bnr
Copy link
Owner

@ethanluoyc unfortunately I don't think this is possible because it will break with Emacs started as a daemon.

@dpc
Copy link

dpc commented Jul 7, 2016

My currently best working setup (solarized dark in terminal, through ssh, in tmux, using daemon + client): http://termbin.com/groe

@robbyoconnor
Copy link
Contributor

Why not just use TRAMP vs ssh'ing in?

@ethanluoyc
Copy link

The problem is that Tramp can have lots of bugs sometimes.

On Thu, Jul 7, 2016 at 4:25 PM +0800, "robbyoconnor" notifications@github.com wrote:

Why not just use TRAMP vs ssh'ing in?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@dpc
Copy link

dpc commented Jul 7, 2016

@robbyoconnor: I am personally looking for Spacemacs to be my Vim replacement. I'd like to be able to take a cheap chromebook, and ssh to my dev box and use Emacs instead of Vim, instead of trying to install emacs on my chromebook etc.

The fact that command line is a second-class citizen in emacs is a great pain for me, since I already spent so much time altering my habits, I can clearly see that emacs is more powerful than Vim, and I really like Spacemacs features and SPC leader, but then problems with solarized theme, and display corruptions in tmux are ruining the experience. :(

@abnerf
Copy link

abnerf commented Jul 31, 2016

@cpaulik your fix works beautifully, but not with emacs as daemon and connecting with emacsclient. Do you have any idea of how to fix it?

@cpaulik
Copy link
Contributor

cpaulik commented Jul 31, 2016

@abnerf have you tried https://github.com/sellout/emacs-color-theme-solarized#all-versions ? I guess you want to set the theme when a new frame is created.

@dpc
Copy link

dpc commented Jul 31, 2016

@abnerf : I use setup with combination of gnome-shell with dark solarized, tmux, ssh, spacemacs in client + daemon mode and it works for me quite well now.

@abnerf
Copy link

abnerf commented Aug 1, 2016

@cpaulik @dpc thanks! I had solved with a similar solution. Now, one thing I don't understand is why the font size is different/smaller when I launch the emacsclient (with graphics) compared to the normal emacs (with graphics). But that probably a question for another ticket.

@arronmabrey
Copy link
Contributor

@domi91c did you ever figure out why tmux was pure black / white? I'm having the same issue.

@yogsototh
Copy link

yogsototh commented Oct 7, 2016

The best workaround I found is to add this line in my .spacemacs in the function dotspacemacs/user-config:

  ;; Colortheme fix in terminal
  (custom-set-faces (if (not window-system) '(default ((t (:background "nil"))))))

While still not perfect, the result is acceptable to me.
So now I am happy with my alias vi="emacsclient -t".

@markschultz
Copy link

@yogsototh I've expanded on that a bit to allow emacsclient -t and emacsclient -c

 (add-hook 'after-make-frame-functions
            (lambda (frame)
              (select-frame frame)
              (if (not window-system)
                  (custom-set-faces '(default ((t (:background "nil")))))
                  (custom-set-faces '(default ((t (background dark))))))))

using urxvt on linux I was getting correct colors in gui, dark blue background in terminal. Above gives more or less correct colors in both.

@robbyoconnor
Copy link
Contributor

@markschultz -- do a PR to fix this for others -- or document it someplace...

@bezhermoso
Copy link
Contributor

@yogsototh's solution works to fix colors in iTerm, but eventually breaks Emacs.app once the (custom-set-faces ...) is appended to ~/.spacemacs.

@markschultz's solution doesn't fix it for me.

@DKuykendall
Copy link

DKuykendall commented Jan 26, 2017

Yogsototh's solution worked for me, but in both the terminal and gui, the background of the mode/buffer number indicator on the left of the powerline is now no longer colored, with the exception of the powerline separator character. No other theme does this. Any idea what causes this and how to fix it?

screen shot 2017-01-26 at 2 45 04 am

screen shot 2017-01-26 at 2 45 17 am

@belak
Copy link
Contributor

belak commented Feb 15, 2017

I know that there was work done on the base16-themes to default to using your terminal colors, so the should no longer be an issue with this.

@jupl
Copy link
Contributor

jupl commented Mar 16, 2017

For those using tmux the answer here fixed my weird color issues.

TL;DR TERM=screen-256color and tmux -2 [other options]

@fmthoma
Copy link

fmthoma commented Apr 25, 2017

So, I finally got @sellout's emacs-color-theme-solarized to work with the emacs daemon and both GUI and terminal (urxvt) clients.

These are the steps:

Step 1:

Set up a Solarized color scheme for your terminal. For urxvt, the .Xresources can be found e.g. here. I added a semi-transparent background: scratchpad.background: [80]#002b36.

Step 2:

In your .spacemacs, you have to exclude the default package for the Solarized color theme (which is broken in most terminals), and install the other one:

(defun dotspacemacs/layers ()
  (setq-default
   ...
   dotspacemacs-excluded-packages '(solarized-theme)
   dotspacemacs-additional-packages '(color-theme-solarized)
   ...
   ))

And by the way, you should also remove any solarized-dark/solarized-light from your dotspacemacs-themes.

Step 3:

The theme loading mechanism for color-theme-solarized is somewhat different from the Spacemacs default, so we need a bit of tweaking. Add this to your dotspacemacs/user-config:

(defun enable-solarized-in-terminal (frame)
  ;; cf. http://philipdaniels.com/blog/2017/02/spacemacs---configuring-the-solarized-theme/
  (unless (display-graphic-p frame)
    (set-frame-parameter frame 'background-mode 'dark)
    (set-terminal-parameter frame 'background-mode 'dark)
    (spacemacs/load-theme 'solarized)
    ))

(defun enable-solarized-in-gui ()
  (mapc 'disable-theme custom-enabled-themes)
  (setup-solarized-theme)
  (spacemacs/load-theme 'solarized)
  )

(defun setup-solarized-theme ()
  ;; I like a transparent background in the terminal
  (custom-set-faces
    '(default (
              (((type tty) (background dark)) (:background "nil"))
              )))
  ;; The frame number indicator has some problems with inverse video
  (set-face-inverse-video 'spacemacs-motion-face nil)
  (set-face-inverse-video 'spacemacs-insert-face nil)
  (set-face-inverse-video 'spacemacs-normal-face nil)
  (set-face-inverse-video 'spacemacs-visual-face nil)
  (set-face-inverse-video 'spacemacs-replace-face nil)
  )

;; For GUI clients, after-make-frame-functions is messed up (probably it is
;; called too early), and some colors are messed up. For terminal clients on
;; the other hand, it works perfectly. The background-mode is necessary for
;; terminal clients, but (apparently) not for GUI clients, and has to be set
;; for each frame individually.
(spacemacs|do-after-display-system-init (enable-solarized-in-gui))
(add-hook 'after-make-frame-functions 'enable-solarized-in-terminal)

Explanation

The difference to @yogsototh's and @markschultz's approach for disabling the background for terminal clients is basically not to change the 'default face definition each time a frame is created, but to assign it a frame-dependent value: the (type tty) (background dark) in the custom-set-faces call means: »When the frame-type is tty, and the background-mode is dark, then change the :background to "nil".
The set-face-inverse-video lines solve the problem mentioned by @DKuykendall.
Also (and this took me a lot of time to figure out), the two different hooks are important: Apparently, in daemon mode the after-make-frame-functions hook is called too early for GUI clients, so the display system is not yet fully initialized and some colors remain broken. (They magically fix after starting the second client, and the problem does neither appear for tty clients, nor for standalone instances).

@fiveNinePlusR
Copy link
Contributor

Is this still an issue?

@belak
Copy link
Contributor

belak commented Jun 19, 2018

@fiveNinePlusR This needs to be fixed on a theme-by-theme basis. The base16 themes are the only ones I can directly speak for, but they should be fine.

@mrivas616
Copy link

@fmthoma Your solution worked for me, not only I got solarized to finally look the way it's supposed to look but also any other theme looks good now in GUI mode, thank you!

@martinweiss
Copy link

I am not using spacemacs, but I also had issues with bbatsov's Solarized themes when running emacs in the terminal. After a while of searching for possible solutions (which also led me here), I finally found a solution that worked for me, by using a custom terminfo description (xterm-24bit), as desribed here: bbatsov/solarized-emacs#18 (comment)

Now I no longer get that blue background when I use the solarized-dark theme.

Maybe this also works with spacemacs?

@sdwolfz
Copy link
Collaborator

sdwolfz commented Aug 3, 2018

There's a guide for turning on 24bit in a terminal here: https://github.com/syl20bnr/spacemacs/wiki/Terminal

@wallevy
Copy link

wallevy commented Jan 9, 2019

@sdwolfz It works for me, thanks so much!! I'm using ir-black theme.

@Compro-Prasad
Copy link
Contributor

IMO this issue is resolved through the wiki.

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

No branches or pull requests