Is there a way to add text properties to empty strings? As far as I can tell, calling
put-text-property on an empty string silently does nothing. I seem to recall reading somewhere that the empty string is (at least potentially) a singleton, so perhaps this is why it doesn't work.
This may seem like a perverse thing to want to do since a text property that doesn't apply to any text is pretty useless. I'm working on a company-mode backend that – for reasons which aren't really important to this question – needs to remember where the completion prefix starts. This is easy to calculate, and after doing so I stash the offset as a text property on the prefix.
However, a prefix can, in some very important cases, be blank. Since I can't add properties to an empty prefix, I'm stuck checking whether the property is blank in lots of places. Hence, my initial question.
If it's not possible to add text properties to blank strings, is there some other way I could transparently associate extra data with the empty prefix string? I know some lisps allow you to tack meta data onto objects, so perhaps there's something like this in elisp. Any ideas would be greatly appreciated.