Thanks for that explanation. Indeed, I found it hard to find a thorough
explanation anywhere. Also, thanks for reminding me about propertize.


On Thu, 23 Feb 2023 at 19:36, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Indeed, I assumed that I was creating new strings because (eq " " " ")
> is nil.

Your test can return nil even if new strings aren't created at runtime
(e.g. because each source code string gets its own runtime string).

It may be nil in your test, but it may also return t (I think if you
byte-compile your test it will return t).

>> >         (let ((s " "))

Here you have a single " " string in your source code.  And no it's not
recreated each time, it will be the same one reused everytime (and
modified by `put-text-property`).

You can use `propertize` instead.


        Stefan