all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Foreground color opacity
@ 2023-09-11 10:45 Filippo Argiolas
  2023-09-11 12:58 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Filippo Argiolas @ 2023-09-11 10:45 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-09-12  5:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-11 10:45 Foreground color opacity Filippo Argiolas
2023-09-11 12:58 ` Eli Zaretskii
2023-09-11 13:09   ` Filippo Argiolas
2023-09-11 14:04     ` Eli Zaretskii
2023-09-11 14:58       ` [External] : " Drew Adams
2023-09-11 16:08         ` Filippo Argiolas
2023-09-11 16:25       ` Filippo Argiolas
2023-09-11 16:56         ` Eli Zaretskii
2023-09-11 19:00           ` Filippo Argiolas
2023-09-12  2:21             ` Eli Zaretskii
2023-09-12  4:55               ` Filippo Argiolas
2023-09-12  5:24                 ` Filippo Argiolas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.