4

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.

Drew
  • 29,895
  • 7
  • 74
  • 104
Marius Hofert
  • 6,546
  • 10
  • 48
  • 102

3 Answers3

2

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
phils
  • 71,335
  • 11
  • 153
  • 198
  • Dear phils, thanks, that's interesting. As I noted above in the updates, I *know* that it's the `highlight` face that determines the color, it's just that I don't know how to adjust the `foreground` color of the `highlight`-entry so that it uses the actual color the item has originally. I can change it to "always black" (with the above command) or "always blue", but I can't adjust it so that it takes the color of the underlying text (I thought that `:foreground nil` should work but it does not) – Marius Hofert Dec 30 '11 at 12:57
1

By using M-x customize-face, I could not define a background color only for the highlight face without making the foreground color conflict with my theme font-lock.

However, I managed to define an inherited foreground color for the highlight face by defining the highlight face custom before loading my emacs theme.

I use dracula-theme and below you will find an example of the very first lines of my init.el file, that solve this precise need.

(custom-set-faces
 '(highlight ((t (:background "#222222" :foreground nil))))

;; Setting personal theme
(unless (package-installed-p 'dracula-theme)
  (package-install 'dracula-theme))

(load-theme 'dracula t)

I restarted the emacs instance (in my case the daemon) to apply the changes, and it finally worked.

lyderichti59
  • 344
  • 1
  • 5
0

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

Drew
  • 29,895
  • 7
  • 74
  • 104