all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Filippo Argiolas <filippo.argiolas@gmail.com>
To: emacs-devel@gnu.org
Subject: Foreground color opacity
Date: Mon, 11 Sep 2023 12:45:04 +0200	[thread overview]
Message-ID: <CAOdrLGL0JWxANi=7tY1D+dAYT8t5EcSZmbM4KYw0uXJKYSWGUQ@mail.gmail.com> (raw)

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	other threads:[~2023-09-11 10:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 10:45 Filippo Argiolas [this message]
2023-09-11 12:58 ` Foreground color opacity 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOdrLGL0JWxANi=7tY1D+dAYT8t5EcSZmbM4KYw0uXJKYSWGUQ@mail.gmail.com' \
    --to=filippo.argiolas@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.