reddit / emacs

Possible to add visual indicator above characters

ireallywantfreedom · 2022-05-28 14:08
I'm trying to add an indicator on top of various characters in the buffer. The indicators are stored as SVG's and I'm using GUI Emacs. I've read through the overlay and faces documentation (a few times) and I'm still uncertain if what I want is possible since I'm looking to combine a character and an image in one space. To be clear, I'm looking to add indicators like [such](https://imgur.com/qcZA7Qp) - while allowing me to dynamically color the indicators. Is anyone familiar with existing packages that combine images and text like this? Or whether or not this is even possible directly via elisp?
wasamasa · 2022-05-28 15:22
The problem with images is that they're treated like a chunk of text places on a line of other text (there is no way to layer them on top of existing text). The best you can do is replace the text with a SVG image that uses fonts to render text. Examples: - https://github.com/sabof/svg-mode-line-themes - https://github.com/ocodo/ocodo-svg-modelines - https://github.com/rougier/svg-tag-mode
ireallywantfreedom · 2022-05-28 19:56
This is interesting, thanks for this. One problem I can see is that other tools like flyspell would (rightly) treat this as an image instead of a character. I don't imagine there's any way around that? Edit: on second thought it seems like this would break pretty much everything. Hrm. I wonder if creating a custom font is my only way out.
7890yuiop · 2022-05-28 23:30
If you're just *displaying* text as an image, any code looking at the buffer text will see the actual buffer text, not an image.
eli-zaretskii · 2022-05-29 10:21
The "Emacsy" way of making portions of text stand out is to give them non-default faces: colors, size and/or style of font, underline, etc.
paretoOptimalDev · 2022-05-30 13:33
I'm pretty sure the OP wants this for voice coding so a red dot ("hat") over letter a can be referenced with the spoken words "red (a)ir". Like the gif example in: https://marketplace.visualstudio.com/items?itemName=pokey.cursorless I suppose you could make a very thick overline to get this affect? It's worth noting these dots are all over the buffer to be used like avy jumping that is always on. Not sure if this changes anything about your recommendation, just thought i'd add context.