> On Jan 6, 2024, at 9:27 AM, Eli Zaretskii wrote: > > I do know that, like the proverbial wisdom of "640KB should be enough for everyone", any > assumptions in Emacs that some feature will be used only "a little" > eventually becomes false. We have ample examples Point taken. That said, I think my “at most a doubling” is a robust estimate, since it makes no sense to remap more face regions than there are in the buffer. But never underestimate the intrepid elisp programmer I suppose... > I cannot be of more help here without understanding better what kinds > of application-level features you want to support. Until now, you > only described that in very general terms. This is because I was discussing a general feature that would be useful for more than my own application. To make it more concrete, what I had in mind is an update to indent-bars which would changes the appearance of the set of bars in a “scope” region via treesitter queries in a post-command hook. As point changes, the TS “enclosing scope” is calculated, and if it has changed, all the existing indent bars in that region would be updated with “alternate” styling (and formerly highlighted text would be returned to normal styling). See [1] for some images to give you the idea of how the normal styling can look. Important to note are that: Bar styling can depend on indentation depth, so in most cases # faces = # indent levels. ‘display properties with ‘face propertized text are used to add bars to blank lines (or insufficiently long empty lines), and to properly handle tabs (when indent-tabs-mode=t). > It could be a buffer-local variable, which defines the size of the > region around point where the faces should change their appearance, > and how to change the appearance. The display engine then could take > that into consideration when processing buffer positions around point. > > Whether this makes sense depends on the applications you have in mind. Since there are many small stretches of text (single character stretches) that would be impacted over a larger region, I’m afraid such a simple approach wouldn’t work. >> In the world of CSS, you’d do this quite simply by (say) updating the class of the div which wraps your >> text of interest, and having special styling for, e.g., "alternate bold" and "alternate italic”, which is only >> activated when the “alternate” class is applied: >> >>
>> >> This is some italic text and some bold text. This is unrelated text. >> >>
>> >> In CSS >> >> .alternate b {...} >> .alternate i {…} >> >> (In JS later:) >> >> myDiv.classList.add('alternate'); > > You are describing how to specify the effect, whereas I'm bothered by > the implementation which could support that. Faces in Emacs are > specific to the entire frame, and we have face-remapping to change > that within limits buffer-locally. We don't currently have any > infrastructure that allows the faces to change on a finer resolution, > except if the Lisp program modifies the 'face' text properties or > defines overlays with 'face' properties. I understand. The question is whether it would be desirable, tractable, performant, and maintainable to add any such infrastructure. Thanks for your thoughts and analysis. [1] https://github.com/jdtsmith/indent-bars/blob/main/examples.md