syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.67k stars 4.89k forks source link

The default theme doesn't work well with tmux+screen-256color #12257

Closed c02y closed 5 years ago

c02y commented 5 years ago

Pay attention to my cusor position and color of the highlight line, all my cursors in the following images are in the same position .

  1. GUI emacs: gui

  2. terminal emacs+tmux without ~/.tmux.conf (TERM: screen) using command emacs -nw no-tmux-screen

  3. terminal emacs+tmux without ~/.tmux.conf using command env TERM=screen-256color emacs -nw tmux-env

  4. terminal emacs+tmux with ~/.tmux.conf containing only set -s default-terminal "screen-256color" using command emacs -nw tmux-env

  5. terminal emacs without tmux using command: env TERM=screen-256color emacs -nw no-tmux-env

Conclusion:

  1. The themes of "GUI emacs" and "terminal emacs without tmux but with screen-256color enabled" are bascially the same.
  2. Once I use tmux, the backgrounds of terminal emacs will be different
  3. I can see the highlighed line(cursor line) when using tmux without screen-256color
  4. once I use tmux + screen-256color(no matter pass it in command line or set it in ~/.tmux.conf), the highlighed line(cursor) will be invisible, besides, if I select any text, the mark is invisiable.

Normally set -s default-terminal "screen-256color" is in my ~/.tmux.conf, this is the result of aftering using tmux+fish for several years, so this is the best configuration, but terminal spacemacs doesn't work with tmux+screen-256color, how can I fix it?

FYI: GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars) of 2019-03-18 Spacemacs develop branch xfce4-terminal 0.6.3 Ubuntu 16.04.6 LTS tmux v2.8

c02y commented 5 years ago

Don't know why, I switch to another environment, it works again, the colors of the highlighed line in SPC b b and marked text are visiable now.

FYI: GNU Emacs 26.2 (build 1, x86_64-suse-linux-gnu, GTK+ Version 3.24.8) Spacemacs develop branch Yakuake v3.0.5 openSUSE Tumbleweed tmux v2.9

KPLauritzen commented 5 years ago

I'm having the same issue. What did you do to solve it?

c02y commented 5 years ago

@KPLauritzen I haven't solve it, I just switched to another environment, check the two FYI parts.

c02y commented 5 years ago

@KPLauritzen I solved it by changing theme in configuration in your terminal such as solarized-dark

or use the following configuration in user-config

  (when (not window-system)
    (progn
      ;; change the color or current highlighted line
      (set-face-background 'hl-line "839496")
      ;; change the color of selected item in helm list
      ;; (set-face-background 'region "black")
      (set-face-attribute 'region nil :background "#666")
      (with-eval-after-load 'helm
        (set-face-background 'helm-selection "839496"))
      ))
sdwolfz commented 5 years ago

Have you tried following the instructions from this guide? https://github.com/syl20bnr/spacemacs/wiki/Terminal

c02y commented 5 years ago

@sdwolfz Yes, the problem of colors is fixed.

But another serious probelm happens again(I mentioned this problem in here https://emacs.stackexchange.com/questions/50546/my-terminal-emacs-displays-weird-characters-u2506-for-unvisiable-characters-i) Emacs in terminal terminal

Vm in terminal: terminal-vim

sdwolfz commented 5 years ago

Hmm... I think you need to select a powerline font for your terminal: https://github.com/powerline/fonts.

c02y commented 5 years ago

I found out that this is the problem of the variable LANG,

$ echo $LANG
en_US

But

$ cat /etc/locale.conf
LANG=en_US.UTF-8
$ localctl status
System Locale: LANG=en_US.UTF-8
...

After I export the LANG to en_US.UTF-8, and problem is gone, and I don't have to do anything from the https://github.com/syl20bnr/spacemacs/wiki/Terminal

I don't know why echo $LANG returns en_US. This OS is managed by administrator in my company and a lot of files have been changed, and I've been using Linux for several years, and this is the first time this problem happens to me.

Anyway, if anyone has the same problem, please change your LANG variable to en_US.UTF-8.


UPDATE:

Actually, only setting LANG is not perfect, so now I use export LC_ALL=en_US.UTF-8 in ~/.bashrc

In case other issues happen in the future, you may need to put the following three into ~/.bashrc

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
sdwolfz commented 5 years ago

Thanks @c02y, I've added the exports to the wiki page for future reference.

c02y commented 5 years ago

@sdwolfz I'm sorry, this is not perfect, changing the environment variable of LC_ALL/LANG only solved the issue I mention at https://github.com/syl20bnr/spacemacs/issues/12257#issuecomment-494220038

The issue (highlight faces) I posted at the beginning of this page is back again.

And I use MobaXterm to access two OSes, one is openSUSE, one is RHEL7, besides, there are the following info I need to mention:

  1. MobaXterm configs are the same
  2. Both spacemacs configs are the same
  3. Both tmux configs are the same including TERM
  4. Both shell configs are the same(fish shell)
  5. spacemacs with configs and vanilla emacs with configs work in openSUSE, not work in RHEL7

So this is not the problem of emacs or spacemacs or tmux , this is problem of my RHEL7 itself.

I reopen this issue, and will update it.

UPDATE: Don't know why, it works again, maybe restart tmux?

UPDATE2:: I know the reason now, if you happen to use tmux, please use tmux -2 or tmux attach -2 instead of just tmux or tmux attach, just to be safe.

Since after tmux or tmux attach, terminal+tmux may not support true colors any longer.

Use https://gist.github.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263#file-print256colours-sh or https://askubuntu.com/a/821161/345798 to test colors on your terminal.

BTW: You may want to disable loading theme when using spaemacs in terminal, use the following snippet in your user-config then:

(unless (display-graphic-p)
   (disable-theme 'spacemacs-dark))

it works for me, now, emacs in terminal does use the theme of my terminal instead of spacemacs-dark, spacemacs-dark is the default theme used my spacemacs if you didn't change dotspacemacs-themes variable in your ~/.spacemacs or ~/.spacemacs.d/init.el