On Aug 5, 2023, at 3:03 PM, Eli Zaretskii <eliz@gnu.org> wrote:
tags 65105 notabugthanksFrom: JD Smith <jdtsmith@gmail.com> Date: Sat, 5 Aug 2023 14:35:23 -0400
Evaluate:
(let ((s1 "test1") (s2 "test2")) (insert "\n" (propertize " " 'display s1) (propertize " " 'display s1) (propertize " " 'display s2) (propertize " " 'display s1)))
The first space display does not take effect, since the s1 string is used for two consecutive characters. This has a practical impact for font-lock backends that use the ‘display text-property and would like to minimize string allocation.
Emacs cannot distinguish between two consecutive characters havingeach a text property with the same value, and two characters havingthe same property. If you think about this for a moment, you willunderstand why: we use intervals for text properties, so two adjacentintervals with the identical property values and one interval withthat same value are indistinguishable (and in fact Emacs optimizesthis during GC by making just one interval from these two).This is not a bug.
Aha, thanks. It does make sense from an optimization standpoint to “gang” properties in this manner. Are you aware of any approach that allow re-using a string for ‘display, but permits consecutive intervals to remain distinct? |