Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 63372) by debbugs.gnu.org; 15 May 2023 20:03:50 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 15 16:03:50 2023 Received: from localhost ([127.0.0.1]:44494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pyeQA-000531-58 for submit <at> debbugs.gnu.org; Mon, 15 May 2023 16:03:50 -0400 Received: from mail-wm1-f41.google.com ([209.85.128.41]:45104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <felician.nemeth@HIDDEN>) id 1pyeQ5-00052k-FJ for 63372 <at> debbugs.gnu.org; Mon, 15 May 2023 16:03:48 -0400 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-3f42d937d2eso47340015e9.2 for <63372 <at> debbugs.gnu.org>; Mon, 15 May 2023 13:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684181019; x=1686773019; h=content-transfer-encoding:mime-version:face:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=+yQESQsziz5ojL0oSksHwN4n+uXYs62i3PI6KYm7IDA=; b=GTBlxXdc7ACQtsBOf63ayUOvxQ3ih37U3t+32RFP8I1OVyWxnyViggbJXJ/ZT7DKGN Jw9KricQpSHa/QPs/RbmkT7lpzWwDk0cr21uyF1JKzX8E5S49cSKcLoXiGafWrOBaetu DOE4JOmmH8SiEAXDlHu/hMKu1RK6fKaxiO52fcPB247hdcG248EyhC8Hxf3opHoo9lx/ Oby8tDH8vuINCkXaCVtVoQkgK3CdplZTWPJX3CHQonziDMAW/eH75Z007Z1g4vvTdvfn wD3eZfQdAgBnoEGRdRo8CMPFyXIxai4w7OU/xkF0Z840sf+TqJgaDlF720M3z1k3eUlx hg9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684181019; x=1686773019; h=content-transfer-encoding:mime-version:face:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+yQESQsziz5ojL0oSksHwN4n+uXYs62i3PI6KYm7IDA=; b=diPMoRxcLBC9PGAEZleQ25XHqOJkVduwt9xxJx5P1QhPHNJIC3+qzleFt+oHF/AfM7 fE3fIx/QZH3lcKleMfPs+47IcHvLz7fpBxPIOGXpJk862soD5f2RzRQCjLC0X9gzohL/ Pr60xMJMhwItWJ6fguRgDhekiMITVd4QUgerUg+fqRs5fVUHfcfdITDomdyTO2VAYNpZ uGR2UFJ/Lxr6aIKzCwrDDSBtNN07+dCkWPvinIkW6oHsmefm0vRiQJSoPi/ySZyqsDSF 2Oas/73/K6FXz7wa3xCBAdvQ0ItB109o3R890s5YQafLTDw5dRyipgw8aMsqhnfyspqU nulw== X-Gm-Message-State: AC+VfDwrsns9XrOfv6jukrFU8kdNbWo2OmdX0h0mgK9drqnpz3qqLFDZ qhBIv6uFPZExKH2tsYHPFyo= X-Google-Smtp-Source: ACHHUZ7d5Kc3IcmMGokVvdTGQuExV1otPxmlfJ7rQ6rF1U/g01vej4wuUcp+w6TsHVoPK90Q+y+8WA== X-Received: by 2002:a1c:7205:0:b0:3f5:176:c398 with SMTP id n5-20020a1c7205000000b003f50176c398mr5086191wmc.31.1684181019257; Mon, 15 May 2023 13:03:39 -0700 (PDT) Received: from betli.gmail.com (catv-89-134-210-182.catv.fixed.vodafone.hu. [89.134.210.182]) by smtp.gmail.com with ESMTPSA id o12-20020a1c750c000000b003f4fffccd73sm37248wmc.9.2023.05.15.13.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 13:03:38 -0700 (PDT) From: Felician Nemeth <felician.nemeth@HIDDEN> To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN> Subject: Re: bug#63372: [PATCH] Add variable: eglot-apply-text-edits-function References: <874jorc7q2.fsf@HIDDEN> <83h6sqj4ed.fsf@HIDDEN> <87354auafu.fsf@HIDDEN> <835y96j10l.fsf@HIDDEN> <87y1m2spbd.fsf@HIDDEN> <87pm7dbo41.fsf@HIDDEN> <83r0rtfv3m.fsf@HIDDEN> <87h6spbibp.fsf@HIDDEN> <83ild5fpj5.fsf@HIDDEN> <871qjqc2xj.fsf_-_@HIDDEN> <CALDnm52AKj_cm6LtcuK4h6y2KvX_8sGK1o=TUhcSNNm8bTFwMg@HIDDEN> <877ctg9dzj.fsf@HIDDEN> <CALDnm52mNTjPksGCKqnNsV0JoLWxAUXeGM2amN4S1O0JbVx2Ng@HIDDEN> Date: Mon, 15 May 2023 22:03:37 +0200 In-Reply-To: <CALDnm52mNTjPksGCKqnNsV0JoLWxAUXeGM2amN4S1O0JbVx2Ng@HIDDEN> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Thu, 11 May 2023 20:54:32 +0100") Message-ID: <87mt25746e.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEU2EgDVmFNHKAa4dz4q AwCDUSH2zWrE61tmAAACeklEQVQ4jU2UwY7jIAyGEZN5ABSFc9Ytcx6K6DmqmHsD8tyZKrz/I+xv yI6WKlHlj982tomiVckiWrUrgRU5jlqMpJKCkch5W419DQAiQGHDxdrWmm0/2kXCApiUmrZLq20s cjexq3VL25QuxjY7wOcJVEpb+jLeGLAK+OMyaa1hx9rFbkwHFWBVA2y8w1wHaLE7GuDdw5cEuOM5 SLIdrpwBkN0ezwI7nYoiilqthbcYc89KgC5+NnaOHGbZz0T6BCEgOLJ0vmYXuNdPAIXgDZJhF2Yu fjnPNwAsoUTUN/P8q3AAyz4zB/xmifEfiIbvS4jh7b7QqZiSm4MJC5kXNpCRaOsoyQXAMN2XCJfs j94NKfo7ACKUEgKE3y+Sg4jibUZ1A0jgYpxtvYMC3gHaHPq6x32ACeALIZoZxB+l9VrRNIA1ncRg wwC8pvQIvYO+a2yt3VXMVyli6L0VV6aOrJa4CpilVQA+eHt0xavk61akih5BUMay/0BAqu783C5h FifY/3QsAIoWYk6PgpwAzLI652+96e2IfN2cF+BD1uT23F21Ghh5OUl4RlO15oh5A2iv+Zk2wsjZ 2DtB5Sm3A4P0+kyb2vs4iEW7G9ohoN3Stl2kVat6MCkXldo6OKaE8P6GhmrKKxWZXQH1iklhhn+d iVeNf6mDdkV0ltFwApRbp+kXSGBFHGV2aPqnIIyQyzhD5n47khqKI08bIapcas4O+hPkct20NAEv ALRuZFUp3PrnQSAm+4lTdHCsYYZ/nGqQrM5z3NS3zefFxkfFPRFbsjpIfbTlvF3ibpVZQ9nzqv60 F/KXSRLJ1AGappJulZll70N/qz6EfwEOCdYOuTHAzAAAAABJRU5ErkJggg== MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63372 Cc: 63372 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes: > After having another look at eglot-x.el i don't > think eglot--apply-text-edits (plural) is the right > place to put the generic. You'd just repeat a lot > of code of the original, with no clear way to reuse it. > > Maybe you want something more akin to the attached patch, > which introduces eglot-apply-text-edit (singular). In your > override for this function you can check conditions to either > proceed with the non-standard edit or delegate to the default > implementation with (cl-call-next-method). Unfortunately, I think this won't help me cleanly implement the snippet-text-edits feature. The server can send many text-edits and at most one of them can be a snippet-text-edit, which currently means that it contains a "$0" to tell the client where to put the point after applying the edits. My implementation applied all the edits and save the snippet (if there was any) for later use. Then it called eglot--snippet-expansion-fn on the saved snippet. This way the user saw results of all the edits before the snippet expansion. If the latest patch is merged, then I can I override the singular eglot-apply-text-edit, but I think I have no way to run a custom code after all the edits are applied. Thanks, Felici=C3=A1n
bug-gnu-emacs@HIDDEN
:bug#63372
; Package emacs
.
Full text available.Received: (at 63372) by debbugs.gnu.org; 11 May 2023 19:54:50 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 11 15:54:50 2023 Received: from localhost ([127.0.0.1]:53409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pxCNG-0003fa-99 for submit <at> debbugs.gnu.org; Thu, 11 May 2023 15:54:50 -0400 Received: from mail-oo1-f47.google.com ([209.85.161.47]:50399) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <joaotavora@HIDDEN>) id 1pxCNF-0003fO-9O for 63372 <at> debbugs.gnu.org; Thu, 11 May 2023 15:54:49 -0400 Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-54fba751417so1395528eaf.0 for <63372 <at> debbugs.gnu.org>; Thu, 11 May 2023 12:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683834883; x=1686426883; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dqeNTIjIYEUDN0v1z8yQ2gVu+AolmWWv2PzSByhxRUY=; b=havRnYtE/TzA6hhXgiqsswjwaBWTGNCTm6FA2S3bx0ZAbqVLtrh3AwBlncqDzwu7L5 UePfNrRYkssRgcXSLrqpOyGjD9n7S+xbAXl9faeKPPsaCrNlsXGY1QIH+Nj0iPDV8yT0 lMDQNfHjoTQpMZfqcZxAcKveX8KeLS/ag/drZ38sIMAEyr8+UjqoYVpfbzmmPRd7WLPI 8VZgaSFzndgSsTfFKFq2bcyp177WrHCqWMzoCnqZtIfBqDtTVwrSFJ+tTGOPQaMyWW+G tvJ96e8G1XUVIZczr8AsbD3MDsl3RFFcSYlMvVBo9/+LsvnFls0yLsMRkECiVR9oE4Mo fm/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683834883; x=1686426883; h=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=dqeNTIjIYEUDN0v1z8yQ2gVu+AolmWWv2PzSByhxRUY=; b=lzfYJ/W4Q17srn09mQDD2nhG5CTXXvS7tXA6clsskmFABG+4r/9Ew37TpDH2NIiALy Xl1ayxuQA0umL/0HhvQQton1l+NgV5OO+Tcv//c5WwAXLLhl/omHeZ/2FlFhMrrzOHIN 9T79W2JUOpkIjuU8FKFR9TYShjaQGF/4tKJESVnipP12NbaGyod7YhXt/Q8J7vwUM1wY KabivyXWDf1nOlfkLUX2/Zb5fy1sJ5FEkM8CeKxbga33Dnu7P3grC9uKP0YtoDE3cZba MClwx0UlFdPkik4/3piOaOFtpdGCXV9rHA6NJZ7/tOocuskxJpRNOvWqHgi/uEBX1DsU YX7A== X-Gm-Message-State: AC+VfDztG02yAbrz0kiAqML5GusQ5go5b7l6OOP5LBjQ69a2TacCvipx WtnP53/Almz1cmETbhpSeetfPwPSJXmXz96HF0I= X-Google-Smtp-Source: ACHHUZ5cCyyl72ee7kpFk5k3JW1tHNlTYW3X8lcODCCsXZUFCifnm2J0zKFpkMq9SXDSAgNF5CgsxZLZCy2Bg4q0kKQ= X-Received: by 2002:a4a:ea06:0:b0:54b:ce85:490a with SMTP id x6-20020a4aea06000000b0054bce85490amr5419175ood.0.1683834883259; Thu, 11 May 2023 12:54:43 -0700 (PDT) MIME-Version: 1.0 References: <874jorc7q2.fsf@HIDDEN> <83h6sqj4ed.fsf@HIDDEN> <87354auafu.fsf@HIDDEN> <835y96j10l.fsf@HIDDEN> <87y1m2spbd.fsf@HIDDEN> <87pm7dbo41.fsf@HIDDEN> <83r0rtfv3m.fsf@HIDDEN> <87h6spbibp.fsf@HIDDEN> <83ild5fpj5.fsf@HIDDEN> <871qjqc2xj.fsf_-_@HIDDEN> <CALDnm52AKj_cm6LtcuK4h6y2KvX_8sGK1o=TUhcSNNm8bTFwMg@HIDDEN> <877ctg9dzj.fsf@HIDDEN> In-Reply-To: <877ctg9dzj.fsf@HIDDEN> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN> Date: Thu, 11 May 2023 20:54:32 +0100 Message-ID: <CALDnm52mNTjPksGCKqnNsV0JoLWxAUXeGM2amN4S1O0JbVx2Ng@HIDDEN> Subject: Re: bug#63372: [PATCH] Add variable: eglot-apply-text-edits-function To: Felician Nemeth <felician.nemeth@HIDDEN> Content-Type: multipart/mixed; boundary="0000000000001401a405fb705c1b" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63372 Cc: 63372 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --0000000000001401a405fb705c1b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable After having another look at eglot-x.el i don't think eglot--apply-text-edits (plural) is the right place to put the generic. You'd just repeat a lot of code of the original, with no clear way to reuse it. Maybe you want something more akin to the attached patch, which introduces eglot-apply-text-edit (singular). In your override for this function you can check conditions to either proceed with the non-standard edit or delegate to the default implementation with (cl-call-next-method). Jo=C3=A3o --0000000000001401a405fb705c1b Content-Type: application/octet-stream; name="0001-Eglot-allow-extensions-to-application-of-LSP-edits-b.patch" Content-Disposition: attachment; filename="0001-Eglot-allow-extensions-to-application-of-LSP-edits-b.patch" Content-Transfer-Encoding: base64 Content-ID: <f_lhjjsbyx0> X-Attachment-Id: f_lhjjsbyx0 RnJvbSBkNTFhMTIxNTZiNjI3OGExZmYxZjRkYmYwZDg5OTFkNzk3NDlhZTAwIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiA9P1VURi04P3E/Sm89QzM9QTNvPTIwVD1DMz1BMXZvcmE/PSA8 am9hb3Rhdm9yYUBnbWFpbC5jb20+CkRhdGU6IFRodSwgMTEgTWF5IDIwMjMgMjA6NTA6MjAgKzAx MDAKU3ViamVjdDogW1BBVENIXSBFZ2xvdDogYWxsb3cgZXh0ZW5zaW9ucyB0byBhcHBsaWNhdGlv biBvZiBMU1AgZWRpdHMKIChidWcjNjMzNzIpCgoqIGxpc3AvcHJvZ21vZGVzL2VnbG90LmVsIChl Z2xvdC1hcHBseS10ZXh0LWVkaXQpOiBOZXcgZnVuY3Rpb24uCihlZ2xvdC0tYXBwbHktdGV4dC1l ZGl0cyk6IFJld29yay4KLS0tCiBsaXNwL3Byb2dtb2Rlcy9lZ2xvdC5lbCB8IDQ3ICsrKysrKysr KysrKysrKysrKysrKystLS0tLS0tLS0tLS0tLS0tLS0tCiAxIGZpbGUgY2hhbmdlZCwgMjUgaW5z ZXJ0aW9ucygrKSwgMjIgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEvbGlzcC9wcm9nbW9kZXMv ZWdsb3QuZWwgYi9saXNwL3Byb2dtb2Rlcy9lZ2xvdC5lbAppbmRleCBkYzhkNDY3NDQyNS4uYzA0 NWY3MWZlOWIgMTAwNjQ0Ci0tLSBhL2xpc3AvcHJvZ21vZGVzL2VnbG90LmVsCisrKyBiL2xpc3Av cHJvZ21vZGVzL2VnbG90LmVsCkBAIC04NDMsNiArODQzLDIwIEBAIGVnbG90LXdvcmtzcGFjZS1m b2xkZXJzCiAgICAgICAgICAgICAgICAgICAgICA6bmFtZSAoYWJicmV2aWF0ZS1maWxlLW5hbWUg ZGlyKSkpCiAgICAgICAgICAgICAgYCgsKHByb2plY3Qtcm9vdCBwcm9qZWN0KSAsQChwcm9qZWN0 LWV4dGVybmFsLXJvb3RzIHByb2plY3QpKSkpKSkKIAorKGNsLWRlZmdlbmVyaWMgZWdsb3QtYXBw bHktdGV4dC1lZGl0IChfc2VydmVyIGVkaXQpCisgICJBcHBseSBFRElUIHN1cHBsaWVkIGJ5IFNF UlZFUiBpbiBjdXJyZW50IGJ1ZmZlci4iCisgIChlZ2xvdC0tZGJpbmQgKChUZXh0RWRpdCkgcmFu Z2UgbmV3VGV4dCkgZWRpdAorICAgIChjbC1kZXN0cnVjdHVyaW5nLWJpbmQgKGJlZyAuIGVuZCkg KGVnbG90LS1yYW5nZS1yZWdpb24gcmFuZ2UgJ21hcmtlcnMpCisgICAgICAobGV0ICgoc291cmNl IChjdXJyZW50LWJ1ZmZlcikpKQorICAgICAgICAod2l0aC10ZW1wLWJ1ZmZlcgorICAgICAgICAg IChpbnNlcnQgbmV3VGV4dCkKKyAgICAgICAgICAobGV0ICgodGVtcCAoY3VycmVudC1idWZmZXIp KSkKKyAgICAgICAgICAgICh3aXRoLWN1cnJlbnQtYnVmZmVyIHNvdXJjZQorICAgICAgICAgICAg ICAoc2F2ZS1leGN1cnNpb24KKyAgICAgICAgICAgICAgICAoc2F2ZS1yZXN0cmljdGlvbgorICAg ICAgICAgICAgICAgICAgKG5hcnJvdy10by1yZWdpb24gYmVnIGVuZCkKKyAgICAgICAgICAgICAg ICAgIChyZXBsYWNlLWJ1ZmZlci1jb250ZW50cyB0ZW1wKSkpKSkpKSkpKQorCiAoZGVmY2xhc3Mg ZWdsb3QtbHNwLXNlcnZlciAoanNvbnJwYy1wcm9jZXNzLWNvbm5lY3Rpb24pCiAgICgocHJvamVj dC1uaWNrbmFtZQogICAgIDpkb2N1bWVudGF0aW9uICJTaG9ydCBuaWNrbmFtZSBmb3IgdGhlIGFz c29jaWF0ZWQgcHJvamVjdC4iCkBAIC0zMzI3LDI5ICszMzQxLDE4IEBAIGVnbG90LS1hcHBseS10 ZXh0LWVkaXRzCiAgICAgKGpzb25ycGMtZXJyb3IgIkVkaXRzIG9uIGAlcycgcmVxdWlyZSB2ZXJz aW9uICVkLCB5b3UgaGF2ZSAlZCIKICAgICAgICAgICAgICAgICAgICAoY3VycmVudC1idWZmZXIp IHZlcnNpb24gZWdsb3QtLXZlcnNpb25lZC1pZGVudGlmaWVyKSkKICAgKGF0b21pYy1jaGFuZ2Ut Z3JvdXAKLSAgICAobGV0KiAoKGNoYW5nZS1ncm91cCAocHJlcGFyZS1jaGFuZ2UtZ3JvdXApKQot ICAgICAgICAgICAoaG93bWFueSAobGVuZ3RoIGVkaXRzKSkKLSAgICAgICAgICAgKHJlcG9ydGVy IChtYWtlLXByb2dyZXNzLXJlcG9ydGVyCisgICAgKGNsLWxvb3AKKyAgICAgd2l0aCBjaGFuZ2Ut Z3JvdXAgPSAocHJlcGFyZS1jaGFuZ2UtZ3JvdXApCisgICAgIHdpdGggcmVwb3J0ZXIgPSAobWFr ZS1wcm9ncmVzcy1yZXBvcnRlcgogICAgICAgICAgICAgICAgICAgICAgIChmb3JtYXQgIltlZ2xv dF0gYXBwbHlpbmcgJXMgZWRpdHMgdG8gYCVzJy4uLiIKLSAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIGhvd21hbnkgKGN1cnJlbnQtYnVmZmVyKSkKLSAgICAgICAgICAgICAgICAgICAgICAw IGhvd21hbnkpKQotICAgICAgICAgICAoZG9uZSAwKSkKLSAgICAgIChtYXBjIChwY2FzZS1sYW1i ZGEgKGAoLG5ld1RleHQgLGJlZyAuICxlbmQpKQotICAgICAgICAgICAgICAobGV0ICgoc291cmNl IChjdXJyZW50LWJ1ZmZlcikpKQotICAgICAgICAgICAgICAgICh3aXRoLXRlbXAtYnVmZmVyCi0g ICAgICAgICAgICAgICAgICAoaW5zZXJ0IG5ld1RleHQpCi0gICAgICAgICAgICAgICAgICAobGV0 ICgodGVtcCAoY3VycmVudC1idWZmZXIpKSkKLSAgICAgICAgICAgICAgICAgICAgKHdpdGgtY3Vy cmVudC1idWZmZXIgc291cmNlCi0gICAgICAgICAgICAgICAgICAgICAgKHNhdmUtZXhjdXJzaW9u Ci0gICAgICAgICAgICAgICAgICAgICAgICAoc2F2ZS1yZXN0cmljdGlvbgotICAgICAgICAgICAg ICAgICAgICAgICAgICAobmFycm93LXRvLXJlZ2lvbiBiZWcgZW5kKQotICAgICAgICAgICAgICAg ICAgICAgICAgICAocmVwbGFjZS1idWZmZXItY29udGVudHMgdGVtcCkpKQotICAgICAgICAgICAg ICAgICAgICAgIChlZ2xvdC0tcmVwb3J0ZXItdXBkYXRlIHJlcG9ydGVyIChjbC1pbmNmIGRvbmUp KSkpKSkpCi0gICAgICAgICAgICAobWFwY2FyIChlZ2xvdC0tbGFtYmRhICgoVGV4dEVkaXQpIHJh bmdlIG5ld1RleHQpCi0gICAgICAgICAgICAgICAgICAgICAgKGNvbnMgbmV3VGV4dCAoZWdsb3Qt LXJhbmdlLXJlZ2lvbiByYW5nZSAnbWFya2VycykpKQotICAgICAgICAgICAgICAgICAgICAocmV2 ZXJzZSBlZGl0cykpKQotICAgICAgKHVuZG8tYW1hbGdhbWF0ZS1jaGFuZ2UtZ3JvdXAgY2hhbmdl LWdyb3VwKQotICAgICAgKHByb2dyZXNzLXJlcG9ydGVyLWRvbmUgcmVwb3J0ZXIpKSkpCisgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAobGVuZ3RoIGVkaXRzKSAoY3VycmVudC1idWZmZXIp KQorICAgICAgICAgICAgICAgICAgICAgIDAgKGxlbmd0aCBlZGl0cykpCisgICAgIGZvciBlIGFj cm9zcyAocmV2ZXJzZSBlZGl0cykgZm9yIGRvbmUgZnJvbSAxCisgICAgIGRvIChlZ2xvdC1hcHBs eS10ZXh0LWVkaXQgKGVnbG90LS1jdXJyZW50LXNlcnZlci1vci1sb3NlKSBlKQorICAgICAoZWds b3QtLXJlcG9ydGVyLXVwZGF0ZSByZXBvcnRlciBkb25lKQorICAgICBmaW5hbGx5CisgICAgICh1 bmRvLWFtYWxnYW1hdGUtY2hhbmdlLWdyb3VwIGNoYW5nZS1ncm91cCkKKyAgICAgKHByb2dyZXNz LXJlcG9ydGVyLWRvbmUgcmVwb3J0ZXIpKSkpCiAKIChkZWZ1biBlZ2xvdC0tYXBwbHktd29ya3Nw YWNlLWVkaXQgKHdlZGl0ICZvcHRpb25hbCBjb25maXJtKQogICAiQXBwbHkgdGhlIHdvcmtzcGFj ZSBlZGl0IFdFRElULiAgSWYgQ09ORklSTSwgYXNrIHVzZXIgZmlyc3QuIgotLSAKMi4zNi4xLndp bmRvd3MuMQoK --0000000000001401a405fb705c1b--
bug-gnu-emacs@HIDDEN
:bug#63372
; Package emacs
.
Full text available.Received: (at 63372) by debbugs.gnu.org; 10 May 2023 19:35:26 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 10 15:35:25 2023 Received: from localhost ([127.0.0.1]:49059 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pwpav-0008RJ-Ar for submit <at> debbugs.gnu.org; Wed, 10 May 2023 15:35:25 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:54432) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <felician.nemeth@HIDDEN>) id 1pwpaq-0008R1-7Q for 63372 <at> debbugs.gnu.org; Wed, 10 May 2023 15:35:24 -0400 Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3062db220a3so5023213f8f.0 for <63372 <at> debbugs.gnu.org>; Wed, 10 May 2023 12:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683747314; x=1686339314; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ATLyec7VFoUv9PiuGwCYzOwcIrzMPemIx4Soh7Ofaq8=; b=mXNAmDdl1ahqViHcr/LoJe9GsACjKSlVYquLM51/1CE8Kc16EPPHcFiump9UnKrmNz HDI7vC5GKhurOk1Pp9r6iznyZGUXB5NqAIddHOV/Mdyl8dbqnSKEInq2gy5V8eEHbFCU C9jbhoUt8HbAWvWavlMd9+xDVu2Sy/EjAfDxwTxLe2mSVr//nUvAPcfYlePSB8fXYtXz j2SshrrsdijcGGfw2A5hDOT+w6tI/neW2sK/dH3SBSK2lePZjVxchZu8BNSqw+7gjpwy ycOL61IkfcZkH/Qw+FoXdHujDNqy5M1JYVmjS5vFC2/iUnu5YnGHVqkhBw+bvNlSbtl9 pBuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683747314; x=1686339314; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ATLyec7VFoUv9PiuGwCYzOwcIrzMPemIx4Soh7Ofaq8=; b=P5+mAdaRDbRG5joW0aCDMYv1Jobg0333Givltlxr+HTj0FZ4kPmo8SYN7PgtRvH5zX boa9sVgMeqU9ur86eKRhtJ+L37pFdYjHkw/SvIN7QF7vEqJwBJGIDzdJeC2zFA7WPTw/ guyt2aq027xm6nASBlhySXTGkLibFXxF5krUfqrJ9vF68u0jdsuecCIBSVRcxLfvkbpZ t8FMOXt2IkC0XM/KOxjZ9i76uH7fSgcnRdezNx/oyscsTgWaRWXBjptH2XF1PC9bt5GF RQoK0mDlo0NokkafRFXJk6aG28VnOHFyZ16+3IkhUgnbUop6d1bFlXwWbQBhrK7Dm4g8 o0/g== X-Gm-Message-State: AC+VfDxF0jR4b4r7SPFDe2qOA4v9tm9aESTGwPLJAyImcSQq5h1RVibl vtwYgf5GxeO7t078no49D5s= X-Google-Smtp-Source: ACHHUZ6gPWLvc8T7j59beGXR5C9iuN4Xt7VMmV0LQ0mMZsgv8j17NuriOLr3QzEaylDz6QN2LyaJGw== X-Received: by 2002:a5d:58d9:0:b0:2f9:1224:2474 with SMTP id o25-20020a5d58d9000000b002f912242474mr13284393wrf.23.1683747314000; Wed, 10 May 2023 12:35:14 -0700 (PDT) Received: from betli.gmail.com (catv-89-134-210-182.catv.fixed.vodafone.hu. [89.134.210.182]) by smtp.gmail.com with ESMTPSA id q6-20020adff946000000b003078cd719ffsm13143385wrr.95.2023.05.10.12.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 12:35:13 -0700 (PDT) From: Felician Nemeth <felician.nemeth@HIDDEN> To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN> Subject: Re: bug#63372: [PATCH] Add variable: eglot-apply-text-edits-function References: <874jorc7q2.fsf@HIDDEN> <83h6sqj4ed.fsf@HIDDEN> <87354auafu.fsf@HIDDEN> <835y96j10l.fsf@HIDDEN> <87y1m2spbd.fsf@HIDDEN> <87pm7dbo41.fsf@HIDDEN> <83r0rtfv3m.fsf@HIDDEN> <87h6spbibp.fsf@HIDDEN> <83ild5fpj5.fsf@HIDDEN> <871qjqc2xj.fsf_-_@HIDDEN> <CALDnm52AKj_cm6LtcuK4h6y2KvX_8sGK1o=TUhcSNNm8bTFwMg@HIDDEN> Date: Wed, 10 May 2023 21:35:12 +0200 In-Reply-To: <CALDnm52AKj_cm6LtcuK4h6y2KvX_8sGK1o=TUhcSNNm8bTFwMg@HIDDEN> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Mon, 8 May 2023 17:33:06 +0100") Message-ID: <877ctg9dzj.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEWOdXElERN7LDLZs6/l 0dDQq6TepMcqAAACW0lEQVQ4jWWSzY7bMAyEaSm6mypylxjkroTRvUW8d9lavf+r7NDOZotWQHzg lyGHP0Sn5ed9qKrLWWIWos9/QJWIeCSywPNTd/AE0LtwFj7A+3WT5PwfeBrQKcsBnkfwVcNySWQr 3i34XN6gRNgis/v4uwSKHCD9lPitB0Aq9BHfHX4cgsI7cJJfLdZg/4bbCzoRmkD9MsagQSBDedZi CgNxkVSJmSOStTBUBKkywEnEoZzbwWj+ACiVJkF6pOpak2PMCqkMYDpaw+gatLR8atMOrB3JGzmm 3rSQo+tkxU+UAbhQSgtslULhsXKk6+IyQ1QTzeQB0MzjlpkCEUCeUdviWrwBcxVqpZjP+v0MYPA0 aq2rvIEZe4GRM0v+9QIB03rsABVSk5y+Mz3LSzExtJLlCCO6dV1uzDQFTBad+gO0TqqL9XE8x4ek +orvYiMJgzC8e+r6TqaPaK6QyqVNvoHtsRrooQ6tTi4vgaSkd8wIikodB3B0iIk58avsDdYNajpS bSKJ+mQnipGszB6zW4lGgsOkKHE2RWVcBpwhaIv3BYIAu3WsnC7YYKLRchp6w8fRGZIWiZuFsVai 7gbcUcJEhiDZ3K1+uzZvBlfaEO8oH4MLu6/hrKVM7QpQcIXJFuC1XjfbfKRxNslk94l9cYcEihV2 HWyNDQAXaLsvnrSyp7HaQhrAn13V6/XW11nh0XINBOEAV+tHK4EvAGNGvEwc0eZw8Vyr56imYEsV sOW9jxm/yb9AH1ufqGMviIK7A0Tc/723oM3tJ4HTOu9gDr3ftbdkxfdjsUv5AqWKwyfCYo5WAAAA AElFTkSuQmCC MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63372 Cc: 63372 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes: >> >> 3. Eglot uses the eglot--apply-text-edits defun to apply server >> >> initiated edits. There is an extension that allows the server to >> >> send the edits in a different format (snippet-text-edits). >> >> >> >> Eglot-x puts an advise on eglot--apply-text-edits to check the for= mat >> >> of the edits and act accordingly. >> >> >> >> I don't know how to avoid this advice. >> > >> > Some hook or function variable, perhaps? If they don't exist, perhaps >> > they could be added? > But then, I wonder, since most of Eglot's API is already CLOS > based, isn't a generic function best? A generic function can > have :around methods, and if we follow the convention of > passing the server as the first argument, third parties > can make server-specific extensions. You're right, I think. In the attached patch, I simply changed eglot--apply-text-edits to a cl-defgeneric and renamed it. The patch is straightforward, but I had to eliminate a cl-return-from call, because generic functions don't seem to support that. Thanks. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Eglot-Replace-eglot-apply-text-edits-with-a-public-f.patch From 4c5e62c901ada66a1ad59e4484cd0be17af64aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <felician.nemeth@HIDDEN> Date: Wed, 10 May 2023 20:58:33 +0200 Subject: [PATCH] Eglot: Replace eglot--apply-text-edits with a public function This allows third parties, for example, to cleanly implement the non-standard snippet-text-edit feature. * lisp/progmodes/eglot.el (eglot--apply-text-edits): Rename to ... (eglot-apply-text-edits): ... this, also change to cl-defgeneric, and relocate the code next to the other defgenerics. (eglot--signal-textDocument/willSave, eglot-format) (eglot-completion-at-point, eglot--apply-workspace-edit): Call renamed function. --- lisp/progmodes/eglot.el | 81 +++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 32626634b7..1c26acfe1f 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -859,6 +859,37 @@ eglot-workspace-folders :name (abbreviate-file-name dir))) `(,(project-root project) ,@(project-external-roots project)))))) +(cl-defgeneric eglot-apply-text-edits (_server edits &optional version) + "Apply EDITS for current buffer if at VERSION, or if it's nil." + (when edits + (unless (or (not version) (equal version eglot--versioned-identifier)) + (jsonrpc-error "Edits on `%s' require version %d, you have %d" + (current-buffer) version eglot--versioned-identifier)) + (atomic-change-group + (let* ((change-group (prepare-change-group)) + (howmany (length edits)) + (reporter (make-progress-reporter + (format "[eglot] applying %s edits to `%s'..." + howmany (current-buffer)) + 0 howmany)) + (done 0)) + (mapc (pcase-lambda (`(,newText ,beg . ,end)) + (let ((source (current-buffer))) + (with-temp-buffer + (insert newText) + (let ((temp (current-buffer))) + (with-current-buffer source + (save-excursion + (save-restriction + (narrow-to-region beg end) + (replace-buffer-contents temp))) + (eglot--reporter-update reporter (cl-incf done))))))) + (mapcar (eglot--lambda ((TextEdit) range newText) + (cons newText (eglot--range-region range 'markers))) + (reverse edits))) + (undo-amalgamate-change-group change-group) + (progress-reporter-done reporter))))) + (defclass eglot-lsp-server (jsonrpc-process-connection) ((project-nickname :documentation "Short nickname for the associated project." @@ -2680,9 +2711,9 @@ eglot--signal-textDocument/willSave (jsonrpc-notify server :textDocument/willSave params)) (when (eglot--server-capable :textDocumentSync :willSaveWaitUntil) (ignore-errors - (eglot--apply-text-edits - (eglot--request server :textDocument/willSaveWaitUntil params - :timeout 0.5)))))) + (eglot-apply-text-edits + server (eglot--request server :textDocument/willSaveWaitUntil params + :timeout 0.5)))))) (defun eglot--signal-textDocument/didSave () "Maybe send textDocument/didSave to server." @@ -2945,11 +2976,13 @@ eglot-format (:range ,(list :start (eglot--pos-to-lsp-position beg) :end (eglot--pos-to-lsp-position end))))) (t - '(:textDocument/formatting :documentFormattingProvider nil))))) + '(:textDocument/formatting :documentFormattingProvider nil)))) + (server (eglot--current-server-or-lose))) (eglot--server-capable-or-lose cap) - (eglot--apply-text-edits + (eglot-apply-text-edits + server (eglot--request - (eglot--current-server-or-lose) + server method (cl-list* :textDocument (eglot--TextDocumentIdentifier) @@ -3172,7 +3205,7 @@ eglot-completion-at-point (delete-region (- (point) (length proxy)) (point)) (funcall snippet-fn (or insertText label)))) (when (cl-plusp (length additionalTextEdits)) - (eglot--apply-text-edits additionalTextEdits))) + (eglot-apply-text-edits server additionalTextEdits))) (eglot--signal-textDocument/didChange))))))))) (defun eglot--hover-info (contents &optional _range) @@ -3351,37 +3384,6 @@ eglot-imenu (((SymbolInformation)) (eglot--imenu-SymbolInformation res)) (((DocumentSymbol)) (eglot--imenu-DocumentSymbol res)))))) -(cl-defun eglot--apply-text-edits (edits &optional version) - "Apply EDITS for current buffer if at VERSION, or if it's nil." - (unless edits (cl-return-from eglot--apply-text-edits)) - (unless (or (not version) (equal version eglot--versioned-identifier)) - (jsonrpc-error "Edits on `%s' require version %d, you have %d" - (current-buffer) version eglot--versioned-identifier)) - (atomic-change-group - (let* ((change-group (prepare-change-group)) - (howmany (length edits)) - (reporter (make-progress-reporter - (format "[eglot] applying %s edits to `%s'..." - howmany (current-buffer)) - 0 howmany)) - (done 0)) - (mapc (pcase-lambda (`(,newText ,beg . ,end)) - (let ((source (current-buffer))) - (with-temp-buffer - (insert newText) - (let ((temp (current-buffer))) - (with-current-buffer source - (save-excursion - (save-restriction - (narrow-to-region beg end) - (replace-buffer-contents temp))) - (eglot--reporter-update reporter (cl-incf done))))))) - (mapcar (eglot--lambda ((TextEdit) range newText) - (cons newText (eglot--range-region range 'markers))) - (reverse edits))) - (undo-amalgamate-change-group change-group) - (progress-reporter-done reporter)))) - (defun eglot--apply-workspace-edit (wedit &optional confirm) "Apply the workspace edit WEDIT. If CONFIRM, ask user first." (eglot--dbind ((WorkspaceEdit) changes documentChanges) wedit @@ -3407,7 +3409,8 @@ eglot--apply-workspace-edit (cl-loop for edit in prepared for (path edits version) = edit do (with-current-buffer (find-file-noselect path) - (eglot--apply-text-edits edits version)) + (eglot-apply-text-edits (eglot--current-server-or-lose) + edits version)) finally (eldoc) (eglot--message "Edit successful!"))))) (defun eglot-rename (newname) -- 2.30.2 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#63372
; Package emacs
.
Full text available.Received: (at 63372) by debbugs.gnu.org; 8 May 2023 16:33:25 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 08 12:33:25 2023 Received: from localhost ([127.0.0.1]:41455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pw3nh-0005AC-0d for submit <at> debbugs.gnu.org; Mon, 08 May 2023 12:33:25 -0400 Received: from mail-oa1-f46.google.com ([209.85.160.46]:62790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <joaotavora@HIDDEN>) id 1pw3ne-0005A0-OL for 63372 <at> debbugs.gnu.org; Mon, 08 May 2023 12:33:23 -0400 Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-18f4a6d2822so32468982fac.1 for <63372 <at> debbugs.gnu.org>; Mon, 08 May 2023 09:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683563597; x=1686155597; 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=xxxmHPyKlhu6GZ/qlS1dYD+LQoVqLVpzC87xTWavZAo=; b=ZxTXiXnZucNLSph7nrpGgsCJenvwbxl1S8NdKJjl6tt96UVMx2U0xrQt9Z1H57C/aK 2e6BAQnv7fD0CzPI1UlYvfFPkoMrogAdieLuHKA8dkOj7mlB3VJsableQU1rMrpCajBF IQN2VWuLRv4lTnkkDhGzqoEbJOCSSKj5e9zyoOzwGql9W/pp6ix8s1fFkghsM7gHUO7L 3Zu9ZCeNGZjTDdzL0+haHd5drfU6pM96U1E8B1Sg7dl55PesmxjRRLCOQGTbXR0fCDaB bCOxnL1tyd/xsvUkXughATT0U70WS9Dmp84ThsAA6EHrrtYh88gNyk9/AUgWF4on+AKn A12Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683563597; x=1686155597; 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=xxxmHPyKlhu6GZ/qlS1dYD+LQoVqLVpzC87xTWavZAo=; b=eFYZmLTsz3pO/5oMvm402W6IlpDIZ6GOp+GI3l7DwwWrHVVSm0203cvbj5aZ7yPanc 6z49B656683DziYsDbVNRcLVGV6kbuKKZczY5WWg4Htfx1aVz9SgsN/m6Ca77tJ6vLLb jLxSeWQFjB/fpe1cR+4dtoM2668AjtZaQxEaZN9HNFc5zTqy3SCb8xOJj6QTpsyoJKyl LGDm0pccTyXLW52+RjFtRUU2J/shtM/r/feenjcYLg3pKoS3bfgGz3+HTovT3nd3xa00 NlxC3KVCWkSiB7qc6sYzZka2d3GRFWaRuEofKWso/XCZ9faNtl0l6PogLVnXgPpyNqIw h5vQ== X-Gm-Message-State: AC+VfDzk8v4bWgWs0ZmE19KWoBR/k5R7zrQIVLNoq3xBzbklo76aybOY vM6G9WpUUDVZbk9cZMxK44fEfidww8UEcfDmrMc= X-Google-Smtp-Source: ACHHUZ69n84FdwbCvNxyn/ISMs9fPubb0lAgYmJ3ZnvvIjVewL+mvWSJ1f6g6Wd3peBeDto5ASRN3WkpjYfcrG3H4WE= X-Received: by 2002:a4a:87c4:0:b0:547:6a8d:67b2 with SMTP id c4-20020a4a87c4000000b005476a8d67b2mr5029505ooi.0.1683563597013; Mon, 08 May 2023 09:33:17 -0700 (PDT) MIME-Version: 1.0 References: <874jorc7q2.fsf@HIDDEN> <83h6sqj4ed.fsf@HIDDEN> <87354auafu.fsf@HIDDEN> <835y96j10l.fsf@HIDDEN> <87y1m2spbd.fsf@HIDDEN> <87pm7dbo41.fsf@HIDDEN> <83r0rtfv3m.fsf@HIDDEN> <87h6spbibp.fsf@HIDDEN> <83ild5fpj5.fsf@HIDDEN> <871qjqc2xj.fsf_-_@HIDDEN> In-Reply-To: <871qjqc2xj.fsf_-_@HIDDEN> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN> Date: Mon, 8 May 2023 17:33:06 +0100 Message-ID: <CALDnm52AKj_cm6LtcuK4h6y2KvX_8sGK1o=TUhcSNNm8bTFwMg@HIDDEN> Subject: Re: bug#63372: [PATCH] Add variable: eglot-apply-text-edits-function To: Felician Nemeth <felician.nemeth@HIDDEN> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63372 Cc: 63372 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) On Mon, May 8, 2023 at 3:30=E2=80=AFPM Felician Nemeth <felician.nemeth@HIDDEN> wrote: > > In https://lists.gnu.org/archive/html/emacs-devel/2023-05/msg00173.html > Eli Zaretskii <eliz@HIDDEN> writes: > > >> From: Felician Nemeth <felician.nemeth@HIDDEN> > >> Cc: joaotavora@HIDDEN, emacs-devel@HIDDEN > >> Date: Sat, 06 May 2023 17:17:14 +0200 > >> > >> 3. Eglot uses the eglot--apply-text-edits defun to apply server > >> initiated edits. There is an extension that allows the server to > >> send the edits in a different format (snippet-text-edits). > >> > >> Eglot-x puts an advise on eglot--apply-text-edits to check the form= at > >> of the edits and act accordingly. > >> > >> I don't know how to avoid this advice. > > > > Some hook or function variable, perhaps? If they don't exist, perhaps > > they could be added? > > I've attached a patch with my first attempt at this. Jo=C3=A3o, what do = you > think of this approach? It could work. But I think Some comments ? +(defvar eglot-apply-text-edits-function #'eglot--apply-lsp-text-edits eglot--apply-lsp-text-edits should in theory be external, because it is something pluggable on and off. IME these things also tend lend themselves to "multiple handlers" in the future, so maybe a generalized "special" hook (ending in "functions", plural) is better. Then some `run-hook-wrapped` would iterate through it. But then, I wonder, since most of Eglot's API is already CLOS based, isn't a generic function best? A generic function can have :around methods, and if we follow the convention of passing the server as the first argument, third parties can make server-specific extensions. Also, in some CLOS versions (not eieio.el's yet) there are even method combinations that simulate hooks. > +(cl-defun eglot--apply-lsp-text-edits (edits) > + "Apply EDITS for current buffer." > (atomic-change-group > (let* ((change-group (prepare-change-group)) Won't every "apply edit" function need this as boilerplate to guarantee undo-stability? Likely this should be popped to around the call to the generic function. > (Independently of this issue, maybe a configurable > apply-workspace-edit-function would be useful as well. One alternative > implementation of the current eglot--apply-workspace-edit could be to > apply all edits without asking for confirmation and then show a > `vc-diff'-like interface allowing the user to revert/accept all of the > changes with a single keystroke.) If this is truly independent, request it in a different bug report (or a different thread within this bug) with a different patch. If it is not independent, let's focus on the infrastructure functionality first. Jo=C3=A3o
bug-gnu-emacs@HIDDEN
:bug#63372
; Package emacs
.
Full text available.Received: (at 63372) by debbugs.gnu.org; 8 May 2023 14:54:48 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 08 10:54:47 2023 Received: from localhost ([127.0.0.1]:41301 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pw2GF-0002D7-Gf for submit <at> debbugs.gnu.org; Mon, 08 May 2023 10:54:47 -0400 Received: from mail-wr1-f54.google.com ([209.85.221.54]:52626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <felician.nemeth@HIDDEN>) id 1pw2GE-0002Ci-0i for 63372 <at> debbugs.gnu.org; Mon, 08 May 2023 10:54:46 -0400 Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-30796c0cbcaso1065152f8f.1 for <63372 <at> debbugs.gnu.org>; Mon, 08 May 2023 07:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683557680; x=1686149680; h=content-transfer-encoding:mime-version:face:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=g9yZVKh+P7LfIZYfyRoTmfwIYhiIQBAFas8hZ5v0AJM=; b=TuRs2ALDPqhi6EuWDrkjehvnpehcgg0zlPVGxftTf6uBbhP6ZJULmM5CT1A9h9xMej YD+r0sLQx7uYz6ILo5+DErlaG8YPOKMDh6/U1ji1m8WpodM3HEO33YukYavPby9IBuYy BFeOV0Wi8Q10pMhcIOnmmopQqk7cIM17LDrZD2anz5XTewLtWmxhOuOuCPTHWLr3wsAQ V2vvUhLUxrOI6NogIA7mXQc0BoafmXp6FskBOC1aOGwZabCBjbqYJpvbc9gi5+FBawfh Q9mRHLF+9O+Cf66dIRPZDTgnV9AOer/Atdgi6OB8g3/OSb3iJ+lVYaoUIe4dO+ITSYnx AuQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683557680; x=1686149680; h=content-transfer-encoding:mime-version:face:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=g9yZVKh+P7LfIZYfyRoTmfwIYhiIQBAFas8hZ5v0AJM=; b=axs4ad1wQZG3Sqyx3TgP4lLZMkez2m9Im4j16KJBHS5cR9ImIr1jcmzl0tKylSfbPp ZlYZPdIgiLjzfKa6j5I0HeoKWDvrw6KJcYbBO9OivtQKH1O74rIhS9N3nWxb3Zz5S2nR LdJnVQks8gpW96crZKA0YwquCYql+QpsxYU8xGtgU22DNEmUChIp8sZ+ED2UtHLWgfEt +Y/aEgLOxfOvDcTFbFxbZvHDp/pMVmWTmkNiblxTEhzMhdz3ly2xoN0YWak3K9HI4Qrv JbiDJKVlwPM/JmdhjY15DlIfXPSBs1r6q49dXoQ7tzP6AG7Jtjzq2S3BJSx7FwpA801b xSDA== X-Gm-Message-State: AC+VfDwe0WDGYzDrei/LUitGoiedK2OUcbYeb9pk4Wo4fe/YjiUlX9mz ZTuNssyGO0g/Ul8aOJGKzzQ= X-Google-Smtp-Source: ACHHUZ54n2pvStJRmD43Yr+nAbwfpptNYyYGCjlGyG7vv4yozzJm0TlxmxlgJc6H046ml3r1eMicZQ== X-Received: by 2002:adf:fc8c:0:b0:306:3204:3633 with SMTP id g12-20020adffc8c000000b0030632043633mr7337496wrr.22.1683557680125; Mon, 08 May 2023 07:54:40 -0700 (PDT) Received: from betli.gmail.com (catv-89-134-210-182.catv.fixed.vodafone.hu. [89.134.210.182]) by smtp.gmail.com with ESMTPSA id j18-20020a5d4492000000b003021288a56dsm11581270wrq.115.2023.05.08.07.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 07:54:39 -0700 (PDT) From: Felician Nemeth <felician.nemeth@HIDDEN> To: 63372 <at> debbugs.gnu.org Subject: Re: bug#63372: [PATCH] Add variable: eglot-apply-text-edits-function References: <874jorc7q2.fsf@HIDDEN> <83h6sqj4ed.fsf@HIDDEN> <87354auafu.fsf@HIDDEN> <835y96j10l.fsf@HIDDEN> <87y1m2spbd.fsf@HIDDEN> <87pm7dbo41.fsf@HIDDEN> <83r0rtfv3m.fsf@HIDDEN> <87h6spbibp.fsf@HIDDEN> <83ild5fpj5.fsf@HIDDEN> <871qjqc2xj.fsf_-_@HIDDEN> Date: Mon, 08 May 2023 16:54:38 +0200 In-Reply-To: <871qjqc2xj.fsf_-_@HIDDEN> (Felician Nemeth's message of "Mon, 08 May 2023 16:28:56 +0200") Message-ID: <87ttwman69.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX5+fmhoaEwMDD/ ///TMNVWAAAAAWJLR0QDEQxM8gAAAAlwSFlzAAAPEgAADxIBIZvyMwAAAAd0SU1FB+AICBUfHgLs gGoAAAGXSURBVCjPRdK/b5tAFAfw753gBEwM2ApMbuVIqf+Ko0qiyhOu4sj2xJBYMn/FUdX7UUUZ OjHgyvf+yj6IcW6Bjx53934ADEvs8bmEr8UVoTYTOyJO9KoYsVofN8kILdbeJ8Li6YpZWop4xOK0 VdfIoXmkHn5/5D7/Ts/8THacSqnkKTcMTxgUkVzFnEIRTKwwYYSCvzfg16f0i8YApW/XG/Pm8R49 dXjxKmRnxv3OwooQWcv4RUYem1fsNe/WU63uk7AmYxk78y32/ee2tZB4fO+WcZ7lnIGEolXW1EGw LfkSuQ0XTgRefgNlfNwRNV6QhBxJ8JNxTMUPyBqTd0bjaAP5G7NJRU39z80hLOZTjqB7K3tEEFSj aEsuQew6qBxxyhHjVUR7H7NpC9iHJZGLMCEuweqAqE1BHbfK2oRIz9EHYA/+wiFWru9smeVfuWNZ 2+NFtX80UA1TvJNdytM4DwO4kY7bJz8Qcd0G0ceslZGkkeoBsjUHwF1+jjM3XHaXEZ7mGLfwPFO+ RV9QLY2iEdmDo78D/gNPaXVYqd+pyQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNi0wOC0wOFQyMzoz MDoyOCswMjowMGy/yHYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTYtMDgtMDhUMjM6MzA6MjgrMDI6 MDAd4nDKAAAAAElFTkSuQmCC MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63372 Cc: Eli Zaretskii <eliz@HIDDEN>, joaotavora@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Felician Nemeth <felician.nemeth@HIDDEN> writes: > I've attached a patch with my first attempt at this. Jo=C3=A3o, what do = you > think of this approach? I forgot to add that alternatively SnippetTextEdit support can be added to Eglot as well. The patch without the boring parts would look like the following. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index eb79a8d2d3..0a4738b3b9 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3350,14 +3350,13 @@ eglot-imenu =20 (cl-defun eglot--apply-text-edits (edits &optional version) "Apply EDITS for current buffer if at VERSION, or if it's nil." + ;; This is quite rust-analyzer specific. It assumes there is at + ;; most one meaningful SnippetTextEdit and that can be identified by + ;; searching for "$0". (unless edits (cl-return-from eglot--apply-text-edits)) (unless (or (not version) (equal version eglot--versioned-identifier)) (jsonrpc-error "Edits on `%s' require version %d, you have %d" (current-buffer) version eglot--versioned-identifier)) (atomic-change-group (let* ((change-group (prepare-change-group)) (howmany (length edits)) @@ -3366,7 +3365,7 @@ eglot--apply-lsp-text-edits howmany (current-buffer)) 0 howmany)) - (done 0)) - (mapc (pcase-lambda (`(,newText ,beg . ,end)) + (done 0) + snippet snippet-beg snippet-end) + (mapc (pcase-lambda (`(,newText ,insertTextFormat (,beg . ,end))) (let ((source (current-buffer))) (with-temp-buffer (insert newText) @@ -3375,11 +3374,30 @@ eglot--apply-lsp-text-edits (save-excursion (save-restriction (narrow-to-region beg end) - (replace-buffer-contents temp))) + (replace-buffer-contents temp)) + (when (and (eql insertTe= xtFormat 2) + (string-match "\\$\\(0\\|{0[^}]*}\\)" + newText)) + ;; "At the moment, rust-analyzer + ;; guarantees that only a single edit will + ;; have InsertTextFormat.Snippet.", but: + ;; https://github.com/rust-analyzer/rust-analy= zer/issues/11006 + ;; Every one of them has insertTextFormat + ;; =3D 2, and there's no easy, reliable way + ;; to tell, which one contains a real + ;; snippet. RA's own .ts implementation + ;; uses the regexp above. + (setq snippet newText) + (setq snippet-beg (point-min-marker)) + (setq snippet-end (point-max-marker)))) (eglot--reporter-update reporter (cl-incf done))))))) - (mapcar (eglot--lambda ((TextEdit) range newText) - (cons newText (eglot--range-region range 'markers))) + (mapcar (eglot--lambda ((SnippetTextEdit) range newText insert= TextFormat) + (list newText insertTextFormat (eglot--range-region = range 'markers))) (reverse edits))) + (when snippet + (goto-char snippet-beg) + (delete-region snippet-beg snippet-end) + (funcall (eglot--snippet-expansion-fn) snippet)) (undo-amalgamate-change-group change-group) (progress-reporter-done reporter))))
bug-gnu-emacs@HIDDEN
:bug#63372
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 8 May 2023 14:29:18 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 08 10:29:18 2023 Received: from localhost ([127.0.0.1]:41271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pw1rZ-0001MV-UI for submit <at> debbugs.gnu.org; Mon, 08 May 2023 10:29:18 -0400 Received: from lists.gnu.org ([209.51.188.17]:39680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <felician.nemeth@HIDDEN>) id 1pw1rY-0001MK-1E for submit <at> debbugs.gnu.org; Mon, 08 May 2023 10:29:16 -0400 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 <felician.nemeth@HIDDEN>) id 1pw1rM-0004ge-MU for bug-gnu-emacs@HIDDEN; Mon, 08 May 2023 10:29:08 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <felician.nemeth@HIDDEN>) id 1pw1rK-00053w-DU for bug-gnu-emacs@HIDDEN; Mon, 08 May 2023 10:29:04 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f19b9d5358so45919315e9.1 for <bug-gnu-emacs@HIDDEN>; Mon, 08 May 2023 07:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683556138; x=1686148138; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=KdQVE67+OqEs6SawzKVc87fvyq+QO8MHDXbjRcblsAU=; b=OkzXd/am6+y88Bhh+0LNY5ZWIMgfK3NhD+IN5jnFaV0Ew0Z3Awggue1awbu+Ekq95L GY/VttEhglz4JTinrykvo2/Ob63C0cPimf6Q+IqJBtiQyIz3LKQk/AU6sdcUkfqtxama v/GCKX8sMJW0LgcXUwGpCKIgXef+oqe+ebY+3Ua0yq0066DeMfUYhzxkjhNT/JBHbdGu tKGLmemISFGrEyQyxasjCQ0C9dfejw4gv6f7eRPlVlzkRrAPkPXJundqTmx9yRERCkAL ImgnhZOn5dkb57kdSfnvFTOUFjnJ88AphCffaiBU+awpQh2xFGOkQPzUfWaOkDiltETZ gNfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683556138; x=1686148138; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KdQVE67+OqEs6SawzKVc87fvyq+QO8MHDXbjRcblsAU=; b=S3kAwzVVxzQOVXO3v6WuzaShPP7gjNL1qGNnuwD0irNL5ORD+AJWESxkylAjWuQfbn 7HdU++D5fTe+g0SwBpUQla1NB4IP3y62yWcYeK8Xc2KsenxJXXN5XTVlehETB35boTKe +/eleOhHyjDVA15TAqwMoDj2c+CcPRPO9AdA96/hfrSgb64zTXbgXTQqz03dUPSzoaQL RazcaiwZsEsEZnZj4Hbn0CiV/lzVEDeZvytYU93pV7/fc7h5DcMx7VqJTssclzZF4cnF eIUrX4GeiQg4GGtA9Zs0qhddah/1WOn2fvpymQl8+3L124TDiJZYLdChvlixInp1TG8I Znog== X-Gm-Message-State: AC+VfDxEZhQfqo55hvrLjOlf9Czwh4SQc2G5bIKoUa7SerCyy8xiaoN8 qv681EbsZzg77jTRbKk/kl1IPFsLeWg= X-Google-Smtp-Source: ACHHUZ7iJEaJ/rFi1gUnixaxg8ei3qtZhiQawYRPF99hISJZIEI+lPXwVpwSqscqU6ojvrnRKXAXuA== X-Received: by 2002:a1c:f71a:0:b0:3f1:91ba:feb2 with SMTP id v26-20020a1cf71a000000b003f191bafeb2mr7077479wmh.2.1683556137621; Mon, 08 May 2023 07:28:57 -0700 (PDT) Received: from betli.gmail.com (catv-89-134-210-182.catv.fixed.vodafone.hu. [89.134.210.182]) by smtp.gmail.com with ESMTPSA id x20-20020a1c7c14000000b003f17af4c4e0sm16877795wmc.9.2023.05.08.07.28.56 for <bug-gnu-emacs@HIDDEN> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 07:28:57 -0700 (PDT) From: Felician Nemeth <felician.nemeth@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: [PATCH] Add variable: eglot-apply-text-edits-function References: <874jorc7q2.fsf@HIDDEN> <83h6sqj4ed.fsf@HIDDEN> <87354auafu.fsf@HIDDEN> <835y96j10l.fsf@HIDDEN> <87y1m2spbd.fsf@HIDDEN> <87pm7dbo41.fsf@HIDDEN> <83r0rtfv3m.fsf@HIDDEN> <87h6spbibp.fsf@HIDDEN> <83ild5fpj5.fsf@HIDDEN> X-Debbugs-Cc: joaotavora@HIDDEN, Eli Zaretskii <eliz@HIDDEN> Date: Mon, 08 May 2023 16:28:56 +0200 In-Reply-To: <83ild5fpj5.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 06 May 2023 18:27:58 +0300") Message-ID: <871qjqc2xj.fsf_-_@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUMBwgHAgMFAAGPjY7/ //80MDHq6eqJt3pKAAABr0lEQVQ4jX2UzZKDIAzHqR177q7TPbtx2HMr6guQcrbY9txZ0fd/hA0f onXazcEJ/CD8E4Js8/HS9mwjXtqeMRxHXJkakTEm4b4GPVQW8PU8ov4fQCqeThlF60MBWdo1IXzd 2nEEZE7CEAZLwI0N/gJAhTj7ESQAX4gPgO8lyI+cvgViSVPlNomAj2M9gW40eg7VWY3cATjUcyiO Z+i03cFruGLYoUR7VyU3HihdmCEVhoDN65FXkpbSxkomOzsTQN/gySaodGb9Gdi1oSRXP46gdBWh LcUKJNdeGCWac74GKakmne0aHCFvyqJPYLsCFAVlhRTvGdzMdLHqtgRyUulyXIAH7CYQ3AB0Nody JQhAkq/qtOnbjhxdzYDkXPxlH5y4WdUAeUcX1NVJ6GR7UQEYPGWoAnA36OQNn5lRRp38vHTAp9Br LoTmvlPPDoRCKzpjG1SXT89AaT5l456BamJuMcs+NIOMzJ/s5dI6yUVcrARlruwOebfdv6gunTn4 ww3+QjGBEn5suVyLHoSGvAqREuDLN+iqZ+VcFg+HBbsJUU9+FZthbez9T+bdb+kPv2Ls6ct3hTkA AAAASUVORK5CYII= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=felician.nemeth@HIDDEN; helo=mail-wm1-x336.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable In https://lists.gnu.org/archive/html/emacs-devel/2023-05/msg00173.html Eli Zaretskii <eliz@HIDDEN> writes: >> From: Felician Nemeth <felician.nemeth@HIDDEN> >> Cc: joaotavora@HIDDEN, emacs-devel@HIDDEN >> Date: Sat, 06 May 2023 17:17:14 +0200 >>=20 >> 3. Eglot uses the eglot--apply-text-edits defun to apply server >> initiated edits. There is an extension that allows the server to >> send the edits in a different format (snippet-text-edits). >>=20 >> Eglot-x puts an advise on eglot--apply-text-edits to check the format >> of the edits and act accordingly. >>=20 >> I don't know how to avoid this advice. > > Some hook or function variable, perhaps? If they don't exist, perhaps > they could be added? I've attached a patch with my first attempt at this. Jo=C3=A3o, what do you think of this approach? (Independently of this issue, maybe a configurable apply-workspace-edit-function would be useful as well. One alternative implementation of the current eglot--apply-workspace-edit could be to apply all edits without asking for confirmation and then show a `vc-diff'-like interface allowing the user to revert/accept all of the changes with a single keystroke.) Thank you. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-variable-eglot-apply-text-edits-function.patch From 1a5c534a291a9ee247cb142a4816b75a9cff3ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <felician.nemeth@HIDDEN> Date: Mon, 8 May 2023 15:57:56 +0200 Subject: [PATCH] Add variable: eglot-apply-text-edits-function This allows third parties to experiment with UI, or implement the SnippetTextEdits LSP extension. * lisp/progmodes/eglot.el (eglot-apply-text-edits-function): New defvar defaulting to eglot--apply-lsp-text-edits. (eglot--apply-text-edits): Delegate the editing task to eglot-apply-text-edits-function. (eglot--apply-lsp-text-edits): New defun containing most of the old eglot--apply-text-edits. --- lisp/progmodes/eglot.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 95a5b325fb..eb79a8d2d3 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -895,6 +895,11 @@ eglot--language-ids (cl-defmethod initialize-instance :before ((_server eglot-lsp-server) &optional args) (cl-remf args :initializationOptions)) +(defvar eglot-apply-text-edits-function #'eglot--apply-lsp-text-edits + "Function to call to apply text edits to the current buffer. +The fuction must have a single argument holding the \"edits\" +value of a TextDocumentEdit LSP object, i.e., a TextEdit or an +AnnotatedTextEdit LSP object.") ;;; Process management (defvar eglot--servers-by-project (make-hash-table :test #'equal) @@ -3349,6 +3354,10 @@ eglot--apply-text-edits (unless (or (not version) (equal version eglot--versioned-identifier)) (jsonrpc-error "Edits on `%s' require version %d, you have %d" (current-buffer) version eglot--versioned-identifier)) + (funcall eglot-apply-text-edits-function edits)) + +(cl-defun eglot--apply-lsp-text-edits (edits) + "Apply EDITS for current buffer." (atomic-change-group (let* ((change-group (prepare-change-group)) (howmany (length edits)) -- 2.30.2 --=-=-=--
Felician Nemeth <felician.nemeth@HIDDEN>
:joaotavora@HIDDEN, eliz@HIDDEN, bug-gnu-emacs@HIDDEN
.
Full text available.joaotavora@HIDDEN, eliz@HIDDEN, bug-gnu-emacs@HIDDEN
:bug#63372
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.