emacs: how to change the foreground color of highlights (e.g., links the point is over)?

StackOverflow https://stackoverflow.com/questions/8662070

  •  08-04-2021
  •  | 
  •  

Frage

I have a color theme file (similar to gruber-darker.el) and I would like to adjust a specific color. This color can be described as follows: Change to Org Agenda (the org-mode agenda buffer) via M-x org-agenda a. Then move the cursor over a Scheduled TODO item (this is a link to the corresponding entry in your agenda file). When the cursor is over such an item, you see the item in highlighted form with a background color and a foreground color. The background color is fine, however, the foreground color is white. I would like to adjust this foreground color to something like :foreground nil so that it is not white anymore; instead, the natural color of the item the cursor is on is inherited. I normally use M-x describe-face RET to figure out what the element is that I have to change. However, this does not work here since I only get the colors/element names of the item the cursors is on.

Update 1: I just realized that I get the same behavior for all links in emacs (not only in org-mode). I found out that (highlight ((t (:background "#453D41")))) gives me a brown background bar as highlighted region. But once the cursor is over the highlighted region, I get a white foreground color instead of the original color. Even (highlight ((t (:background "#453D41" :foreground nil)))) does not give me the original color of the item the cursor is on. How can I achieve that?

Update 2: I figured out that (highlight ((t (:foreground "#000000" :background "#453D41")))) indeed gives a black foreground color instead of white. But I don't know how to get the "inherited" foreground color of the item the cursor is on.

War es hilfreich?

Lösung

What you have discovered is that it cannot be done. For one thing, the mouse-face text property is independent of the face property. For another, face attributes are defined statically; they cannot be inherited dynamically.

Consider filing an Emacs enhancement request for such a capability (it is not limited to highlight or to mouse-face etc.), using M-x report-emacs-bug. (Yes, that command is for enhancement requests also.)

Andere Tipps

Try using describe-char instead of describe-face. That should give you more information about the various faces in use.

Interactively the function uses the character at point but you can also pass it a position, so if you find that placing the cursor on the character in question is a problem (e.g. it changes the highlighting to something else), you can do something like this:

  1. Move point to a non-conflicting position nearby (let's say 3 characters prior to the character you're interested in).
  2. M-: (describe-char (+ 3 (point))) RET
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top