简体   繁体   中英

emacs ansi-term background color

I'm having a problem changing the background color in ansi-term (and also term - but shell is fine). It displays colors fine from output but the background color of the out put is always white. Not the entire buffer, but just under actual characters that have been outputted. If I do something like

(add-hook 'ansi-term-mode-hook
    (lambda ()
        (set-background-color "purple")))

This changes the buffer's background color, but the output just overrides it with its own background color - white.

I've also tried to find the face that it is using so I can customize it by doing Cu Cx = to get the info on the face at the point -- which works for everything else and even points you where to change it which is nice... but in ansi term i get this

    character: m (109, #o155, #x6d)
preferred charset: ascii (ASCII (ISO646 IRV))
   code point: 0x6D
       syntax: w    which means: word
     category: .:Base, a:ASCII, l:Latin, r:Roman
  buffer code: #x6D
    file code: #x6D (encoded by coding system utf-8)
      display: by this font (glyph code)
xft:-unknown-DejaVu Sans Mono-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1 (#x50)

Character code properties: customize what to show
  name: LATIN SMALL LETTER M
  general-category: Ll (Letter, Lowercase)

There are text properties here:
  face                 (:background "white" :foreground "black")

[back]

I don't know where this is getting set.

Also, I've used multiple themes that I know have the ansi-term-color-vector (zenburn, etc). I've gone through every sample in customize-face and its no where in there either.

Any thoughts on how to override/set this so it's just the transparent (or unset) background like everything else?

Thanks for any help.

I'm not sure if I understand what's going on in your setup but you can try setting:

(setq term-default-bg-color "#211E1E")
(setq term-default-fg-color "#AAAAAA")

Try it from scratch buffer start a new term and check.

user178399's reply was entirely correct 10 years ago. As of v24.3, this pair of variables has been deprecated in favor of customizing the term face. In fact, in Emacs 25.6 (Debian 10 distro, x64), setting these variables no longer has any effect whatsoever, while changing the face does.

If (or rather when, as the variables are already broken, at least here), do not forget to remove their settings from your init file (usually ~/.emacs ) or reset their customization.

Just a heads-up, in case you are searching why the default fore/background settings suddenly turned angry and insubordinate upon you after an upgrade...

What puzzles me is that I still have to change the background of the ansi-term buffer in a hook to match that of the term face, just like the OP did 10 years back, lest I get this. Lose, lose!

在此处输入图片说明

Oh, and there is Emacs.SE now, a much better targeted place for Emacs-related questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM