Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify face under cursor in Emacs, including on ansi-term

Is there a way to easily modify the font-face under cursor?

For example, the text in blue below is hard to read:

                           enter image description here

The above is the output of

ipython --color "Linux"

running on an ansi-term with tango-dark in Emacs 24.1, i.e. (load-theme 'tango-dark t)

If I run what-cursor-position on the image above (described here: Get font face under cursor in Emacs), I get:

             position: 30385 of 30477 (100%), column: 22
            character: / (displayed as /) (codepoint 47, #o57, #x2f)
    preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x2F
               syntax: _    which means: symbol
             category: .:Base, a:ASCII, l:Latin, r:Roman
          buffer code: #x2F
            file code: #x2F (encoded by coding system nil)
              display: by this font (glyph code)
    xft:-unknown-DejaVu LGC Sans Mono-bold-normal-normal-*-11-*-*-*-m-0-iso10646-1 (#x12)

Character code properties: customize what to show
  name: SOLIDUS
  old-name: SLASH
  general-category: Po (Punctuation, Other)
  decomposition: (47) ('/')

There are text properties here:
  face                 (:weight bold :foreground "blue2" :background unspecified)

How can I modify this font?

In case you are wondering IPython only supports three color sets:

  • Nocolor
  • Linux (the one I am using above)
  • LightBG (for light backgrounds)

Update:

I think font-lock-string-face is a different face:

                        enter image description here

In fact, I think that's not the face that IPython uses to represent strings, but the face that python-mode uses to represent strings in a buffer with regular python code (in tango-dark) -- see below --.

                                          enter image description here

like image 717
Amelio Vazquez-Reina Avatar asked Dec 20 '25 02:12

Amelio Vazquez-Reina


2 Answers

M-x customize-face with your cursor over the particular thing you want to modify. Also available are set-face-foreground and set-face-background depending on what you want to do (sometimes it's good to change the backing color to make the font easier to see in terminals).

So I checked out IPython as mentioned in my comment below and ipython.el does no highlighting of its own. The coloring is all done by using terminal ANSI colors. It's possible in some terminals to change the colors via a .bashrc or .zshrc or whatever your shell is and running it from M-x term possibly. Through Emacs itself I cannot see a way of changing it as IPython only has 3 default schemes and no way to specify anything specific as far as I can see.

like image 145
Jesus Ramos Avatar answered Dec 21 '25 16:12

Jesus Ramos


It is possible to change the way ansi colors are shown:

(defface term-color-red
    '((t (:foreground "#ff0000" :background "#ff0000")))
  "Unhelpful docstring.")

Here is the whole bunch:

term-color-red
term-color-green
term-color-black
term-color-yellow
term-color-blue
term-color-magenta
term-color-cyan
term-color-white
like image 20
sabof Avatar answered Dec 21 '25 15:12

sabof