emacshighlightemacs-faces

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


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.


Solution

  • 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.)