GNU bug report logs - #60338
[PATCH] Add option to present server changes as diffs

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Philip Kaludercic <philipk@HIDDEN>; Keywords: patch; dated Mon, 26 Dec 2022 13:43:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 60338 <at> debbugs.gnu.org:


Received: (at 60338) by debbugs.gnu.org; 30 Dec 2022 13:11:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 30 08:11:53 2022
Received: from localhost ([127.0.0.1]:33707 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pBFAu-0001n7-PI
	for submit <at> debbugs.gnu.org; Fri, 30 Dec 2022 08:11:53 -0500
Received: from mail-oi1-f176.google.com ([209.85.167.176]:45941)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1pBFAt-0001ms-2L
 for 60338 <at> debbugs.gnu.org; Fri, 30 Dec 2022 08:11:51 -0500
Received: by mail-oi1-f176.google.com with SMTP id d127so18038312oif.12
 for <60338 <at> debbugs.gnu.org>; Fri, 30 Dec 2022 05:11:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=Ya0vlwhAK40OKIzL9PSQe0rhYZIyd25t47C8QRVGWdI=;
 b=L/2QAP8PfC8Xlf7Pt6fKQp+5MXZZR7JkDEr6aFTY1k/zFlA2i9w7bina9m8+ZZDJ7a
 HoZNVJH2ifG1lwfcA6slDwFNd+aDyaw8rrWHfH58GAmComnW7KvZ5Dmdl5YUot9egxyg
 77RbIdf7OxybT3hKrWjDNRLS5FzgRXpgisNfi13y64N0zU1/7bCourPEuJl5gL4ywVh8
 k/j/3GnEKol5oF9M6UvP7wO23Si436kgwh4y4ptsANl7sIg5SJCa4bj8XPhr5jIW+tsj
 WGiTLD66i1gnfXT6YwFsFlip2zMu8QodtARijYO7Uqi9LHuB440WcUXzTmK2QCpsCudW
 CBMg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 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=Ya0vlwhAK40OKIzL9PSQe0rhYZIyd25t47C8QRVGWdI=;
 b=11sCvksK0ROwsBI5e5UjSgOEzHgFr+i6sKAs95+61cEhtVJGz1wCT/XXEZc+aGQYDR
 bwlizptIzGzEOGPQr7Ek0lCSQPQzC1XbOVqo3TRNavbdgXLYNXv0MMNlQWSkQtp70uMj
 f3dD5JdOtWWOavGo7msWjhiiP2rnQCcS1r1cjALunMTrl/CMF8+IU1p/cLVJAKAfJBSf
 7mpcppbreFa6ufKWVDMSs0j70GQbFZQXwC2uQ53cz7Ukb96dUlFokDpTrt5I5jmXcBf0
 HGkXek1Ghk8EKMbWeQo6UNgOQrcq1lMGxUdceKkQ4q9BEjWwEeAkR/xq6eIGMbaPzn7f
 /bJg==
X-Gm-Message-State: AFqh2krDZDIZoFU46YCUKbm5LfYmLI4KI238Gc3riAfH3B+qPKDJ0HN7
 P9WrEI39SezBZbDmKaF1rPgfpxW6nDXaE4n7mJM=
X-Google-Smtp-Source: AMrXdXs0hBPYf8uusBbwkUBZX9thPj7xN81XjslqVZFL4r7F5m8nPYu5FQBtwXLlzea/el1kAq0BNzItR6O3s3CFObA=
X-Received: by 2002:a05:6808:13d6:b0:35c:2ddf:59d5 with SMTP id
 d22-20020a05680813d600b0035c2ddf59d5mr1675645oiw.215.1672405905439; Fri, 30
 Dec 2022 05:11:45 -0800 (PST)
MIME-Version: 1.0
References: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@HIDDEN>
 <87zgb6gu71.fsf@HIDDEN>
 <CALDnm50p=dVUCojmR+6kcgTrXRzww-TjAN6H5q5ZMKkmsjd1KQ@HIDDEN>
 <87v8lugtou.fsf@HIDDEN>
In-Reply-To: <87v8lugtou.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Fri, 30 Dec 2022 13:13:05 +0000
Message-ID: <CALDnm52XtrvrJen5zPmz3E9g4Le4B-6+vf2okTZw-oohWeJ3rw@HIDDEN>
Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs
To: Philip Kaludercic <philipk@HIDDEN>
Content-Type: multipart/alternative; boundary="000000000000e9ffa205f10b57ba"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60338
Cc: Yuan Fu <casouri@HIDDEN>, 60338 <at> debbugs.gnu.org
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 (-)

--000000000000e9ffa205f10b57ba
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, Dec 29, 2022 at 2:39 PM Philip Kaludercic <philipk@HIDDEN>
wrote:

> Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:
>
> > The idea is good, but how does this play along with the existing
> > eglot-confirm-server-initiated-edits?
>
> It takes precedence, since the diff is regarded as a kind of prompt.  If
> you want to, I can also update the patch to use that option instead of a
> custom one (e.g. present a diff if
> `eglot-confirm-server-initiated-edits' is set to `diff').


This is an improvement, but it's not enough, unfortunately.

The current semantics of eglot-confirm-server-initiated-edits must first be
investigated, then potentially expanded/consolidated, even before the
augmentation
with the new 'diff value.   Only then should 'diff be added.  If we do this
some other
way, we only increase inconsistency and confusion.

Here is some information to get started with the investigation.

The function responsible for applying edits, eglot--apply-workspace-edit is
called currently from 3 places:

1. eglot-rename (this ignores eglot-c-s-initiated-edits, but confirms with
a prefix
argument).  The reasoning is that this is such a common action that by
default
we shouldn't bother the user with confirmation.

2. When the user chooses a code action from a list of code actions presente=
d
as a menu and that code action happens to contain an edit.  This also
ignores
eglot-c-s-initiated-edits.  The locus of the call is
eglot--read-execute-code-action.
The reasoning here is, I believe, that the user is already being presented
with
an interactive prompt, and presenting a second follow-up seemed too much.

3. When applying a code action that makes the server initiate a code
action.
The locus is eglot--handle-request (for workspace/applyEdit).  Here
eglot-confirm-server-initiated-edits is read honoured.  The reasoning here
is
that the user might not be aware of the breadth of the code action that the
server is about to propose.

Note that the differences between 2 and 3 are subtle, and perhaps
conceptually
non-existent, but technically they do exist.  In 2, the edit is immediately
available whereas in 3, a further server trip is required to get the edit
to apply.

Moreover, the current method of  "confirmation" is just a prompt that lists
the
files about to be changed.  This is what should change, perhaps even by
default,  to a presentation of a diff in a separate buffer.

Currently, the confirmation happens also (regardless of the value of
eglot-confirm-server-initiated-edits) if any of the files about to be
changed
is not yet visited in a buffer.

So to summarize, I would like to hear proposals on how to make
user confirmation of edits more consistent and predictable across the
various use cases.

Then, as I've already said, the "diff" method of confirmation sounds in
principle very robust  and in-line with Emacs' principles. It could
eventually
even be made the default.

Jo=C3=A3o

--000000000000e9ffa205f10b57ba
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"></div><br><div class=3D"gmail_quote"><div=
 dir=3D"ltr" class=3D"gmail_attr">On Thu, Dec 29, 2022 at 2:39 PM Philip Ka=
ludercic &lt;<a href=3D"mailto:philipk@HIDDEN">philipk@HIDDEN</a>&g=
t; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Jo=C3=
=A3o T=C3=A1vora &lt;<a href=3D"mailto:joaotavora@HIDDEN" target=3D"_bla=
nk">joaotavora@HIDDEN</a>&gt; writes:<br>
<br>
&gt; The idea is good, but how does this play along with the existing<br>
&gt; eglot-confirm-server-initiated-edits?<br>
<br>
It takes precedence, since the diff is regarded as a kind of prompt.=C2=A0 =
If<br>
you want to, I can also update the patch to use that option instead of a<br=
>
custom one (e.g. present a diff if<br>
`eglot-confirm-server-initiated-edits&#39; is set to `diff&#39;).</blockquo=
te></div><div><br></div><div>This is an improvement, but it&#39;s not enoug=
h, unfortunately.<br></div><div><br></div><div>The current semantics of egl=
ot-confirm-server-initiated-edits must first be <br></div><div>investigated=
, then potentially expanded/consolidated, even before the augmentation <br>=
</div><div>with the new &#39;diff value.=C2=A0=C2=A0 Only then should &#39;=
diff be added.=C2=A0 If we do this some other <br></div><div>way, we only i=
ncrease inconsistency and confusion.<br></div><div><br></div><div>Here is s=
ome information to get started with the investigation.<br></div><div><br></=
div><div></div><div>The function responsible for applying edits, eglot--app=
ly-workspace-edit is <br></div><div>called currently from 3 places:</div><d=
iv><br></div><div>1. eglot-rename (this ignores eglot-c-s-initiated-edits, =
but confirms with a prefix <br></div><div>argument).=C2=A0 The reasoning is=
 that this is such a common action that by default <br></div><div>we should=
n&#39;t bother the user with confirmation.<br></div><div><br></div><div>2. =
When the user chooses a code action from a list of code actions presented</=
div><div>as a menu and that code action happens to contain an edit.=C2=A0 T=
his also ignores<br></div><div>eglot-c-s-initiated-edits.=C2=A0 The locus o=
f the call is eglot--read-execute-code-action.</div><div>The reasoning here=
 is, I believe, that the user is already being presented with <br></div><di=
v>an interactive prompt, and presenting a second follow-up seemed too much.=
<br></div><div></div><div><br></div><div>3. When applying a code action tha=
t makes the server initiate a code action. <br></div><div>The locus is eglo=
t--handle-request (for workspace/applyEdit).=C2=A0 Here</div><div>eglot-con=
firm-server-initiated-edits is read honoured.=C2=A0 The reasoning here is</=
div><div>that the user might not be aware of the breadth of the code action=
 that the</div><div>server is about to propose.</div><div><br></div><div>No=
te that the differences between 2 and 3 are subtle, and perhaps conceptuall=
y</div><div>non-existent, but technically they do exist.=C2=A0 In 2, the ed=
it is immediately</div><div>available whereas in 3, a further server trip i=
s required to get the edit to apply.<br></div><br><div>Moreover, the curren=
t method of=C2=A0 &quot;confirmation&quot; is just a prompt that lists the =
<br></div><div>files about to be changed.=C2=A0 This is what should change,=
 perhaps even by <br></div><div>default,=C2=A0 to a presentation of a diff =
in a separate buffer.<br></div><div><br></div><div>Currently, the confirmat=
ion happens also (regardless of the value of <br></div><div>eglot-confirm-s=
erver-initiated-edits) if any of the files about to be changed <br></div><d=
iv>is not yet visited in a buffer.</div><div><br></div><div>So to summarize=
, I would like to hear proposals on how to make <br></div><div>user confirm=
ation of edits more consistent and predictable across the</div><div>various=
 use cases.</div><div><br></div><div>Then, as I&#39;ve already said, the &q=
uot;diff&quot; method of confirmation sounds in <br></div><div>principle ve=
ry robust=C2=A0 and in-line with Emacs&#39; principles. It could eventually=
 <br></div><div>even be made the default.</div><div><br></div><div>Jo=C3=A3=
o<br></div><div><br></div><div><br></div></div>

--000000000000e9ffa205f10b57ba--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60338; Package emacs. Full text available.

Message received at 60338 <at> debbugs.gnu.org:


Received: (at 60338) by debbugs.gnu.org; 29 Dec 2022 14:39:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 29 09:39:49 2022
Received: from localhost ([127.0.0.1]:59638 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pAu4S-0007Po-Vg
	for submit <at> debbugs.gnu.org; Thu, 29 Dec 2022 09:39:49 -0500
Received: from mout01.posteo.de ([185.67.36.65]:54353)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philipk@HIDDEN>) id 1pAu4R-0007PZ-Dj
 for 60338 <at> debbugs.gnu.org; Thu, 29 Dec 2022 09:39:48 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 61707240124
 for <60338 <at> debbugs.gnu.org>; Thu, 29 Dec 2022 15:39:40 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1672324781; bh=tNDR89MI2sRMqx+4fTiGcDbblqZZ9xMJ8ZMUpeZAcog=;
 h=From:To:Cc:Subject:Date:From;
 b=Zm52Pp7xcJtdRJQal4NxtS/Y4J/F+o6dRB13FEieXaEsUEC3HNvuEvbbHeZQk+7PG
 UVtvOYMWtimJMLgHoNPXWXsLqSsPDIsh/9ZFDr/V9chWjLvC4h9DVIpT1gwvOF0L6v
 4kbhXwb3/l9zU6tjXGE/qYVdUJQEdb1umF8EP4InJupG3eK/Pjo7Gma6LOE5wi42Hc
 YoeNoQuQhOT/Nst01q7O4a+kDOVqJIZ0w8eehtLzpNjPbiItox0SwDexRquwwDY0md
 8eg8e2gJfEdYtMh1aL767QBlNFD+hCAna/GYYSW4oDPvrPcfmGgeAmwGP+/uR144uj
 v9yIM8jIuiVvQ==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4NjWHv6KrTz9rxH;
 Thu, 29 Dec 2022 15:39:39 +0100 (CET)
From: Philip Kaludercic <philipk@HIDDEN>
To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs
In-Reply-To: <CALDnm50p=dVUCojmR+6kcgTrXRzww-TjAN6H5q5ZMKkmsjd1KQ@HIDDEN>
 (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Thu, 29 Dec 2022
 14:36:13 +0000")
References: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@HIDDEN>
 <87zgb6gu71.fsf@HIDDEN>
 <CALDnm50p=dVUCojmR+6kcgTrXRzww-TjAN6H5q5ZMKkmsjd1KQ@HIDDEN>
Date: Thu, 29 Dec 2022 14:39:45 +0000
Message-ID: <87v8lugtou.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60338
Cc: Yuan Fu <casouri@HIDDEN>, 60338 <at> debbugs.gnu.org
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: -3.3 (---)

Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:

> The idea is good, but how does this play along with the existing
> eglot-confirm-server-initiated-edits?

It takes precedence, since the diff is regarded as a kind of prompt.  If
you want to, I can also update the patch to use that option instead of a
custom one (e.g. present a diff if
`eglot-confirm-server-initiated-edits' is set to `diff').

> Jo=C3=A3o




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60338; Package emacs. Full text available.

Message received at 60338 <at> debbugs.gnu.org:


Received: (at 60338) by debbugs.gnu.org; 29 Dec 2022 14:35:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 29 09:35:02 2022
Received: from localhost ([127.0.0.1]:59632 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pAtzq-0007IP-61
	for submit <at> debbugs.gnu.org; Thu, 29 Dec 2022 09:35:02 -0500
Received: from mail-oa1-f42.google.com ([209.85.160.42]:40833)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1pAtzn-0007I5-PB
 for 60338 <at> debbugs.gnu.org; Thu, 29 Dec 2022 09:35:00 -0500
Received: by mail-oa1-f42.google.com with SMTP id
 586e51a60fabf-14455716674so21847529fac.7
 for <60338 <at> debbugs.gnu.org>; Thu, 29 Dec 2022 06:34:59 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=wJn1k5IRs8X892akQ/ohKNu7GdM6btA9QiaHxCLc7Os=;
 b=TY4ojibTO45QeaX5eVWx1BAZvh0Rc+BIdUijw/BiIE3JC4BFNYgPEZS/KuxtrYqXU/
 7CybYe0LGBOnBO6ed2boYo+en9jsrquu9HXPcGnMHHPmy+8El4t0iqm0axP+Zealck6a
 JejSQQz37EEWg+UJ8Z7Y0TfapMGEYPM0xHGP0ca3GNMKAqhflpMy6+P4jdZsuI8mBJAa
 y+GyQ6PZKRcBbOztiV/SPQB+y3g4qy78IdKyUCV/eUNrAjNX4IkpGKMS9r8HA7B2RQvu
 +YbnmwQDXVzyAtRsJ97BZ+EQkLruFtHCIcZVfweZUP0WWo2S7u9QYwWn/9r6T8e/0uuL
 ZQlg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 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=wJn1k5IRs8X892akQ/ohKNu7GdM6btA9QiaHxCLc7Os=;
 b=EM1ZSkDNU5gpHy9HgEcgQ5wxZXMnOtYXLfW0SloJWOQAoDJPbEWJJmgc+Fs7n8aFSL
 wWl3XeKKxzpFvcRtSzFrIm2gBFp+JGfce3QV4196iCyVBhSVeOTJx1rX/XtEygT691DJ
 wxser5/yHn7QLUz30ovNgn1UeoBNCgJE6TRwhjl7U8UGbkJQSnOUzRxBBMGwqicR7xMm
 5irXhRaK20BXqEszf4gR+Pzc8bUsXVIIdGoaGKIXTV5VPUUXRYzqXOJWKOHt2W5pd8nM
 uvpihP4/oLadLaDW/FP2E7NEkNQvuoxFfgQo2WUpsi+zdhq9uL7E7k77WPKd4t0fzjos
 MMqA==
X-Gm-Message-State: AFqh2kr+Dne8LwfdoC0iUL/DXagOJ2Qe9JpWcnTqXVg3S3A341qbgg1m
 9OE19S/v3Zn938FSq8Mxxq1wqLlRCxXmK0PMDm0=
X-Google-Smtp-Source: AMrXdXs4qhfV4rkA9QHKTbIUoLGDuaxY9HDKSL6gDyDLTeLpFL7oGtAdVj+ti9VI8N1TPAdWYlGXB3kuZjyjSuMlhVw=
X-Received: by 2002:a05:6870:d99a:b0:143:7889:c525 with SMTP id
 gn26-20020a056870d99a00b001437889c525mr1597130oab.171.1672324493931; Thu, 29
 Dec 2022 06:34:53 -0800 (PST)
MIME-Version: 1.0
References: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@HIDDEN>
 <87zgb6gu71.fsf@HIDDEN>
In-Reply-To: <87zgb6gu71.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Thu, 29 Dec 2022 14:36:13 +0000
Message-ID: <CALDnm50p=dVUCojmR+6kcgTrXRzww-TjAN6H5q5ZMKkmsjd1KQ@HIDDEN>
Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs
To: Philip Kaludercic <philipk@HIDDEN>
Content-Type: multipart/alternative; boundary="00000000000068f89a05f0f8637a"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60338
Cc: Yuan Fu <casouri@HIDDEN>, 60338 <at> debbugs.gnu.org
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 (-)

--00000000000068f89a05f0f8637a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

The idea is good, but how does this play along with the existing
eglot-confirm-server-initiated-edits?

Jo=C3=A3o

--00000000000068f89a05f0f8637a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>The idea is good, but how does this play along with t=
he existing <br></div><div>eglot-confirm-server-initiated-edits?</div><div>=
<br></div><div>Jo=C3=A3o</div></div>

--00000000000068f89a05f0f8637a--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60338; Package emacs. Full text available.

Message received at 60338 <at> debbugs.gnu.org:


Received: (at 60338) by debbugs.gnu.org; 29 Dec 2022 14:29:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 29 09:29:08 2022
Received: from localhost ([127.0.0.1]:59619 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pAttt-000785-5s
	for submit <at> debbugs.gnu.org; Thu, 29 Dec 2022 09:29:08 -0500
Received: from mout01.posteo.de ([185.67.36.65]:48175)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philipk@HIDDEN>) id 1pAttr-00077t-MC
 for 60338 <at> debbugs.gnu.org; Thu, 29 Dec 2022 09:28:52 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id AC3B4240177
 for <60338 <at> debbugs.gnu.org>; Thu, 29 Dec 2022 15:28:45 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1672324125; bh=M8pg2Jf3UE9FOgr2HOWgV/kcKY0vWqo3Ud53lYVlbtY=;
 h=From:To:Cc:Subject:Date:From;
 b=qVkirpHYN7tusSGUSNYSZZMowTrydHwiTZ/z95T9U2EJ+6C4H15Kq7n+Rt6awMzXT
 ZB7qI0fo4w+2eIcK6/BkEoVGuVp56T+wiWf8Brcukf7Jcj+8AAcuPEI4b3odH9Il0n
 2ByW/1HkU2HXmUBeGrobudsHfbogqNcUbfcohWtXVHGcmcxY8zFA8ECyQ92bz6Fvou
 o6u1Z+e0TEiHmlgQPO/Ae//Eh9Myr2pta28xy9KvB0vQgKRFbK2lfqDT2rf7NNEVq8
 p69xgQbbedA9V47mfPJm7CREOUMS201c/Vlf3ublAH7fZoQ4BW8NldleAaEKHGcJlg
 2g0pQIRp6MAbw==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4NjW3J62GYz9rxG;
 Thu, 29 Dec 2022 15:28:44 +0100 (CET)
From: Philip Kaludercic <philipk@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>
Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs
In-Reply-To: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@HIDDEN> (Yuan Fu's
 message of "Wed, 28 Dec 2022 16:01:39 -0800")
References: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@HIDDEN>
Date: Thu, 29 Dec 2022 14:28:50 +0000
Message-ID: <87zgb6gu71.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60338
Cc: 60338 <at> debbugs.gnu.org,
 =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <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 (-)

Yuan Fu <casouri@HIDDEN> writes:

> Philip Kaludercic <philipk@HIDDEN> writes:
>
>> X-CC-Debbugs: 
>>
>> I'd like to propose adding an option that makes server modifications by
>> Eglot less invasive.  The current behaviour is to make the changes
>> directly in a buffer and open the remaining files to make the
>> modifications in those as well (?).  If `eglot-use-diffs' is enabled,
>> all confirmations are prepared as patches in a pop-up buffer that the
>> user can review and apply at will.  To my knowledge there is no general
>> `diff-apply-hunk' that will apply all the changes from a buffer, but
>> that is a separate issue that can be fixed in a separate patch.
>>
>> (Note, I'm still testing emacs-29, so the patch was developed on that
>> branch.  But it should be applied to master)
>
> This seems really nice :-)

Have you tried it out?  My worry is that there are some simple changes
that don't warrant a diff, but I don't know how these can be
distinguished.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60338; Package emacs. Full text available.

Message received at 60338 <at> debbugs.gnu.org:


Received: (at 60338) by debbugs.gnu.org; 29 Dec 2022 00:01:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Dec 28 19:01:48 2022
Received: from localhost ([127.0.0.1]:59015 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pAgMl-0003I5-UW
	for submit <at> debbugs.gnu.org; Wed, 28 Dec 2022 19:01:48 -0500
Received: from mail-pl1-f180.google.com ([209.85.214.180]:45683)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1pAgMk-0003Hk-BE
 for 60338 <at> debbugs.gnu.org; Wed, 28 Dec 2022 19:01:47 -0500
Received: by mail-pl1-f180.google.com with SMTP id g16so7762924plq.12
 for <60338 <at> debbugs.gnu.org>; Wed, 28 Dec 2022 16:01:46 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=/hvsmBYS8W2ZE6pmuBbeQRwUCzOj0szH9OWCM+ZPy2M=;
 b=J6ZlyYfWBmkEDue8VLxCFOKEriyjMJ43rk+Y5H9N4T95J2bAKNe9dezLVhGVCnL370
 YMF8ljaCjnEsts2VZoRH8sxTUkXxY/TNVAotPMxco9ALkV7kaIho8OwItFzXqLABkdFD
 ea3x3HGFlme773VDlKpnuuDYYMLLuJGpBG3tU9UVdnZLGrS8UjRcp9A0Sc765TNtIKsf
 mvw965eOf7mPWbLz6rVnJ7eL+z6GUehr62d+u9JQWy0ZdfcQKYQ9rkV/6TE5os5C8pzq
 80jF9aKOsuJe3eootjLbFpPb9tgYfc/yEPtxMfGH4/6kY8E6P9mocKT3oUQcY9q667AM
 AvLQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=/hvsmBYS8W2ZE6pmuBbeQRwUCzOj0szH9OWCM+ZPy2M=;
 b=lww30tboyDcPBnlp3jajrQsJ/vQV0keJk+nD95k1vlBcByh/XEzhFNisCksd9uicMo
 udvQZPfaKHlAr3un+6rWXIuzlr9r5bDCDdnx24Whe6D36GnP6TzEgiYfjwWA+b3Qq7Ou
 WSAtDTIL1RqgmWnveHjt8uFEID0AI+ae1s01tdf2VcDiqprwgfpIAjDww4i9MD7qUc6i
 AyQTa7bDlbZdoC12OLfzYarfvC/ao1YK/M49UjgfzMJy+qY9d/FGu4Cw5BwuTR3k7Azd
 OQBR8tqNWKkzdfUz+o1eVF4H43LaZRxi9qcsiJrHFWP22q6od+P3wxbqwWSW/gPVjH5i
 eWtQ==
X-Gm-Message-State: AFqh2ko4VoCVV1U7415c2IE9yc2KPnD/q+7dXRckWlm/+tScJMxBpbFu
 iTQQddhByFw0zxw4JmAR9Hw=
X-Google-Smtp-Source: AMrXdXtfYG4N41icL0KMGvUgB8MQgXRRYU9BEvj2djzOVFLP+GMMJzsQFHHO7ZB6yk8Rsq//UVveDg==
X-Received: by 2002:a17:903:24b:b0:187:282d:6990 with SMTP id
 j11-20020a170903024b00b00187282d6990mr13812302plh.28.1672272100632; 
 Wed, 28 Dec 2022 16:01:40 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 e2-20020a17090301c200b001868981a18esm11565082plh.6.2022.12.28.16.01.39
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 28 Dec 2022 16:01:40 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs
Message-Id: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@HIDDEN>
Date: Wed, 28 Dec 2022 16:01:39 -0800
To: Philip Kaludercic <philipk@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60338
Cc: 60338 <at> debbugs.gnu.org
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 (-)


Philip Kaludercic <philipk@HIDDEN> writes:

> X-CC-Debbugs: Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN>
>
> I'd like to propose adding an option that makes server modifications =
by
> Eglot less invasive.  The current behaviour is to make the changes
> directly in a buffer and open the remaining files to make the
> modifications in those as well (?).  If `eglot-use-diffs' is enabled,
> all confirmations are prepared as patches in a pop-up buffer that the
> user can review and apply at will.  To my knowledge there is no =
general
> `diff-apply-hunk' that will apply all the changes from a buffer, but
> that is a separate issue that can be fixed in a separate patch.
>
> (Note, I'm still testing emacs-29, so the patch was developed on that
> branch.  But it should be applied to master)

This seems really nice :-)

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60338; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Dec 2022 13:42:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 26 08:42:08 2022
Received: from localhost ([127.0.0.1]:50961 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p9njz-0002XU-KW
	for submit <at> debbugs.gnu.org; Mon, 26 Dec 2022 08:42:08 -0500
Received: from lists.gnu.org ([209.51.188.17]:52456)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philipk@HIDDEN>) id 1p9njx-0002XN-Tk
 for submit <at> debbugs.gnu.org; Mon, 26 Dec 2022 08:42:06 -0500
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 <philipk@HIDDEN>)
 id 1p9njx-0002Km-JS
 for bug-gnu-emacs@HIDDEN; Mon, 26 Dec 2022 08:42:05 -0500
Received: from mout01.posteo.de ([185.67.36.65])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <philipk@HIDDEN>)
 id 1p9nju-0001hf-BP
 for bug-gnu-emacs@HIDDEN; Mon, 26 Dec 2022 08:42:04 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id F313F2400B2
 for <bug-gnu-emacs@HIDDEN>; Mon, 26 Dec 2022 14:41:59 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1672062120; bh=bS8nNnXEL6mkVLVpquN/9XlkcPcxAp+u3lHMTwvpS5E=;
 h=From:To:Subject:Date:From;
 b=VhF5rNMIlavkdzA4oAq4B02mT+RXFk/mc3xmqgi6nF8cFPQxJGD9O5fEJBxGW1Id6
 381FyAdrYi+dh83Q/1mUjPuEJfqcEHd/DAilzB4VngyizcfTWMZmQTDI2kWKWZC1GZ
 mw3NpKCK3RfaPEO90ibxNDmNx/NRP4kRZJ4VJZxU0r7dEksWTW5UP8XDGwcG07VhGP
 9oWozC68naQmVLe5WSqqZK0InTjbrE8NJreUB25pnA7Na4/Rb94Yl4MSVD2Y/DVyHQ
 e5BVervNbPtVaLGiphDMk3xndzqmO/iXD5cL4EOCdCHg9FsMd+GnyN/E9oBB0D3doZ
 aRGrqoQY5Al2g==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4Ngf8l45Ctz9rxG
 for <bug-gnu-emacs@HIDDEN>; Mon, 26 Dec 2022 14:41:59 +0100 (CET)
From: Philip Kaludercic <philipk@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Add option to present server changes as diffs
Date: Mon, 26 Dec 2022 13:42:04 +0000
Message-ID: <87ilhy1dub.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@HIDDEN;
 helo=mout01.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 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,
 RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.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

X-CC-Debbugs: Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN>

I'd like to propose adding an option that makes server modifications by
Eglot less invasive.  The current behaviour is to make the changes
directly in a buffer and open the remaining files to make the
modifications in those as well (?).  If `eglot-use-diffs' is enabled,
all confirmations are prepared as patches in a pop-up buffer that the
user can review and apply at will.  To my knowledge there is no general
`diff-apply-hunk' that will apply all the changes from a buffer, but
that is a separate issue that can be fixed in a separate patch.

(Note, I'm still testing emacs-29, so the patch was developed on that
branch.  But it should be applied to master)


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment
Content-Description: [PATCH] Add option to present server changes as diffs

From 88ba620b47b7987d203fc5b42716fa08be3b1d8f Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@HIDDEN>
Date: Mon, 26 Dec 2022 11:06:09 +0100
Subject: [PATCH] Add option to present server changes as diffs

* lisp/progmodes/eglot.el (eglot-use-diffs): Add new user option.
(eglot--apply-workspace-edit): Respect 'eglot-use-diffs'.
* doc/misc/eglot.texi (Customizing Eglot): Document 'eglot-use-diffs'.
---
 doc/misc/eglot.texi     |  7 ++++++
 lisp/progmodes/eglot.el | 54 ++++++++++++++++++++++++++++++++---------
 2 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/doc/misc/eglot.texi b/doc/misc/eglot.texi
index 2aff038b9a..9150e1a879 100644
--- a/doc/misc/eglot.texi
+++ b/doc/misc/eglot.texi
@@ -955,6 +955,13 @@ Customizing Eglot
 to use Eglot in your @code{eglot-managed-mode-hook} or via some other
 mechanism.
 
+@vindex eglot-use-diffs
+@item eglot-use-diffs
+If this option is enabled, any server modifications (renames, code
+actions, refactoring, @dots{}) will be presented as diffs that the
+user can selectively apply.  The default is that all modifications are
+made in place.
+
 @vindex eglot-report-progress
 @cindex progress
 @item eglot-report-progress
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 15cb1b6fad..74472b25ce 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -111,6 +111,8 @@
 (require 'ert)
 (require 'array)
 (require 'external-completion)
+(require 'diff-mode)
+(require 'diff)
 
 ;; ElDoc is preloaded in Emacs, so `require'-ing won't guarantee we are
 ;; using the latest version from GNU Elpa when we load eglot.el.  Use an
@@ -3160,6 +3162,11 @@ eglot--apply-text-edits
       (undo-amalgamate-change-group change-group)
       (progress-reporter-done reporter))))
 
+(defcustom eglot-use-diffs nil
+  "Non-nil means that server changes are presented as diffs."
+  :type 'boolean
+  :version "30.1")
+
 (defun eglot--apply-workspace-edit (wedit &optional confirm)
   "Apply the workspace edit WEDIT.  If CONFIRM, ask user first."
   (eglot--dbind ((WorkspaceEdit) changes documentChanges) wedit
@@ -3175,18 +3182,41 @@ eglot--apply-workspace-edit
         ;; prefer documentChanges over changes.
         (cl-loop for (uri edits) on changes by #'cddr
                  do (push (list (eglot--uri-to-path uri) edits) prepared)))
-      (if (or confirm
-              (cl-notevery #'find-buffer-visiting
-                           (mapcar #'car prepared)))
-          (unless (y-or-n-p
-                   (format "[eglot] Server wants to edit:\n  %s\n Proceed? "
-                           (mapconcat #'identity (mapcar #'car prepared) "\n  ")))
-            (jsonrpc-error "User canceled server 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))
-               finally (eldoc) (eglot--message "Edit successful!")))))
+      (if eglot-use-diffs
+          (with-current-buffer (get-buffer-create " *Server Changes*")
+            (buffer-disable-undo (current-buffer))
+            (let ((buffer-read-only t))
+              (diff-mode))
+            (let ((inhibit-read-only t)
+                  (target (current-buffer)))
+              (erase-buffer)
+              (pcase-dolist (`(,path ,edits ,_) prepared)
+                (with-temp-buffer
+                  (let ((diff (current-buffer)))
+                    (with-temp-buffer
+                      (insert-file-contents path)
+                      (eglot--apply-text-edits edits)
+                      (diff-no-select path (current-buffer)
+                                      nil t diff))
+                    (with-current-buffer target
+                      (insert-buffer-substring diff))))))
+            (setq-local buffer-read-only t)
+            (buffer-enable-undo (current-buffer))
+            (goto-char (point-min))
+            (pop-to-buffer (current-buffer))
+            (font-lock-ensure))
+        (if (or confirm
+                (cl-notevery #'find-buffer-visiting
+                             (mapcar #'car prepared)))
+            (unless (y-or-n-p
+                     (format "[eglot] Server wants to edit:\n  %s\n Proceed? "
+                             (mapconcat #'identity (mapcar #'car prepared) "\n  ")))
+              (jsonrpc-error "User canceled server 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))
+                 finally (eldoc) (eglot--message "Edit successful!"))))))
 
 (defun eglot-rename (newname)
   "Rename the current symbol to NEWNAME."
-- 
2.35.1


--=-=-=--




Acknowledgement sent to Philip Kaludercic <philipk@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#60338; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 30 Dec 2022 13:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.