unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* emacs -nw, xterm and 256 colors
@ 2007-03-27 14:54 Martin Karlsson
  2007-03-28 15:53 ` Leo
  2007-03-29 12:22 ` emacs -nw, xterm and 256 colors [solved] Martin Karlsson
  0 siblings, 2 replies; 9+ messages in thread
From: Martin Karlsson @ 2007-03-27 14:54 UTC (permalink / raw)
  To: help-gnu-emacs

Hello.

I'm trying to get `emacs -nw' in xterm to display 256 colors, and so far
it's not going well. I only get 8.

This (or a very similar) problem was discussed in
<87fzic4rqq.fsf@dazed.zeppelin.net> (October 2003, emacs-pretest-bugs@),
and in <cr924i$164$1@reader1.panix.com> (January 2005, help-gnu-emacs@).

My environment:

xterm% uname -psr
==> FreeBSD 6.2-RELEASE-p3 i386

xterm% $(which xterm) -v  # /usr/ports/x11/xterm
                          # with 256 colors enabled
==> X.Org 6.9.0(225)

xterm% $(which emacs) --version | head -1
                          # /usr/ports/editors/emacs-devel
==> GNU Emacs 22.0.93.1   # linked against X and libXaw3d

; emacs -nw inside xterm
system-uses-terminfo C-j
==> t

(display-color-cells) C-j
==> 8

M-x list-colors-display RET
==> <http://martink.freeshell.net/emacs/list-colors-display.png>
    black    black    #000000
    red      red      #cd0000
    green    green    #00cd00
    yellow   yellow   #cdcd00
    blue     blue     #0000ee
    magenta  magenta  #cd00cd
    cyan     cyan     #00cdcd
    white    white    #e5e5e5

(getenv "TERMCAP") C-j
==> <http://martink.freeshell.net/emacs/getenv-termcap.txt>
    "xterm-256color|xterm alias 3:k1=\\EOP:k2=\\EOQ: [...]"

xterm% echo $TERM
==> xterm-256color # set in ~/.Xdefaults
                   # (XTerm*termName: xterm-256color)

xterm% ./256colors2.pl # <http://frexx.de/xterm-256-notes/>
==> <http://martink.freeshell.net/emacs/256colors2.png> (the "correct" output)

xterm% infocmp xterm-256color  # /usr/ports/devel/ncurses
==> <http://martink.freeshell.net/emacs/xterm-256color.txt>
    #       Reconstructed via infocmp from file: \
    /usr/local/share/misc/terminfo.db
    xterm-256color|xterm with 256 colors,
        am, bce, ccc, km, mc5i, mir, msgr, npc, xenl,
        colors#256, cols#80, it#8, lines#24, pairs#32767,
    ...
    (weird spacing and line-breaks due to formatting for this message)


On a whim, I changed line 373 of
[...]/share/emacs/22.0.93/lisp/term/xterm.el(.gz) to read:
"(let* ((ncolors 256)"

and later to read:
"(let* ((ncolors 88)"

instead of:
"(let* ((ncolors (display-color-cells))"

In the 256-colors case, emacs tells me "Unsupported number of xterm
colors (256)" in the echo area (and I'm not surprised, me and math don't
mix very well, so the value 256 may very well be wrong).

In the 88-colors case, `M-x list-colors-display' outputs:
==> black         black         0000
    red           red            #cd0000
    green         green          #00cd00
    yellow        yellow         #cdcd00
    blue          blue           #0000ee
    magenta       magenta        #cd00cd
    cyan          cyan           #00cdcd
    white         white          #e5e5e5
    brightblack   brightblack    #7f7f7f
    brightred     brightred      #ff0000
    brightgreen   brightgreen    #00ff00
    brightyellow  brightyellow   #ffff00
    brightblue    brightblue     #5c5cff
    brightmagenta brightmagenta  #ff00ff
    brightcyan    brightcyan     #00ffff
    brightwhite   brightwhite    #ffffff
    color-16      color-16       #000000
    color-17      color-17       #00008b
    ...           ...            ...
    color-87      color-87       #e7e7e7

Only the "usual" colors (up to and including "white"), however, are
actually colorized by emacs.

For the 88-colors case, the output of "M-x open-termscript RET" followed
by "M-x list-colors-display RET" can be found at
<http://martink.freeshell.net/emacs/88termscript.txt>

I'm not at all sure what to make of all this. My working theory is that
it's more of a user problem, than an emacs\|terminfo\|xterm problem --
in any case, I'd appreciate feedback and help.

If the fix for my problem was mentioned in the the threads I mentioned
above, I didn't understand it. My apologies.

Regards,

-- 
Martin Karlsson

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: emacs -nw, xterm and 256 colors
  2007-03-27 14:54 emacs -nw, xterm and 256 colors Martin Karlsson
@ 2007-03-28 15:53 ` Leo
  2007-03-29 12:22 ` emacs -nw, xterm and 256 colors [solved] Martin Karlsson
  1 sibling, 0 replies; 9+ messages in thread
From: Leo @ 2007-03-28 15:53 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-03-27, Martin Karlsson said:

> I'm trying to get `emacs -nw' in xterm to display 256 colors, and so
> far it's not going well. I only get 8.

