Subject: Re: bug#55205: 28.1.50; completion--replace illegally mutates completion candidates

From: Daniel Mendler <[email-masked]>
Date: Mon, 2 May 2022 18:48:47 +0200

On 5/2/22 18:43, Eli Zaretskii wrote:
> I have no doubt that in most cases there's no modification of the
> original strings.  However, AFAIU the discussion was about not letting
> that happen, ever, and that I cannot understand.
> 
> IOW, I'm saying that people who want to see all the strings immutable,
> all the time, have wrong expectations _in_principle_, even though in
> most cases they will probably get what they want.

I agree with you that one shouldn't have wrong expectations about
mutation of string properties in Emacs general.

But in this case, having the expectation is justified and it is also
realized throughout completion. The bug report I linked originally
essentially shows that if you use completion with a propertized string
it is not possible to restore the original text metadata by looking up
the text property, since it got destroyed in the process.

I am not only taking about the default Completions buffer UI, but also
about all kinds of other completion UIs (Icomplete and third-party
packages). These UIs all respect the immutability of completion
candidates. It is better to not weaken this contract, since it makes
things much easier to reason about.

Daniel