emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: region-based face-remapping


From: Dmitry Gutov
Subject: Re: region-based face-remapping
Date: Sun, 7 Jan 2024 05:41:15 +0200
User-agent: Mozilla Thunderbird

On 06/01/2024 15:53, JD Smith wrote:
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:

    <div class=“normal”>

        This is <i>some italic text</i> and <b>some bold</b> text.  This
        is unrelated text.

    </div>


    In CSS

        .alternate b {...}
        .alternate i {…}

    (In JS later:)

          myDiv.classList.add('alternate');

If we were to try to emulate CSS's nesting capability, perhaps we would add some new attributes which would alter the existing ones (using relative values). E.g. :background-relative and :foreground-relative, which could be used to lighten or darken the colors provided by the :background and :foreground attributes. The -relative ones could come from a separate face, but the question would be how to make sure to apply it - it would have to be the last rule in font-lock rules, to avoid forcing all other rules to use :override. Or, I don't know, if would need to be applied some other way at the end of font-lock. Main thing, it wouldn't work off an overlay.

Or a different spin, for better theme-ability: some declarative forms which allow to specify resulting attributes (colors, etc) for combinations of faces. I.e. if two faces are present together, the foreground and background should be this and that. The limitation is also like the above.

But to be able to set these faces through an overlay, or even a text property but without worrying about the application order vis-a-vis font-lock, it would probably need to be a new property. Not sure if we'd also need some new entities in its values, rather than regular faces.

Maybe the new property would specify one or several new values which would correspond to new conditions in the DISPLAY form of face definitions. But that would make defface forms incompatible with older emacsen, I guess, and it's not certain whether it would be easy enough to use for a third-party package author anyway.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]