7

Two related questions

  1. Is it possible to use opacity while theming in emacs? I mean defining theme which - for example - would add 25% of blue to the background color of elements it is applied to. Or which would make font 30% lighter.

Or, if not.

  1. Is it possible to dynamically recalculate some theme properties whenever main custom theme changes?

Background

Such a thing would be great for various „add-some-mark” modes. One case I mean specifically is flycheck-error face, which would be less invasive if it gave background slight red accent instead of underlining text.

But my main case is crosshairs mode (which combines highlighting current row and current column). I configured it to use background slightly different than default, and that created nice subtle indication of cursor location. But once I started switching themes more often, it turned out to be nuisance, as proper color depends on current background.

Mekk
  • 1,017
  • 7
  • 14
  • Here is an idea: The functions `gamgrid-color` and `gamegrid-colorize-glyph` within `gamegrid.el` is a combined example where shading can be used to create different levels of coloring -- e.g., the shades used *0.6* or *0.8* or *1.0* (full color). The color one desires to change within a theme can be done programmatically by converting the color to a 3-element vector using the function `color-name-to-rgb` from `color.el`. The function `face-remap-add-relative` can be used to make a particular face buffer-local: http://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Remapping.html – lawlist Mar 04 '15 at 18:19
  • On certain operating systems, the cross-hairs mode can be made to use a `vline-style` of `'compose` [use composit char] or `'mixed` [use face and composit char] to create a vertical strike-through effect. The default value is `'face`. The `vline-style` options of `'compose` and `'mixed` work out of the box on Windows, but do not work out of the box on OSX. The vertical strike-through effect with `'compose` does not use a face, and that would perhaps resolve your issue with background coloring interfering with seeing the vertical line. – lawlist Mar 04 '15 at 18:28

1 Answers1

2

I finally found more-or-less satisfactory solution myself. Still, not sure whether it is perfect.

1) Library hexrgb.el provides nice functions to perform actual color calculations. For example:

(hexrgb-increment-green (face-background 'default) 2 20)

calculates color which is a bit more green than current background (in params above, 2 is how many digits each color has and 20 is relative change).

2) Then I adviced load-theme (as I write this it struck me that this is not the good place and some lower level API - enable-theme or sth even deeper - could be better) to change various attributes of hl-line and col-highlight faces after theme changed (I had to set actual color, but also to clear :inherit).

Mekk
  • 1,017
  • 7
  • 14