Recently I started using Tmux, but I noticed that it causes a strange Emacs glitch. When I open source code for elisp or haskell, the comments aren't highlighted. Only the comment sign is (; in case of elisp, -- in case of haskell). The rest of the commented line is in normal colour. When I run Emacs outside of Tmux everything works as expected - the whole commented line is highlighted in a colour denoting a comment. Any ideas why this is happening?

SOLUTION: Based on Stefan's comment I added this to my .emacs file:

  '(font-lock-comment-face ((((class color)
                              (min-colors 8)
                              (background dark))
                              (:foreground "red"))))))

Now the comments are displayed in red, just like comment delimiters.

migrated from stackoverflow.com Sep 18 '12 at 8:21

This question came from our site for professional and enthusiast programmers.

  • This is a software behavior question, not a programming question and is thus better suited for superuser, no wait, serverfault. no wait, i dont know, but somewhere else. – Wug Sep 16 '12 at 16:10

This behavior is due to Emacs using a different coloring scheme when the number of colors is too limited. So the underlying cause of the difference is that in Tmux, the number of colors available is restricted (I don't know why). You can also change (with M-x customize-face RET) the faces font-lock-comment-face and font-lock-command-delimiter-face to simply work around the problem.

  • 1
    One possibility is to start tmux with the -2 option (256-color support) and to make sure you set TERM to screen-256color inside tmux. – chepner Sep 16 '12 at 20:53
  • Thanks chepner. Your solution works, but it also causes other colours to change. – killy9999 Sep 17 '12 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.