From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Moving point around empty overlays with 'after-text Date: Mon, 10 Apr 2023 16:56:46 +0700 Message-ID: References: <9b1654ec-1ac6-4936-860b-2d77dcc4dac7@app.fastmail.com> <28954f0d-205d-b322-4a43-cf4481d1266e@gmail.com> <3a1bb709-d00f-49b8-a2c5-d0ac5b6a82c4@app.fastmail.com> <22b315db-39eb-80b6-1a7c-127f5e703dc1@gmail.com> <83o7nwl4ig.fsf@gnu.org> <571d4b51-a29f-23a6-5b29-ca5870af1c8f@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19709"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , help-gnu-emacs@gnu.org To: Platon Pronko Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 10 11:57:34 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ploHF-00050z-U0 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 10 Apr 2023 11:57:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ploGn-0002ZU-Ae; Mon, 10 Apr 2023 05:57:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ploGl-0002Yy-10 for help-gnu-emacs@gnu.org; Mon, 10 Apr 2023 05:57:03 -0400 Original-Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ploGj-0007bv-EQ; Mon, 10 Apr 2023 05:57:02 -0400 Original-Received: by mail-wm1-x32b.google.com with SMTP id eo6-20020a05600c82c600b003ee5157346cso4006655wmb.1; Mon, 10 Apr 2023 02:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681120618; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Uyp8Xu/4yKJAz/vKuSnOVctRT63lletaNNAvUflKmdw=; b=lD+ZnZ4mgQgrEJ98+DA5sTwKcfPbDc2hxMeersZpy3XzdLpl8XbeYLfXBuk8E8ygWI uyH6qwv/GQKAfvkMDtiste9x44VLJVbEsISr1kWHbeQ7yZ81iSQffOz6eLJ11CZ7Gbzn HM5JtrP+VrQzLrQO1TkQGjYqpAlKDf0DwAlvzG6yH2Ll+1JilNPBUMEn6zTtoqiabybU RhRXbtzmlRpb0koh+Du1jtAdmOK8D8gp8+2K4cVmOYrrZPOu5x/Asz+pLgTfyMPDqN5l NQYn6E38/lJFxRBDqmEgB2Wc2hBMaiCbtun7gx+omb12ANwfpqXHLVtfR3rsh0EVM15M MngA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681120618; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uyp8Xu/4yKJAz/vKuSnOVctRT63lletaNNAvUflKmdw=; b=FLgc7Xyr+vOAIZHxle19TTlVJO5wsMCNxFU4VbKzDno0+fSAWIekoLQZVsmcr1a9/r v/to5RdGd65QfJM7RHWZXxR0lBmM/ZpuOO4XweT9uetw8j6GGSgjUT9C7u/MkRH8Gl1B GzxnN2jplJDPXhXLcQ+YzG52+SXu+9AxHTwajVYKZmKVng2wIa67mB7Vm+uLhC3s1R9h f6nQjst071MZQ7CmV2VOae480qiw97rZ+IN3ToxOYq16oZFP/iSGSleH6faW2USJEk0N msKzsq+dLpeDXwFpipfdlPijuYPtie+t+OBXsW5RIDHvFwYc2X9yRvWj6/cOrosBBfDN hLsQ== X-Gm-Message-State: AAQBX9eqUuvctJwoJz0Gs2Xk0UZf4Sb+kiPSvrfV1rD+5cc4hyCu2dW8 oiLjo0cq8vtNVjaMJDYj1nqXWvE5jv0urbqI0iaiamk0DU94L5os X-Google-Smtp-Source: AKy350ZdMrzGJwX3dvRrrV4xJnHLj1nx00dTat2gD8HJkbK8g8H+ygJK83k0feXEOB4R3QCC+8Dk0oGQHCChAq+eG7M= X-Received: by 2002:a7b:c8cb:0:b0:3ed:4e6d:ac13 with SMTP id f11-20020a7bc8cb000000b003ed4e6dac13mr2024047wml.1.1681120618262; Mon, 10 Apr 2023 02:56:58 -0700 (PDT) In-Reply-To: <571d4b51-a29f-23a6-5b29-ca5870af1c8f@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=yurivkhan@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143250 Archived-At: On Mon, 10 Apr 2023 at 12:23, Platon Pronko wrote= : > I'll try to do it with bunch of attached images, since it feels that it w= ill be easier to explain. If it's better to use text examples, please tell = me, I'll try to reformat them. > > The base example is in inlay-base.png image - you can see the inline hint= on the second line ("a1 =3D"). > > I can position the cursor right before the inline hint (inlay-cursor-befo= re.png), type "41, ", thus adding a new argument before existing one (inlay= -cursor-before-result.png). You=E2=80=99re talking about typing =E2=80=9C41, =E2=80=9D as if it were an= atomic action. In some cases (e.g. pasting from clipboard) it could be, but normally you=E2=80=99ll be inserting characters one by one, and it might be instruct= ive to look at the buffer contents and expected inlay behavior through the intermediate stages. 0. Base state: def test(a1: Int =3D 1, a2: Int =3D 2, a3: Int =3D 3) {} test({a1=3D}42) 1. You type =E2=80=9C4=E2=80=9D. Depending on how the editor interprets the= insertion around the inlay: 1a. The editor inserts the digit 4 at the position where the inlay is. The text is now =E2=80=9Ctest(442)=E2=80=9D. Syntactically, you just change= d the argument value, so the inlay should stay before the newly inserted character. def test(a1: Int =3D 1, a2: Int =3D 2, a3: Int =3D 3) {} test({a1=3D}42) 1b. The editor lets you insert the digit 4 before the inlay and somehow knows it is separate from the =E2=80=9C42=E2=80=9D that used to be = the first argument. The text is now =E2=80=9Ctest(4=E2=96=8842)=E2=80=9D where the bl= ock represents some kind of separator. Likely, this text is invalid syntax, so the inlay is now technically incorrect. def test(a1: Int =3D 1, a2: Int =3D 2, a3: Int =3D 3) {} test(4=E2=96=88a1=3D=E2=96=8842) 2. You type =E2=80=9C1=E2=80=9D. Same thing as =E2=80=9C4=E2=80=9D before, = only in case 2a the insertion is no longer adjacent to the inlay so the issue does not even arise. In case 2b, you now have =E2=80=9Ctest(41=E2=96=8842)=E2=80=9D = in the buffer and =E2=80=9Ctest(41=E2=96=88a1=3D=E2=96=8842)=E2=80=9D in the view. 3. You type =E2=80=9C,=E2=80=9D. 3a. The text is now =E2=80=9Ctest(41,42)=E2=80=9D and syntactically it=E2= =80=99s a call with two arguments. The inlay for the first argument stays right after the opening paren; a new inlay appears after the comma and before the 42. 3b. The text is now syntactically well-formed, so the IDE can update the in= lays. def test(a1: Int =3D 1, a2: Int =3D 2, a3: Int =3D 3) {} test({a1=3D}41,{a2=3D}42) 4. You type a space. For typographical reasons, a well-designed grammar will infer the space to belong to the separator, not the argument expression. The inlay will shift after the space. def test(a1: Int =3D 1, a2: Int =3D 2, a3: Int =3D 3) {} test({a1=3D}41, {a2=3D}42) Basically, after working out the above, my question is: Why is it important to let the user choose whether to insert newly typed characters before or after the inlay, if the inlay is going to be updated and repositioned based on the resulting buffer text? Alternatively, why is it important to let the user bring the buffer into an invalid state that may even be unrepresentable in text?