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

From: Eli Zaretskii <[email-masked]>
Date: Mon, 02 May 2022 19:24:10 +0300

> From: Stefan Monnier <[email-masked]>
> Cc: Lars Ingebrigtsen <[email-masked]>,  [email-masked],
>   [email-masked]
> Date: Mon, 02 May 2022 12:01:18 -0400
> 
> Eli Zaretskii [2022-05-01 15:17:10] wrote:
> > I don't understand how can completion work in general without
> > destructively modifying strings.
> 
> The completion API (i.e. between the UI code and the completion backend)
> is basically functional: the backend is a function that can operate
> without any side effects.
> 
> The only thing that may occasionally need to be "modified" is the buffer
> that the user is editing (most often it's a minibuffer).
> 
> Why would the completion UI ever need to modify any of the data that
> belongs to the completion backend?  Or are you thinking of some other
> form of "modifiying"?  Or other strings?

I have no idea.  The way you present this is waaay above my level of
understanding.

Completion takes text typed by the user and produces strings that the
user could possibly mean by typing what he/she typed.  Some part(s) of
the candidates can legitimately come from what the user typed, some
other part(s) could be invented by the completion machinery more or
less out of thin air.  Why should anyone expect this meat-grinder to
refrain from destructively modifying any of the involved strings?