13

如何term在新的 Emacs 中调整面以获得与ansi-term-color-vector.

Emacs 24.3中的新特性之一似乎是它改进了控制term缓冲区面的机制,即:

变量term-default-fg-colorterm-default-bg-color现在已弃用,取而代之的是可定制的 face term

term-color-COLOR您可以通过自定义相应的,term-color-underlineterm-color-bold面来自定义如何显示 ANSI 终端颜色和样式。

来自 Mastering Emacs 的 Mickey评论如下

如果像我一样,您自定义ansi-color-names-vector更改默认术语颜色,我建议您现在切换到使用面孔。这里的好消息是,您可以(应该希望)更改的不仅仅是每种 ANSI 颜色的颜色:没有什么能阻止您为某些颜色强制使用不同的字体

像 Mickey 一样,我也ansi-color-names-vector用来确保term缓冲区的颜色在深色主题上看起来很好(例如tango-dark

(setq ansi-term-color-vector [unspecified “black” “red3” “lime green” “yellow3” “DeepSkyBlue?3” “magenta3” “cyan3” “white”])

但这现在会导致错误:

"error in process filter: Invalid face; unspecified" 

为了尝试使用新面孔term,当我转到 时M-x describe-face term,我看到以下内容:

[] Font Family
[] Font Foundry
[] Width
[] Height
[] Weight
[] Slant
[] Underline
[] Overline
[] Strike-through
[] Box around text
[] Inverse-video
[] Foreground
[] Background
[] Stipple
[x]  Inherit

但是如何调整这些设置以获得与使用相同的效果ansi-term-color-vector

更新

我仍然无法修复颜色。这是我得到的菜单M-x customize-theme tango-dark

在此处输入图像描述

这是终端中难以看到的颜色/面之一的示例:

                              在此处输入图像描述

4

3 回答 3

10

这在 Emacs 24.3.1 中对我有用,可以设置 term 和 ansi-term 的颜色。只需将颜色更改为您喜欢的值(相应调整背景)。

;; term
(defface term-color-black 
  '((t (:foreground "#3f3f3f" :background "#272822"))) 
  "Unhelpful docstring.")
(defface term-color-red
  '((t (:foreground "#cc9393" :background "#272822"))) 
  "Unhelpful docstring.")
(defface term-color-green
  '((t (:foreground "#7f9f7f" :background "#272822"))) 
  "Unhelpful docstring.")
(defface term-color-yellow
  '((t (:foreground "#f0dfaf" :background "#272822"))) 
  "Unhelpful docstring.")
(defface term-color-blue 
  '((t (:foreground "#6d85ba" :background "#272822"))) 
  "Unhelpful docstring.")
(defface term-color-magenta 
  '((t (:foreground "#dc8cc3" :background "#272822"))) 
  "Unhelpful docstring.")
(defface term-color-cyan
  '((t (:foreground "#93e0e3" :background "#272822"))) 
  "Unhelpful docstring.")
(defface term-color-white
  '((t (:foreground "#dcdccc" :background "#272822"))) 
  "Unhelpful docstring.")
'(term-default-fg-color ((t (:inherit term-color-white))))
'(term-default-bg-color ((t (:inherit term-color-black))))

;; ansi-term colors
(setq ansi-term-color-vector
  [term term-color-black term-color-red term-color-green term-color-yellow 
    term-color-blue term-color-magenta term-color-cyan term-color-white])
于 2013-08-02T23:54:32.913 回答
5

在 Emacs 24.3 中,您需要调整以下面:

   ;; term
   `(term-color-black ((t (:foreground ,zenburn-bg
                                       :background ,zenburn-bg-1))))
   `(term-color-red ((t (:foreground ,zenburn-red-2
                                       :background ,zenburn-red-4))))
   `(term-color-green ((t (:foreground ,zenburn-green
                                       :background ,zenburn-green+2))))
   `(term-color-yellow ((t (:foreground ,zenburn-orange
                                       :background ,zenburn-yellow))))
   `(term-color-blue ((t (:foreground ,zenburn-blue-1
                                      :background ,zenburn-blue-4))))
   `(term-color-magenta ((t (:foreground ,zenburn-magenta
                                         :background ,zenburn-red))))
   `(term-color-cyan ((t (:foreground ,zenburn-cyan
                                       :background ,zenburn-blue))))
   `(term-color-white ((t (:foreground ,zenburn-fg
                                       :background ,zenburn-fg-1))))
   '(term-default-fg-color ((t (:inherit term-color-white))))
   '(term-default-bg-color ((t (:inherit term-color-black))))

此代码来自Zenburn的最新版本。个人觉得自定义人脸的新方法是对使用模糊向量的改进。

于 2013-03-27T15:06:41.397 回答
3

我建议M-x customize-group RET term RET
作为定制这些颜色的最简单的切入点。

于 2014-09-17T08:33:01.300 回答