I was able to set TERM=term-256color and get 256 from
(display-color-cells) as tested in GNU Emacs 22.0.95.6
(i686-pc-linux-gnu, GTK+ Version 2.10.8) of 2007-03-18 on Fedora 6
gnu/linux.

However, (list-display-colors) only displays 7 colors namely black red
green yellow blue magenta cyan and white in color, the rest are
displayed with the default background.

Best,
-- 
Leo <sdl.web AT gmail.com>                         (GPG Key: 9283AA3F)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: emacs -nw, xterm and 256 colors [solved]
  2007-03-27 14:54 emacs -nw, xterm and 256 colors Martin Karlsson
  2007-03-28 15:53 ` Leo
@ 2007-03-29 12:22 ` Martin Karlsson
  2007-03-29 13:01   ` Leo
  1 sibling, 1 reply; 9+ messages in thread
From: Martin Karlsson @ 2007-03-29 12:22 UTC (permalink / raw)
  To: help-gnu-emacs

Not an emacs problem, sorry for the noise.

A few minutes of hack 'n' slash in the termcap database, replacing some
of the xterm* entries with newer ones, and adding some, fixed my problem.
-- 
Martin Karlsson

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: emacs -nw, xterm and 256 colors [solved]
  2007-03-29 12:22 ` emacs -nw, xterm and 256 colors [solved] Martin Karlsson
@ 2007-03-29 13:01   ` Leo
  2007-03-29 15:17     ` Martin Karlsson
  0 siblings, 1 reply; 9+ messages in thread
From: Leo @ 2007-03-29 13:01 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-03-29, Martin Karlsson said:

> Not an emacs problem, sorry for the noise.
>
> A few minutes of hack 'n' slash in the termcap database, replacing
> some of the xterm* entries with newer ones, and adding some, fixed
> my problem.

Can you post a screen shot of list-colors-display? I can only see 7
colors while display-color-cells shows 256.

Regards,
-- 
Leo <sdl.web AT gmail.com>                         (GPG Key: 9283AA3F)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: emacs -nw, xterm and 256 colors [solved]
  2007-03-29 13:01   ` Leo
@ 2007-03-29 15:17     ` Martin Karlsson
  2007-03-29 15:46       ` Leo
  0 siblings, 1 reply; 9+ messages in thread
From: Martin Karlsson @ 2007-03-29 15:17 UTC (permalink / raw)
  To: help-gnu-emacs

Leo <sdl.web@gmail.com> writes:

> Can you post a screen shot of list-colors-display? I can only see 7
> colors while display-color-cells shows 256.

Sure, have a look at <http://martink.freeshell.net/l-c-d.png>
(No color names yet though, looking into that.)

Regards,
-- 
Martin Karlsson

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: emacs -nw, xterm and 256 colors [solved]
  2007-03-29 15:17     ` Martin Karlsson
@ 2007-03-29 15:46       ` Leo
  2007-03-29 18:54         ` Martin Karlsson
       [not found]         ` <mailman.1591.1175194608.7795.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Leo @ 2007-03-29 15:46 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-03-29, Martin Karlsson said:

> Leo <sdl.web@gmail.com> writes:
>
>> Can you post a screen shot of list-colors-display? I can only see 7
>> colors while display-color-cells shows 256.
>
> Sure, have a look at <http://martink.freeshell.net/l-c-d.png>
> (No color names yet though, looking into that.)
>
> Regards,

That looks awesome. What specifically did you do to get there?

-- 
Leo <sdl.web AT gmail.com>                         (GPG Key: 9283AA3F)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: emacs -nw, xterm and 256 colors [solved]
  2007-03-29 15:46       ` Leo
@ 2007-03-29 18:54         ` Martin Karlsson
       [not found]         ` <mailman.1591.1175194608.7795.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 9+ messages in thread
From: Martin Karlsson @ 2007-03-29 18:54 UTC (permalink / raw)
  To: help-gnu-emacs

Leo wrote:

> That looks awesome. What specifically did you do to get there?

First off, most of the following explanation is me guessing, not hard
facts.

Secondly, since you're on Linux, I'm guessing your system favours
terminfo over termcap. I'm using FreeBSD, which unfortunately seems to
rely more on (the older) termcap.

In short, my terminfo.db has a valid xterm-256color entry (which I
believe is ignored by many apps), and has termcap.db entries which map
all xterms with more tha 8 colours to an xterm TERM *with* 8 colours.

In other words, when i set my TERM to xterm-256color, xterm happily
obliges since it looks in terminfo. That only gives the actual xterm
access to all those nice colours though.

Some other apps (including emacs), [again this is on FreeBSD -- may or
may not apply to linuxen] use termcap, and conlude that my xterm is only
capable of displaying 8 colours.

Having said that, the full story (meager and potentially wildly
dangerous as it may be) can be found at:
<http://martink.freeshell.net/emacs/emacs-256xterm.txt>

Good luck,
-- 
Martin Karlsson

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: emacs -nw, xterm and 256 colors [solved]
       [not found]         ` <mailman.1591.1175194608.7795.help-gnu-emacs@gnu.org>
@ 2007-03-29 21:53           ` Ilya Zakharevich
  2007-03-30 21:24             ` Martin Karlsson
  0 siblings, 1 reply; 9+ messages in thread
From: Ilya Zakharevich @ 2007-03-29 21:53 UTC (permalink / raw)
  To: help-gnu-emacs

[A complimentary Cc of this posting was sent to
Martin Karlsson 
<qsvans@gmail.com>], who wrote in article <mailman.1591.1175194608.7795.help-gnu-emacs@gnu.org>:
> In other words, when i set my TERM to xterm-256color, xterm happily
> obliges since it looks in terminfo. That only gives the actual xterm
> access to all those nice colours though.

Something is very wrong in your understanding.  xterm has no idea what
is the value of TERM in your application.  Moreover, it does not
"take" any access to colors; it PROVIDES these colors to applications
which request them.

Hope this helps,
Ilya

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: emacs -nw, xterm and 256 colors [solved]
  2007-03-29 21:53           ` Ilya Zakharevich
@ 2007-03-30 21:24             ` Martin Karlsson
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Karlsson @ 2007-03-30 21:24 UTC (permalink / raw)
  To: help-gnu-emacs

Ilya Zakharevich <nospam-abuse@ilyaz.org> writes:

> [A complimentary Cc of this posting was sent to
> Martin Karlsson 
> <qsvans@gmail.com>], who wrote in article <mailman.1591.1175194608.7795.help-gnu-emacs@gnu.org>:
>> In other words, when i set my TERM to xterm-256color, xterm happily
>> obliges since it looks in terminfo. That only gives the actual xterm
>> access to all those nice colours though.
>
> Something is very wrong in your understanding.

I'm not surprised, and that's why I began my post, from which you quote,
by saying: "First off, most of the following explanation is me guessing,
not hard facts." Apparently my guessing was way off.

> xterm has no idea what is the value of TERM in your application.
> Moreover, it does not "take" any access to colors; it PROVIDES these
> colors to applications which request them.
>
> Hope this helps,

It does. Thanks for the explanation. :)

Regards,
-- 
Martin Karlsson

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-03-30 21:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-27 14:54 emacs -nw, xterm and 256 colors Martin Karlsson
2007-03-28 15:53 ` Leo
2007-03-29 12:22 ` emacs -nw, xterm and 256 colors [solved] Martin Karlsson
2007-03-29 13:01   ` Leo
2007-03-29 15:17     ` Martin Karlsson
2007-03-29 15:46       ` Leo
2007-03-29 18:54         ` Martin Karlsson
     [not found]         ` <mailman.1591.1175194608.7795.help-gnu-emacs@gnu.org>
2007-03-29 21:53           ` Ilya Zakharevich
2007-03-30 21:24             ` Martin Karlsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).