1

I’m having this weird problem with emacs and would really appreciate some help. I’m running emacs in terminal on an ubuntu server that is setup on VirtualBox on my windows pc. I’ve tried both Cygwin and Git-Bash (both have mintty) and I get the same problem on both terminals.

The problem I’m getting is when I activate one of my custom themes for emacs the text gets garbled and unreadable. It’s mostly commented text that seem to meld together with other text. However, when I switch over to one of the default themes that ship with emacs the problem goes away. So this seems to be a problem with the custom themes (gotham and the whole tomorrow-night pack), because I’ve also noticed that the custom themes are affected by the mintty theme I’m using, while the standard emacs themes are unaffected by these. So when I enable, for example, gotham theme, and I open the mintty options and switch color themes there, the colors of gotham are affected as well. If I try the same with for example wombat theme (which ships with emacs), changing mintty themes does not have any affect at all on the emacs colors.

I believe the problems are connected to the emacs themes. The problem should not come from using mintty themes, as I’ve tried starting a terminal with default options (with only xterm-256color) enabled, and get the same problems from the custom emacs themes. It could be a problem with xterm-256color, but I am unable to check this since emacs doesn’t load any themes at all when only standard 8bit colors are enabled. But once again, if mintty was at fault then all emacs themes should be affected, instead of just the custom ones I’ve downloaded.

So what I’m wondering is if anyone knows if there are any settings somewhere in emacs config or in the theme files themselves that allow emacs to ignore terminal colors? Any advice would be greatly appreciated. I’m currently in the process of analyzing standard emacs themes against custom emacs themes to see if I find anything, but I’m not sufficiently versed at lisp to really understand what I’m looking for.

UPDATE - After experimenting some more I realized that the problematic themes seem to either be missing or are failing to load a few colors. I saw this while scrolling through the different themes with M-x customize-themes. A few of the themes will retain some background and text color from the previous working theme, and mix them together which is what produces the garbled looking text. The unreadable text is printed in two layers on top of eachother with different colors and fonts.

2 Answers 2

2

Getting italics working with tmux

since mintty supports italics since 2.7.6

Short and sweet answer

  1. Edit your $TERM.terminfo to include sitm=\E[3m & ritm=\E[23m and then recompile with tic

  2. Edit your .tmux.conf (I changed both the default and user copy) to include: set -g default-terminal "tmux-256color"

  3. rm -rf /tmp/tmux-* and then start the tmux server again and it should work.

  4. Disclaimer: I've only tested this on cygwin, no actual linux systems.

Backstory and longer winded explanation.

I spent about an hour figuring this out today, hopefully it will help others figure it out faster.

Short and sweet background; I installed a new colorscheme that uses italics a LOT.

As with most things, there's always a catch. The colorscheme was working great alongside my cygwin setup, with no hitches until I opened up tmux. Tmux really doesn't play well with things like syntax highlighting or italics (without configuration). So the next thing to do to is some reasearch. In my travels I came across these next few links.

The first one links to the second one, and technically had all of the info necessary to fix my problems. It wasn't quite acceptable for me though, as the first had you writing your own special terminfo file which nothing will recognize once you start ssh'ing other places. So that was right out, but I figured there was probably a way to edit the terminfo of the current terminal to add italic support. After some more research I found this which was exactly what I was looking for, but didn't outright fix the problem.

On a hunch, I went to the github project for tmux and searched for 'italics', and came up with issue #1137. I would suggest reading through the entire thread, as it has some very helpful info even apart from just italicizing words.

After changing the $TERM value in my .tmux.conf to 'tmux-256color' and rm -rf'ing the tmux directory located in tmp, tmux started up and displayed all the italics!

1

Solved! The problem arose with some themes using italics, which apparently broke the rendering of text. I think the problem may in this case be cause by Mintty, but I am not sure. After changing all fields in the theme that say :slant italic to :slant normal the problem was fixed.

I also found this explanation at https://github.com/mintty/mintty/issues/152:

The trouble is, terminals are basically designed for rectangular character cells, so slanted letter don't really fit that. When trying italic fonts in mintty, parts of letters are painted outside their character cells, so they also end up being cut off or not erased properly."

edit: See other answer for solution. My answer here is more of a workaround than an actual fix.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .