Adjusting term faces in the new Emacs 24.3

2019-01-18 23:05发布

How can I adjust the term face in the new Emacs to get the same control that was possible with ansi-term-color-vector?

One of the new features in Emacs 24.3 seems to be that it revamps the mechanism to control the face of term buffers, i.e.:

The variables term-default-fg-color and term-default-bg-color are now deprecated in favor of the customizable face term.

You can customize how to display ANSI terminal colors and styles by customizing the corresponding term-color-COLOR, term-color-underline and term-color-bold faces.

Mickey from Mastering Emacs comments the following:

If, like me, you customized ansi-color-names-vector to change the default term colours I suggest you switch to using the faces now. The good news here is you can, should desire to, change more than just the colours for each ANSI Color: there’s nothing stopping you from forcing a different font for certain colours

Like Mickey, I was also using ansi-color-names-vector to make sure that the color of my term buffers looked well on dark themes (e.g. tango-dark)

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

But this now results in an error:

"error in process filter: Invalid face; unspecified" 

In an attempt to use the new face term, when I go to M-x describe-face term, I see the following:

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

But how do I adjust these settings to get the same effect I achieved using ansi-term-color-vector?

Update

I am still unable to fix the colors. Here is the menu that I get for M-x customize-theme tango-dark:

enter image description here

And here is an example of one of the colors/faces in a terminal that are hard to see:

                              enter image description here

3条回答
狗以群分
2楼-- · 2019-01-18 23:17

I would suggest M-x customize-group RET term RET
as the easiest entry point to customizing those colours.

查看更多
老娘就宠你
3楼-- · 2019-01-18 23:26

This worked for me in Emacs 24.3.1 to set the colors of term and ansi-term. Just change the colors to your preferred values (with the background adjusted accordingly).

;; 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])
查看更多
forever°为你锁心
4楼-- · 2019-01-18 23:37

In Emacs 24.3 you'll need to adjust the following faces:

   ;; 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))))

This code is from the latest version of Zenburn. Personally I feel that the new way of customising the faces is an improvement over the use of the obscure vector.

查看更多
登录 后发表回答