9

I tried to set the foreground color of the cursor face, but it does not seem to work. Setting the background color works fine, but setting the foreground color does not have any effect.

I would like Emacs to act in the same way as my terminal. When I move the cursor over the text the foreground color does not change.

enter image description here

When I do the same in Emacs the foreground color becomes white.

enter image description here

How can I stop Emacs inverting the text at the cursor?

5

Nope. M-x customize-option cursor shows you the doc string:

Basic face for the cursor color under X. Hide Currently, only the :background attribute is meaningful; all other attributes are ignored. The cursor foreground color is taken from the background color of the underlying text.

Note the last sentence.

Consider filing an enhancement request: M-x report-emacs-bug.

| improve this answer | |
  • 2
    Uff. The inconceivable happened: I found something Emacs can not do. ;-) – ceving Dec 5 '15 at 10:12
  • 1
    There are an infinite number of things that the Emacs design or implementation does not immediately support. M-x report-emacs-bug to suggest enhancements. – Drew Dec 5 '15 at 16:01
  • 2
    Still not possible? – rien333 Mar 14 '19 at 17:51
0

A workaround could be to change the cursor shape via the cursor-type, for example:

(setq cursor-type 'hollow)
(setq cursor-type 'bar)
(setq cursor-type 'hbar)

I know, it's a brutal change, but at least the foreground color is preserved.

| improve this answer | |
  • I tried customizing cursor-type but it did not change anything to the problem. Could you please elaborate on this workaround? – Giuseppe Sep 27 at 8:54
  • By using a hollow cursor type you simply see through it so Emacs won't change the foreground color of the area in the middle. – cYrus Sep 27 at 9:32
0

You could change the face (colour style) that is hard to read:

:distant-foreground

Alternative foreground color, a string. This is like :foreground but the color is only used as a foreground when the background color is near to the foreground that would have been used. This is useful for example when marking text (i.e., the region face). If the text has a foreground that is visible with the region face, that foreground is used. If the foreground is near the region face background, :distant-foreground is used instead so the text is readable.

from face-attributes

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.