elisp-tree-sitter
elisp-tree-sitter copied to clipboard
Faces: the inherit from default is problematic in some cases. Does it have benefits?
Hi - two faces have :inherit default
which causes them to render badly if the background is other than the default.
-
tree-sitter-hl-face:embedded
-
tree-sitter-hl-face:punctuation
E.g. in org-mode
source blocks, as is probably quite common, I highlight source blocks with a different background color:
If I customize away the inherit it becomes:
(Note the spacing got slightly messed by it too)
There may be some problem the :inherit default
fixes, but I feel like it would be better if they weren't there(?).
The embedded
face is for things like string interpolation, where :inherit default
is intended to "reset" the background.
I don't remember why punctuation
also has it though. Maybe it was an oversight.
The messed spacing is probably due to your org-block
and default
faces having different sizes.
This is happening for me without tree-sitter-hl-mode
ever being called, which in itself feels problematic. I have to not load tree-sitter to prevent it from happening.
Even if these punctuation faces are important, they should not be applied outside of the applicable mode(s)
Edit: Ok these are likely being enabled in the background with the use of a temporary buffer that captures the syntax highlighting. If your org-mode background for codeblocks deviates from the source-code background, you get these weird highlighting errors.
I have some problems when I use variable-pitch-mode
in the org mode and fixed-pitch-mode
in the blocks. I set "EB Garamond" for variable-pitch and "Fira Code" for fixed-pitch. The brackets and delimiters use the "EB Garamond" fonts instead of "Fira Code", while others are right. I found these two faces inherit from "default" while others are not.

How can I solve this?