emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Foreground color opacity


From: Filippo Argiolas
Subject: Foreground color opacity
Date: Mon, 11 Sep 2023 12:45:04 +0200

After the discussion in bug#65418 (Eglot: support clangd
inactiveRegions extension) I wrote a little package starting from João
example code about extending Eglot.

It's little more than an experiment at this point, you can find it at:
https://github.com/fargiolas/clangd-inactive-regions

Long story short clangd introduced a protocol extension in version 17
that signals inactive code (e.g. code under ifdefs) to the editor with
a server notification. Eglot can be easily extended to listen to these
notification and highlight inactive code.

The initial idea was to just use `shadow' face to render inactive
code. But in my opinion a much better solution is to render inactive
code as semi-transparent so that it blends with the background but
still gets syntax highlighting. See the screenshot in github for an
example, other editors have similar UIs for inactive code regions.

My approach so far has been something like this:
- label inactive regions with a dedicated text property
- add a function that runs after fontify-lock-fontify-region-function
(after so we run when we have fortified text with font lock faces)
- inside the fontify function detect face changes in the inactive
region and for each different face encountered apply a new one with
foreground color computed blending current foreground and background

It seems to work so far and I like the result, but I keep thinking
it's overly complicated for something so simple as setting text
opacity. I'm pretty new to emacs lisp, am I missing a face attribute I
can just set in an overlay and get the same result? Wouldn't it make
sense to have something like this at backend level if it doesn't exist
yet?

Thanks,
Filippo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]