From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 26 08:42:08 2022 Received: (at submit) by debbugs.gnu.org; 26 Dec 2022 13:42:08 +0000 Received: from localhost ([127.0.0.1]:50961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9njz-0002XU-KW for submit@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 ) id 1p9njx-0002XN-Tk for submit@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 ) id 1p9njx-0002Km-JS for bug-gnu-emacs@gnu.org; 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 ) id 1p9nju-0001hf-BP for bug-gnu-emacs@gnu.org; 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 ; 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 ; Mon, 26 Dec 2022 14:41:59 +0100 (CET) From: Philip Kaludercic To: bug-gnu-emacs@gnu.org Subject: [PATCH] Add option to present server changes as diffs Date: Mon, 26 Dec 2022 13:42:04 +0000 Message-ID: <87ilhy1dub.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 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 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 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 28 19:01:48 2022 Received: (at 60338) by debbugs.gnu.org; 29 Dec 2022 00:01:48 +0000 Received: from localhost ([127.0.0.1]:59015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAgMl-0003I5-UW for submit@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 ) id 1pAgMk-0003Hk-BE for 60338@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@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 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@gmail.com> Date: Wed, 28 Dec 2022 16:01:39 -0800 To: Philip Kaludercic X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60338 Cc: 60338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Philip Kaludercic writes: > X-CC-Debbugs: Jo=C3=A3o T=C3=A1vora > > 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 From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 29 09:29:08 2022 Received: (at 60338) by debbugs.gnu.org; 29 Dec 2022 14:29:08 +0000 Received: from localhost ([127.0.0.1]:59619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAttt-000785-5s for submit@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 ) id 1pAttr-00077t-MC for 60338@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@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 To: Yuan Fu Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@gmail.com> (Yuan Fu's message of "Wed, 28 Dec 2022 16:01:39 -0800") References: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@gmail.com> Date: Thu, 29 Dec 2022 14:28:50 +0000 Message-ID: <87zgb6gu71.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: 60338@debbugs.gnu.org, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Yuan Fu writes: > Philip Kaludercic 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 29 09:35:02 2022 Received: (at 60338) by debbugs.gnu.org; 29 Dec 2022 14:35:02 +0000 Received: from localhost ([127.0.0.1]:59632 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAtzq-0007IP-61 for submit@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 ) id 1pAtzn-0007I5-PB for 60338@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@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@gmail.com> <87zgb6gu71.fsf@posteo.net> In-Reply-To: <87zgb6gu71.fsf@posteo.net> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Thu, 29 Dec 2022 14:36:13 +0000 Message-ID: Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs To: Philip Kaludercic Content-Type: multipart/alternative; boundary="00000000000068f89a05f0f8637a" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60338 Cc: Yuan Fu , 60338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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
The idea is good, but how does this play along with t= he existing
eglot-confirm-server-initiated-edits?
=
Jo=C3=A3o
--00000000000068f89a05f0f8637a-- From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 29 09:39:49 2022 Received: (at 60338) by debbugs.gnu.org; 29 Dec 2022 14:39:49 +0000 Received: from localhost ([127.0.0.1]:59638 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAu4S-0007Po-Vg for submit@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 ) id 1pAu4R-0007PZ-Dj for 60338@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@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 To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: (=?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@gmail.com> <87zgb6gu71.fsf@posteo.net> Date: Thu, 29 Dec 2022 14:39:45 +0000 Message-ID: <87v8lugtou.fsf@posteo.net> 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 , 60338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Jo=C3=A3o T=C3=A1vora 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 From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 30 08:11:53 2022 Received: (at 60338) by debbugs.gnu.org; 30 Dec 2022 13:11:53 +0000 Received: from localhost ([127.0.0.1]:33707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBFAu-0001n7-PI for submit@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 ) id 1pBFAt-0001ms-2L for 60338@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@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@gmail.com> <87zgb6gu71.fsf@posteo.net> <87v8lugtou.fsf@posteo.net> In-Reply-To: <87v8lugtou.fsf@posteo.net> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Fri, 30 Dec 2022 13:13:05 +0000 Message-ID: Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs To: Philip Kaludercic Content-Type: multipart/alternative; boundary="000000000000e9ffa205f10b57ba" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60338 Cc: Yuan Fu , 60338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 wrote: > Jo=C3=A3o T=C3=A1vora 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

On Thu, Dec 29, 2022 at 2:39 PM Philip Ka= ludercic <philipk@posteo.net&g= t; wrote:
Jo=C3= =A3o T=C3=A1vora <joaotavora@gmail.com> 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.=C2=A0 = 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 enoug= h, unfortunately.

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

Here is s= ome information to get started with the investigation.

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

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

2. = When the user chooses a code action from a list of code actions presented
as a menu and that code action happens to contain an edit.=C2=A0 T= his also ignores
eglot-c-s-initiated-edits.=C2=A0 The locus o= f 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 tha= t makes the server initiate a code action.
The locus is eglo= t--handle-request (for workspace/applyEdit).=C2=A0 Here
eglot-con= firm-server-initiated-edits is read honoured.=C2=A0 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.

No= te that the differences between 2 and 3 are subtle, and perhaps conceptuall= y
non-existent, but technically they do exist.=C2=A0 In 2, the ed= it is immediately
available whereas in 3, a further server trip i= s required to get the edit to apply.

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

Currently, the confirmat= ion happens also (regardless of the value of
eglot-confirm-s= erver-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 confirm= ation of edits more consistent and predictable across the
various= use cases.

Then, as I've already said, the &q= uot;diff" method of confirmation sounds in
principle ve= ry robust=C2=A0 and in-line with Emacs' principles. It could eventually=
even be made the default.

Jo=C3=A3= o


--000000000000e9ffa205f10b57ba-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 30 10:09:12 2022 Received: (at 60338) by debbugs.gnu.org; 30 Dec 2022 15:09:13 +0000 Received: from localhost ([127.0.0.1]:35924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBH0S-0007g1-F8 for submit@debbugs.gnu.org; Fri, 30 Dec 2022 10:09:12 -0500 Received: from mout02.posteo.de ([185.67.36.66]:59585) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBH0Q-0007fm-2s for 60338@debbugs.gnu.org; Fri, 30 Dec 2022 10:09:10 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 314B8240188 for <60338@debbugs.gnu.org>; Fri, 30 Dec 2022 16:09:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1672412944; bh=hPxlXii7jY5XhpF+N/6PKFWOe6yPhdwoP3oh0aZ4u9A=; h=From:To:Cc:Subject:Date:From; b=TSoVrXYcySF+f9vccud+YLZZH7wcriSnzanoAXG5gEHcuuhtteRY2bShPUgGkeuM+ dew9Fg7CHb7VQ1RmsE4GdaT7FzdTNPTHpqSUYAG/oOY08PK/K/4FkOIwfYMHD5Ktbt u3nnczESNebqtUN73WSMJIMjkUV7zX/yIvmrCbMEIjeOCLuYNoetvtS7f9NGI0fq9+ ZD6/1uz7Imi9QVzipb4NNlWt+cx7pkiLf1dLVtCkqRQHuVSwP+oUbeCRsIfJbxjOFX ylML7+nyJDyMjqUyI12gGWCTts0pwmr0/bFJghZPZlkQatIAwPLB34eJRtPyc3nbAU aX7Fc06tM0mxw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Nk7vL5G8Qz9rxD; Fri, 30 Dec 2022 16:09:00 +0100 (CET) From: Philip Kaludercic To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Fri, 30 Dec 2022 13:13:05 +0000") References: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@gmail.com> <87zgb6gu71.fsf@posteo.net> <87v8lugtou.fsf@posteo.net> Date: Fri, 30 Dec 2022 15:09:06 +0000 Message-ID: <87k0297wtp.fsf@posteo.net> 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 , 60338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Jo=C3=A3o T=C3=A1vora writes: > On Thu, Dec 29, 2022 at 2:39 PM Philip Kaludercic > wrote: > >> Jo=C3=A3o T=C3=A1vora 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 th= is > 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. This is also one of the situations where I believe that a diff is not necessary, since the change is predictable. > 2. When the user chooses a code action from a list of code actions presen= ted > 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 t= he > 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 immediate= ly > available whereas in 3, a further server trip is required to get the edit > to apply. I am afraid I can't conceptualise the difference between the two. The 2. is probably what I am familiar with, but when does the server initiate a code action. Are we talking about an unprompted change? Or something like code formatting? > Moreover, the current method of "confirmation" is just a prompt that lis= ts > 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. Would you say that this means we should always generate a diff and only apply it when the user confirms the change, or is the cost of doubling the communication acceptable? > 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. So in the sense that a diff is presented as a kind of confirmation, along with the option to apply all the changes immediately. All in all, this makes me less certain that merging the change into `eglot-confirm-server-initiated-edits' is the right approach. > Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 04 15:56:40 2023 Received: (at 60338) by debbugs.gnu.org; 4 Jan 2023 20:56:40 +0000 Received: from localhost ([127.0.0.1]:49743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDAoS-00045I-0t for submit@debbugs.gnu.org; Wed, 04 Jan 2023 15:56:40 -0500 Received: from mail-ed1-f44.google.com ([209.85.208.44]:36550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDAoQ-000454-5p for 60338@debbugs.gnu.org; Wed, 04 Jan 2023 15:56:38 -0500 Received: by mail-ed1-f44.google.com with SMTP id m21so50233139edc.3 for <60338@debbugs.gnu.org>; Wed, 04 Jan 2023 12:56:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=MKcuKpRQqn8vRy/oaCUA+G44NpbIVBgYvr5c3AXHU+M=; b=LnpevdGYS4nrAYecjVzVZX+5w7WqmHEdGWOnexc1DdMu9olDHfYHpScSKosgsYchDo XiMoC/2OexCIjQHYIy75CQ7BqVe092hPhqt+haSVHHcrqHuXkFftzlacHGD01/yYHmtP uWf+16AQwAAHClvVTNS1u2sV/CWktAUFuw9Dp6WTd2RD91JrUgVj6+aIKDZBtqOwcieU 4kBWJN4XbOpPfM6P4fT47wIMnOeJcpHXkgVtm0reaISW5KepYBMPOv6jRdm82LYq6Uik vLuvxZSPanHC5DPVn0py0b+SobQyu120czdxjEQKDLFZilLs7GhtxIYC50o4lzTqw0Uf rnMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=MKcuKpRQqn8vRy/oaCUA+G44NpbIVBgYvr5c3AXHU+M=; b=6c9dGtm0f8OlSa4ndt7ENBpnBvXOUG3NLsRm4/AH+AOTs7tZN9c8e2IVRByC7/DofP lZPQsFYOmUk1n4Sr+x5gyDsMRrQZeCRi/7BBH9rCcFltuBN5C8pxuQRPtjVsRHLSVlPu gUwDBguj5xZ5guw9qB31xClWFHWkLNe5SyP1neQms7px1xC0AUn+0vTp5rjFmvAPzphX SIKPKWcXc3wT55YEAKgRHGaHlUSQc0OUnT0EQnLkIQ2elYTuXpjIK5ibYdZKeFZ80/U4 YNljKE9p/8LcuZo94GbRJHXGQKacsW/bCitrCnvrIpV0vQdhqNSdW8ASkxHac3Ogfucu 1XVA== X-Gm-Message-State: AFqh2krWds3JG9uvEPM8mtZ1S3WS2XF3PoxKs+IJoEtquLHr+8RJiidS khDTEhy1zklfO0WSATngEf9exRqaA48= X-Google-Smtp-Source: AMrXdXuOsrV5LnzzSOMUbEw5TKD0u6euL6/c3fsFlUiPTlKQyXcTvDgnfn/5oYbbNMSkwVgg5tpQCA== X-Received: by 2002:a05:6402:ca8:b0:490:30a0:21be with SMTP id cn8-20020a0564020ca800b0049030a021bemr2041275edb.18.1672865791678; Wed, 04 Jan 2023 12:56:31 -0800 (PST) Received: from betli.gmail.com (catv-86-101-66-128.catv.fixed.vodafone.hu. [86.101.66.128]) by smtp.gmail.com with ESMTPSA id l26-20020a056402125a00b0046b471596e6sm15376563edw.57.2023.01.04.12.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 12:56:30 -0800 (PST) From: Felician Nemeth To: Philip Kaludercic Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs References: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@gmail.com> <87zgb6gu71.fsf@posteo.net> <87v8lugtou.fsf@posteo.net> <87k0297wtp.fsf@posteo.net> Date: Wed, 04 Jan 2023 21:56:29 +0100 In-Reply-To: <87k0297wtp.fsf@posteo.net> (Philip Kaludercic's message of "Fri, 30 Dec 2022 15:09:06 +0000") Message-ID: <87lemi6mte.fsf@betli.tmit.bme.hu> 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: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60338 Cc: Yuan Fu , 60338@debbugs.gnu.org, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is going to be a bit off-topic, but I'm guessing that users (after a while) get used to what they can expect from a specific language server when it comes to code-actions. And with a well written server, users should never want to partially apply a server initiated text-edit. Therefore it might be a better UI to apply every text-edit without questions, display a message when the changes are not visible ("Changed 100 lines in 10 files"), provide a command to view the last text-edit as a diff, and allow the users to undo the change with a single undo command. This UI wouldn't slow down experienced users, and it would allow them to quickly correct rare mistakes. Eglot could also teach inexperienced users with messages like "Changed 2 lines in 1 file. `undo-view-last' shows the change." WDT? From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 09 03:56:00 2023 Received: (at 60338) by debbugs.gnu.org; 9 Jun 2023 07:56:00 +0000 Received: from localhost ([127.0.0.1]:58255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q7WyW-0006mJ-8C for submit@debbugs.gnu.org; Fri, 09 Jun 2023 03:56:00 -0400 Received: from mout01.posteo.de ([185.67.36.65]:55003) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q7WyS-0006m4-PF for 60338@debbugs.gnu.org; Fri, 09 Jun 2023 03:55:59 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id CFBB2240027 for <60338@debbugs.gnu.org>; Fri, 9 Jun 2023 09:55:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686297350; bh=iGb9oIGgO2EV9HfoY9Z0qssghY2d8df8R8kGhF1c3ro=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=FZEkH1rHM5XHdXYvEiD45DRqe1it6BuXiSg1UDUQzTfPZSm14FuwBW9Lofd4V2V3y 7WbKl7oJVns4BemA46UbQXfKAMrC82FGTWQCaSWdSpiooPDOQSfiMC2F7NNoQWJweH OCZZxZB0S+qGId0LU2pTwl/crghFERqEiTHp6CHSlLbOZ3nKU/hujjtLXYVQKsDQb4 3HD3Ao8BmbdHPY9ZHZ604ayQQZZQckjbehMKbcdqh5bWbgG2zFoK5LiJnSG0ZYkjpq xrW3bRZJ5BD9eC6BYOO+O6D3/DRIGMmiyRGtCRge/1aBJ7syPPhPkmJoIJwLNEmGPZ hZInRhd3HKyRA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QctgB0xBFz6txP; Fri, 9 Jun 2023 09:55:50 +0200 (CEST) From: Philip Kaludercic To: Felician Nemeth Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <87lemi6mte.fsf@betli.tmit.bme.hu> (Felician Nemeth's message of "Wed, 04 Jan 2023 21:56:29 +0100") References: <6829F6A2-C6FD-4807-B3D2-1E740ED496BC@gmail.com> <87zgb6gu71.fsf@posteo.net> <87v8lugtou.fsf@posteo.net> <87k0297wtp.fsf@posteo.net> <87lemi6mte.fsf@betli.tmit.bme.hu> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Fri, 09 Jun 2023 07:55:49 +0000 Message-ID: <87ttvht6gq.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: Yuan Fu , 60338@debbugs.gnu.org, =?utf-8?B?Sm8=?= =?utf-8?B?w6NvIFTDoXZvcmE=?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) (Sorry for the delay in answering, I forgot about this thread) Felician Nemeth writes: > This is going to be a bit off-topic, but I'm guessing that users (after > a while) get used to what they can expect from a specific language > server when it comes to code-actions. And with a well written server, > users should never want to partially apply a server initiated text-edit. > > Therefore it might be a better UI to apply every text-edit without > questions, display a message when the changes are not visible ("Changed > 100 lines in 10 files"), provide a command to view the last text-edit as > a diff, and allow the users to undo the change with a single undo > command. > > This UI wouldn't slow down experienced users, and it would allow them to > quickly correct rare mistakes. Eglot could also teach inexperienced > users with messages like "Changed 2 lines in 1 file. `undo-view-last' > shows the change." > > WDT? In principle this should be ok, but there are users who for whatever reason do not want the language server to modify the files (e.g. because they don't like it in principle, or because the language is /not/ well written). I tend towards that camp, and which is why I wrote the patch in the first place. The other issue is that the patch would have to be generated before any changes are applied, so that the user can inspect it after the server made the changes, regardless of whether or not they will be interested or not. I am not sure how much waste this will generate, and if it is really worth it, compared to having a diff as a "prompt". From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 11 17:33:51 2023 Received: (at 60338) by debbugs.gnu.org; 11 Jun 2023 21:33:51 +0000 Received: from localhost ([127.0.0.1]:37787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8Sh4-0008C5-CU for submit@debbugs.gnu.org; Sun, 11 Jun 2023 17:33:50 -0400 Received: from mout01.posteo.de ([185.67.36.65]:48001) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8Sh1-0008Bo-2t for 60338@debbugs.gnu.org; Sun, 11 Jun 2023 17:33:48 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 52584240028 for <60338@debbugs.gnu.org>; Sun, 11 Jun 2023 23:33:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686519221; bh=0oMNeE9uEwHNkkXEXFBHLU5AFc5P6wlqT7QzDy4R824=; h=From:To:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=p79NsalpTgXw+kdrG0Pp6+uuL49h4H4lKRfMgSqy2k74DCFojApNTFIJjyqcaG2Yc lcsh33HGD5tUTI8sTA/TbRl9TpzSKSFCYRih3/RRq4sVev3GcnlndphUGS0Yt6ct2h kNnvPCEwptd9ONUVlYd58LvvDOVMAZMsdjFAqAWyRuO2OgGdbFb5WmhysL/udja5eS oCJ9spIKKVgPEJSGywWl3QWiTU5K79ORRiXK9L1qu4nm+O5upcmFOm0Fy+imNcaoZF OOR9yVkGy6CjSrHYn2WJYtWqRrXUQ+Pqcn0twXwD2zjXQCwvx5T5l7uwGq/JejX4Az WhMG0QgfwvfLw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QfSjw6zszz6tmv; Sun, 11 Jun 2023 23:33:40 +0200 (CEST) From: Philip Kaludercic To: 60338@debbugs.gnu.org, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <87ilhy1dub.fsf@posteo.net> (Philip Kaludercic's message of "Mon, 26 Dec 2022 13:42:04 +0000") References: <87ilhy1dub.fsf@posteo.net> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Sun, 11 Jun 2023 21:33:40 +0000 Message-ID: <877cs97kgb.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain The previous patch couldn't be applied onto master anymore, so I have adjusted it and merged the user option into 'eglot-confirm-server-initiated-edits'. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Allow-for-LSP-edits-to-be-generated-as-diffs.patch >From 7263d821c2d217c5748965aad57df8c0311f7e95 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sun, 11 Jun 2023 23:18:12 +0200 Subject: [PATCH 1/2] Allow for LSP edits to be generated as diffs * doc/misc/eglot.texi (Eglot Variables): Document the new behaviour. * lisp/progmodes/eglot.el (eglot-confirm-server-initiated-edits): Add new value 'diff'. (eglot-execute): Check if 'eglot-confirm-server-initiated-edits' is set to 'diff'. (eglot--apply-workspace-edit): Respect the new 'diff' value. (eglot-rename): Pass 'eglot-confirm-server-initiated-edits' instead of just the value 'current-prefix-arg'. (Bug#60338) --- doc/misc/eglot.texi | 6 ++-- lisp/progmodes/eglot.el | 62 +++++++++++++++++++++++++++++++---------- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/doc/misc/eglot.texi b/doc/misc/eglot.texi index 962e6c914ce..305feda43a6 100644 --- a/doc/misc/eglot.texi +++ b/doc/misc/eglot.texi @@ -833,9 +833,11 @@ Eglot Variables @item eglot-confirm-server-initiated-edits Various Eglot commands and code actions result in the language server sending editing commands to Emacs. If this option's value is -non-@code{nil} (the default), Eglot will ask for confirmation before +@code{confirm} (the default), Eglot will ask for confirmation before performing edits initiated by the server or edits whose scope affects -buffers other than the one where the user initiated the request. +buffers other than the one where the user initiated the request. If +set to @code{diff}, Eglot will generate and display a diff to display +the changes. @item eglot-ignored-server-capabilities This variable's value is a list of language server capabilities that diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 7d5d786dea3..9c9c3152472 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -108,6 +108,7 @@ (require 'filenotify) (require 'ert) (require 'text-property-search nil t) +(require 'diff) ;; These dependencies are also GNU ELPA core packages. Because of ;; bug#62576, since there is a risk that M-x package-install, despite @@ -386,9 +387,14 @@ eglot-events-buffer-size :type '(choice (const :tag "No limit" nil) (integer :tag "Number of characters"))) (defcustom eglot-confirm-server-initiated-edits 'confirm - "Non-nil if server-initiated edits should be confirmed with user." + "Control how server edits are applied. +If set to `confirm', a prompt is presented to confirm server +changes. If set to `diff', a buffer will pop up with changes +that can be applied manually. If set to nil, modifications are +made automatically." :type '(choice (const :tag "Don't show confirmation prompt" nil) + (const :tag "Present as diffs in a buffer" diff) (const :tag "Show confirmation prompt" confirm))) (defcustom eglot-extend-to-xref nil @@ -740,7 +746,8 @@ eglot-execute (eglot--dcase action (((Command)) (eglot--request server :workspace/executeCommand action)) (((CodeAction) edit command) - (when edit (eglot--apply-workspace-edit edit)) + (when edit + (eglot--apply-workspace-edit edit (eq eglot-confirm-server-initiated-edits t))) (when command (eglot--request server :workspace/executeCommand command)))))) (cl-defgeneric eglot-initialization-options (server) @@ -3408,18 +3415,43 @@ 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 + (cond + ((eq confirm 'diff) + (with-current-buffer (get-buffer-create " *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))) + ((and (or (eq confirm 'confirm) + (cl-find-if-not #'find-buffer-visiting prepared + :key #'car)) + ;; Should the list of buffers be popped up temporarily in + ;; a buffer instead of resizing the minibufffer? + (not (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!"))))) + (mapconcat #'identity (mapcar #'car prepared) "\n "))))) + (jsonrpc-error "User canceled server edit")) + ((cl-loop for (path edits version) in prepared + 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." @@ -3434,7 +3466,7 @@ eglot-rename (eglot--request (eglot--current-server-or-lose) :textDocument/rename `(,@(eglot--TextDocumentPositionParams) :newName ,newname)) - current-prefix-arg)) + (and current-prefix-arg eglot-confirm-server-initiated-edits))) (defun eglot--region-bounds () "Region bounds if active, else bounds of things at point." -- 2.39.2 --=-=-= Content-Type: text/plain In addition to that, here is a cheap command that would allow for a patch to be applied with a single command. I've bound it to C-c C-x, but perhaps there is a more intuitive key? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Add-command-to-apply-an-entire-diff-at-once.patch >From 1cf6f09318860a8232f5850c0d1ca497d8c621f9 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sun, 11 Jun 2023 23:30:03 +0200 Subject: [PATCH 2/2] Add command to apply an entire diff at once * lisp/vc/diff-mode.el (diff-mode-map): Bind 'diff-apply-everything'. (diff-apply-everything): Add new command. --- lisp/vc/diff-mode.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index d776375d681..d81f0af365e 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -216,6 +216,7 @@ diff-mode-map "C-x 4 A" #'diff-add-change-log-entries-other-window ;; Misc operations. "C-c C-a" #'diff-apply-hunk + "C-c C-x" #'diff-apply-everything "C-c C-e" #'diff-ediff-patch "C-c C-n" #'diff-restrict-view "C-c C-s" #'diff-split-hunk @@ -2033,6 +2034,16 @@ diff-apply-hunk (when diff-advance-after-apply-hunk (diff-hunk-next)))))) +(defun diff-apply-everything () + "Apply the entire diff." + (interactive) + (save-excursion + (goto-char (point-min)) + (while (let ((inhibit-message t) + (start (point))) + (diff-hunk-next) + (/= start (point))) + (diff-apply-hunk)))) (defun diff-test-hunk (&optional reverse) "See whether it's possible to apply the current hunk. -- 2.39.2 --=-=-= Content-Type: text/plain Philip Kaludercic 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) -- Philip Kaludercic --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 12 07:56:25 2023 Received: (at 60338) by debbugs.gnu.org; 12 Jun 2023 11:56:25 +0000 Received: from localhost ([127.0.0.1]:39120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8g9o-0000Nx-Lx for submit@debbugs.gnu.org; Mon, 12 Jun 2023 07:56:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8g9m-0000Nj-6C for 60338@debbugs.gnu.org; Mon, 12 Jun 2023 07:56:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q8g9f-0002G6-Nl; Mon, 12 Jun 2023 07:56:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Jzd/ACu1UV7G37ETS6pjGg4j1N6c3AeFy4ebv5oeA5E=; b=RiU6UwvKRQ8c JaZbEXKljzOIJfq232OyvI00zF3yO6ZPMLfUmCdsd9rcwnWC31T8g3L7nh4V55+o0Uc+xb1tmxbyN XirmeH/5vJOzhwNRjRLxhdX4pCvt3YgpJ8Q4cud9dXMlh2T7TpS8934qsD6sgQzJZq4m5y80on7hz LJ7ccikSYU+h2EBHBpZQlAgPrFTbArnpnt+Q/DNWBl89de93ExUpYOLkJJ/IRuG14oCA953QyQ+2k 58ZfJMCrrCN3cBr7ER/lbsEl2+koFR4aM4PE4km75dLm+QlmOzOuPki1/4AyzIJk3cCCpFXcIGDjg OtdBwXMPXvL+Wsu7E5Hu/g==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q8g9f-0006MS-7J; Mon, 12 Jun 2023 07:56:15 -0400 Date: Mon, 12 Jun 2023 14:56:30 +0300 Message-Id: <83jzw8yjv5.fsf@gnu.org> From: Eli Zaretskii To: Philip Kaludercic In-Reply-To: <877cs97kgb.fsf@posteo.net> (message from Philip Kaludercic on Sun, 11 Jun 2023 21:33:40 +0000) Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Philip Kaludercic > Date: Sun, 11 Jun 2023 21:33:40 +0000 > > + ((eq confirm 'diff) > + (with-current-buffer (get-buffer-create " *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)) Isn't there a better way of presenting the edits in human-readable form than apply them and then run Diff? What format is used by the server itself to send the edits? Besides, this assumes the 'diff' command is available, which is not portable -- one more reason not to go that way, or at leas provide an alternative. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 12 08:35:20 2023 Received: (at 60338) by debbugs.gnu.org; 12 Jun 2023 12:35:20 +0000 Received: from localhost ([127.0.0.1]:39152 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8glU-0001cf-9q for submit@debbugs.gnu.org; Mon, 12 Jun 2023 08:35:20 -0400 Received: from mout02.posteo.de ([185.67.36.66]:52955) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8glP-0001cK-V4 for 60338@debbugs.gnu.org; Mon, 12 Jun 2023 08:35:19 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2CF41240103 for <60338@debbugs.gnu.org>; Mon, 12 Jun 2023 14:35:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686573310; bh=dMORhE3bQ8NZ8OKwt+VGExodni/14utxLZ7Kqb6W/lc=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=TydMPTPMnbUFcvcNcWT9lLVXNESCB21Q+57q+3S9ROuVUn87j87kY9kQk9E1Iax4G tsTWoeGk0rRqXi5SdJw+oVYZiZsTx7h80ikHbZgMn4IYdbrwZsk0+QJU3A5JatHeva jQ4ol8y1Mpdwp9CVMJ6VtJdMPDD+nGM6L2A1MWhCyTwFrEwyfijsSlXhNIpU3FLEtV Hjau0WInfGDHbNYc6uugiZ7+FQeNYhw7r9i6unMbfpyZUFHhyjGFCOX0pMz2jP/tyK 8pAgnOzAYyyoz9TK+64xzH7P6lbHx9FxlAvK5YqKfg8RjlQ8TNDR/LDQo3d3YMvmsQ AAZ2LLOYRvmQw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Qfrk53xZdz9rxS; Mon, 12 Jun 2023 14:35:09 +0200 (CEST) From: Philip Kaludercic To: Eli Zaretskii Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <83jzw8yjv5.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 12 Jun 2023 14:56:30 +0300") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> X-Hashcash: 1:20:230612:joaotavora@gmail.com::XUDleUn3HJbZccHk:03bl X-Hashcash: 1:20:230612:eliz@gnu.org::d++XZLETjeEPMkTs:J9xq X-Hashcash: 1:20:230612:60338@debbugs.gnu.org::WsMyxn4/r7WdvOnB:DM9C Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Mon, 12 Jun 2023 12:35:09 +0000 Message-ID: <877cs8g8oy.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> From: Philip Kaludercic >> Date: Sun, 11 Jun 2023 21:33:40 +0000 >> >> + ((eq confirm 'diff) >> + (with-current-buffer (get-buffer-create " *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)) > > Isn't there a better way of presenting the edits in human-readable > form than apply them and then run Diff? What format is used by the > server itself to send the edits? The server sends a JSON message. Here is an example from a little toy project of mine in C, where I intentionally uncommented a #include directive: --8<---------------cut here---------------start------------->8--- (:id 51 :jsonrpc "2.0" :result [(:diagnostics [(:code "-Wimplicit-function-declaration" :message "Implicitly declaring library function 'strcmp' with type 'int (const char *, const char *)' (fix available)" :range (:end (:character 21 :line 63) :start (:character 15 :line 63)) :severity 2 :source "clang")] :edit (:changes (:file:///home/philip/Source/sgo/sgo.c [(:newText "#include \n" :range (:end (:character 0 :line 25) :start (:character 0 :line 25)))])) :isPreferred t :kind "quickfix" :title "Include for symbol strcmp")]) --8<---------------cut here---------------end--------------->8--- The server gives me a diagnostic and suggests a change. The change is just a replacement of a text range with a string: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textEdit > Besides, this assumes the 'diff' command is available, which is not > portable -- one more reason not to go that way, or at leas provide an > alternative. I am personally fond of this approach, because I get a regular text buffer that I can store or send someone. The fact that diff is not available everywhere (even though I would guess any system with a language server /should/ have diff installed), is an argument against enabling this behaviour by default, not against providing this interface. -- Philip Kaludercic From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 12 08:52:00 2023 Received: (at 60338) by debbugs.gnu.org; 12 Jun 2023 12:52:00 +0000 Received: from localhost ([127.0.0.1]:39162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8h1c-0002AM-DD for submit@debbugs.gnu.org; Mon, 12 Jun 2023 08:52:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8h1X-0002A2-ID for 60338@debbugs.gnu.org; Mon, 12 Jun 2023 08:51:59 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q8h1Q-0005DR-W5; Mon, 12 Jun 2023 08:51:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=gXI0G4kXCBE5eZwzdEUbWzvYmRcWmISCDFaEX+NkvWc=; b=RNeZF+vnp+Tk sONAu648UtsPRM7Os3XPEvoFHkNGTYLz4C0lIzyx1bzCjbUIaF6sU0JOX1DeBrKjHEiwmdvnG7yN/ gFpAcNKJJjlBafWPVa6fen5LMwO6C4DEpUs74GZLjR/dimWu2iqWkT/Iy28czmv/gEWSCJ6DVLT+q rsInaSG5SXWaicd1QlUbGmrTubJY0htYFK9TMrcO39mEc1WD2xFuw8ev0V1DCts56xHgF8UThLsLn YUS644WPwS33d0jaTneT/Ub4vGRiS9nzUrKebP2V0e0WxtuZP4mVgvdFsLjvXGgcbuUXu371XHma4 MKIa5p7EOLgn/zlrNYhqsg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q8h1Q-0004QK-G0; Mon, 12 Jun 2023 08:51:48 -0400 Date: Mon, 12 Jun 2023 15:52:03 +0300 Message-Id: <83fs6wyhak.fsf@gnu.org> From: Eli Zaretskii To: Philip Kaludercic In-Reply-To: <877cs8g8oy.fsf@posteo.net> (message from Philip Kaludercic on Mon, 12 Jun 2023 12:35:09 +0000) Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Philip Kaludercic > Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com > Date: Mon, 12 Jun 2023 12:35:09 +0000 > > Eli Zaretskii writes: > > > Isn't there a better way of presenting the edits in human-readable > > form than apply them and then run Diff? What format is used by the > > server itself to send the edits? > > The server sends a JSON message. Here is an example from a little toy > project of mine in C, where I intentionally uncommented a #include > directive: And we cannot generate the Diff format from this? > > Besides, this assumes the 'diff' command is available, which is not > > portable -- one more reason not to go that way, or at leas provide an > > alternative. > > I am personally fond of this approach, because I get a regular text > buffer that I can store or send someone. The fact that diff is not > available everywhere (even though I would guess any system with a > language server /should/ have diff installed), is an argument against > enabling this behaviour by default, not against providing this interface. What do we suggest to people who don't have Diff, though? Nothing? From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 12 09:29:31 2023 Received: (at 60338) by debbugs.gnu.org; 12 Jun 2023 13:29:31 +0000 Received: from localhost ([127.0.0.1]:39203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8hbv-000372-2T for submit@debbugs.gnu.org; Mon, 12 Jun 2023 09:29:31 -0400 Received: from mout01.posteo.de ([185.67.36.65]:47027) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8hbr-00036i-RE for 60338@debbugs.gnu.org; Mon, 12 Jun 2023 09:29:28 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id DEACD24002B for <60338@debbugs.gnu.org>; Mon, 12 Jun 2023 15:29:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686576561; bh=u2xBTEyFqJTcjfI/zINqWB91XFjIFyyjULphzuRpAr8=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=IaEKRxgEfQeXeuWaPAvf++rhOfrjnMpgTlJWVIbCmyswVOPsVL2JLo5IRgcENliet BlDHYDt0fgIIVcL7yU6RpJSYQtXKDHIcORoRE/unkuhpOdK92eBiZsSYISPnjg+1ag aCwTkxYVPcJTX68j2y+PSlchNqYAprTbo8ZnU5Zf/EI7pnaZyFkolWNw52EOHQ9dPV bguGTR+xTe5d6kku3uSpo+g//1wrmtbZEz60XBnvlCsBFioIwgh8ZTPbt6vPVejCB9 3u33JAm8VKqyQ2r75PQKUEJpsAT/AWPgHCWTdypDeg8MP6WxGSueN168FaHG+d8GR0 80f6TokleXZsQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Qfswd21cwz9rxH; Mon, 12 Jun 2023 15:29:21 +0200 (CEST) From: Philip Kaludercic To: Eli Zaretskii Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <83fs6wyhak.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 12 Jun 2023 15:52:03 +0300") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> X-Hashcash: 1:20:230612:60338@debbugs.gnu.org::a+2lATgF8jZns5Ff:02pY X-Hashcash: 1:20:230612:eliz@gnu.org::IiT+KuUEUg6z3B4T:4+PW X-Hashcash: 1:20:230612:joaotavora@gmail.com::z/lJT7CuZt1koqUb:7vxc Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Mon, 12 Jun 2023 13:29:21 +0000 Message-ID: <87y1koerm6.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> From: Philip Kaludercic >> Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com >> Date: Mon, 12 Jun 2023 12:35:09 +0000 >> >> Eli Zaretskii writes: >> >> > Isn't there a better way of presenting the edits in human-readable >> > form than apply them and then run Diff? What format is used by the >> > server itself to send the edits? >> >> The server sends a JSON message. Here is an example from a little toy >> project of mine in C, where I intentionally uncommented a #include >> directive: > > And we cannot generate the Diff format from this? Certainly we /could/, but I don't think that would be worth the effort to generate a proper diff manually. >> > Besides, this assumes the 'diff' command is available, which is not >> > portable -- one more reason not to go that way, or at leas provide an >> > alternative. >> >> I am personally fond of this approach, because I get a regular text >> buffer that I can store or send someone. The fact that diff is not >> available everywhere (even though I would guess any system with a >> language server /should/ have diff installed), is an argument against >> enabling this behaviour by default, not against providing this interface. > > What do we suggest to people who don't have Diff, though? Nothing? They still have two different options for `eglot-confirm-server-initiated-edits', 'confirm (the default) and nil. This is the current state. -- Philip Kaludercic From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 12 09:41:51 2023 Received: (at 60338) by debbugs.gnu.org; 12 Jun 2023 13:41:51 +0000 Received: from localhost ([127.0.0.1]:39226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8hnq-0003Sz-M5 for submit@debbugs.gnu.org; Mon, 12 Jun 2023 09:41:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35406) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8hnp-0003Sk-02 for 60338@debbugs.gnu.org; Mon, 12 Jun 2023 09:41:49 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q8hnj-0006LI-Ma; Mon, 12 Jun 2023 09:41:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=mAeSQyKysiAedV6oGeZu0FFDVr/50y6dw5eaycc2v2Y=; b=cij+OOMdu0oq MEZ9jdRFiOa9Xlsgv2CA7Ws1QoM9J/7cGIZmjXdQ8zU9Pf0YpjMj6T2JHKYT5Vt2x4Guio98mt9nN PsIttm+sK8QcyQUyhYSiEMSGrMbYwjEGzDdl3a5nU9+h6LjMoyJ2r2hyK7NH+Zqf1O7HRUGeg3uii 34bfLApiJrCvZVQQDiLJLCIoaIc2NxsgCC5tETzSE8fExRQxEp8cF+/Q/RD8QYZANWBfs4qm22zBG cV7hzkM6OKN+EIIA0Tov/XveSZlW+16/u6UcgfrsZAGIANWZBIzNUPzkGricxlE0bmaUkqJgAzAky vthQB/smBfhLfoAVgg2Juw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q8hni-0002FB-3J; Mon, 12 Jun 2023 09:41:43 -0400 Date: Mon, 12 Jun 2023 16:41:57 +0300 Message-Id: <83bkhkyeze.fsf@gnu.org> From: Eli Zaretskii To: Philip Kaludercic In-Reply-To: <87y1koerm6.fsf@posteo.net> (message from Philip Kaludercic on Mon, 12 Jun 2023 13:29:21 +0000) Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Philip Kaludercic > Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com > Date: Mon, 12 Jun 2023 13:29:21 +0000 > > Eli Zaretskii writes: > > >> From: Philip Kaludercic > >> Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com > >> Date: Mon, 12 Jun 2023 12:35:09 +0000 > >> > >> Eli Zaretskii writes: > >> > >> > Isn't there a better way of presenting the edits in human-readable > >> > form than apply them and then run Diff? What format is used by the > >> > server itself to send the edits? > >> > >> The server sends a JSON message. Here is an example from a little toy > >> project of mine in C, where I intentionally uncommented a #include > >> directive: > > > > And we cannot generate the Diff format from this? > > Certainly we /could/, but I don't think that would be worth the effort > to generate a proper diff manually. It doesn't necessarily have to be the full-fledged diffs, it could be something approximate. After all, this is for human consumption. > > What do we suggest to people who don't have Diff, though? Nothing? > > They still have two different options for > `eglot-confirm-server-initiated-edits', 'confirm (the default) and nil. > This is the current state. IOW, we offer them nothing for this feature. Look, I cannot force you to do anything else, if you don't feel like it, but I don't like this solution, and think we should try harder. I urge you to try to find some way of presenting the edits in human-readable form that doesn't need running Diff. Thanks in advance. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 13 17:34:27 2023 Received: (at 60338) by debbugs.gnu.org; 13 Jun 2023 21:34:27 +0000 Received: from localhost ([127.0.0.1]:43200 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9Bek-0006jh-Po for submit@debbugs.gnu.org; Tue, 13 Jun 2023 17:34:27 -0400 Received: from mout02.posteo.de ([185.67.36.66]:52099) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9Bej-0006jQ-66 for 60338@debbugs.gnu.org; Tue, 13 Jun 2023 17:34:25 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 169FF240103 for <60338@debbugs.gnu.org>; Tue, 13 Jun 2023 23:34:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686692059; bh=kw+Lm6erVB6SmQMiSrGgUVidxPe07+1H3/IUKSDHhHA=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=Y868Euffda2zOhoCQ8mhnDzipmZvuP43/UWFxTR8nVuqjOojD330EcXwXyWQKXlNB BgFnZTAa3iRm24SU6TpQSa0qoy3qKCZMzNpbCZk3v7Y+EzDDMd8LSUOIDE3pJsjXqV LL3jD+XkkSdEkFHfWY9vvl/ZPkDSl+XUkpG/DDNyrGFxnJ9ExIZpfB98Ov7A38JbjM 9PSsohG5GrZpuV3vhhraSvywOtcY7Z/DHZU9hR9asvmil/PLMikzjI9O8PoPodlqHM i9It4P/tOhPwU94mh2p6Si1v9NdaYsZqlUlSE7osJrBJoSjE4N9kmPo3i0eKGZvWuo WFHq5+krwpuNw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Qghdk2Kxgz6tm4; Tue, 13 Jun 2023 23:34:18 +0200 (CEST) From: Philip Kaludercic To: Eli Zaretskii Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <83bkhkyeze.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 12 Jun 2023 16:41:57 +0300") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Tue, 13 Jun 2023 21:34:17 +0000 Message-ID: <87v8fr6o86.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> From: Philip Kaludercic >> Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com >> Date: Mon, 12 Jun 2023 13:29:21 +0000 >> >> Eli Zaretskii writes: >> >> >> From: Philip Kaludercic >> >> Cc: 60338@debbugs.gnu.org, joaotavora@gmail.com >> >> Date: Mon, 12 Jun 2023 12:35:09 +0000 >> >> >> >> Eli Zaretskii writes: >> >> >> >> > Isn't there a better way of presenting the edits in human-readable >> >> > form than apply them and then run Diff? What format is used by the >> >> > server itself to send the edits? >> >> >> >> The server sends a JSON message. Here is an example from a little toy >> >> project of mine in C, where I intentionally uncommented a #include >> >> directive: >> > >> > And we cannot generate the Diff format from this? >> >> Certainly we /could/, but I don't think that would be worth the effort >> to generate a proper diff manually. > > It doesn't necessarily have to be the full-fledged diffs, it could be > something approximate. After all, this is for human consumption. Not really, the point is that you can apply these diffs directly. Also, I would not say that diffs are not for human consumption. >> > What do we suggest to people who don't have Diff, though? Nothing? >> >> They still have two different options for >> `eglot-confirm-server-initiated-edits', 'confirm (the default) and nil. >> This is the current state. > > IOW, we offer them nothing for this feature. In the sense of a preview? Yes, but I would still argue, that that would be a different feature. I can take a look at that as well, but I know of at least a few people who would be explicitly interested in this kind of a user interface. > Look, I cannot force you to do anything else, if you don't feel like > it, but I don't like this solution, and think we should try harder. I > urge you to try to find some way of presenting the edits in > human-readable form that doesn't need running Diff. I respect your perspective, so I don't want to insist on anything against your or Joao's will. > Thanks in advance. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 14 02:00:35 2023 Received: (at 60338) by debbugs.gnu.org; 14 Jun 2023 06:00:35 +0000 Received: from localhost ([127.0.0.1]:43483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9JYZ-0003tq-7m for submit@debbugs.gnu.org; Wed, 14 Jun 2023 02:00:35 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:38588 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9JYX-0003ti-A5 for 60338@debbugs.gnu.org; Wed, 14 Jun 2023 02:00:33 -0400 From: Eshel Yaron DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1686722432; bh=GurkDTSyTCOyaztsVPHibdU7UDwJ3TRjv3zuUal0igU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=LjXOrOxIRqANWJ+NN20XrsVwdSLE+oUFL6jokx/mQ8DOyEFtP2DDmv9UjLXW4NIfe mLdzTsewjwJavDu1FYBuK+hFmXyELD6yWRlZEjLvLLvHeBYdKIsvoqM+O26Olk/ogb 7Gt14auCyNmy4B6Clw3WARoOhnIrQzewbmqnkTpA9RENN6+fLKDICSOqL2WtFW0e3O y3mfFQ0DpcWopQ9GFxeA8qbh2HqSEq0G8Zh+bKvShvjuhhkgz5ihkHZ8R2Bm41/vlx Gpa4D8T7GgR5ixZdHsMhi7f5OX8V7Xg7k0am/9H/9VFs3nMK/md9V0zfI1FxX46Apb MNsGYd1Dk7UlQ== To: Philip Kaludercic Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <87v8fr6o86.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 13 Jun 2023 21:34:17 +0000") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> Date: Wed, 14 Jun 2023 09:00:27 +0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 60338 Cc: Eli Zaretskii , 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) FWIW I'd definitely want to use this feature when it lands. >> It doesn't necessarily have to be the full-fledged diffs, it could be >> something approximate. After all, this is for human consumption. > > Not really, the point is that you can apply these diffs directly. Also, > I would not say that diffs are not for human consumption. I agree, it'd be nice to get a proper diff buffer with all the benefits of `diff-mode`. I also see how it would be useful for Emacs to be able to generate such a diff buffer directly from the change description that the LSP server provides, without applying the change and running the diff program, but it doesn't seem quite trivial so I hope that can be implemented as an enhancement down the line. (I'd be happy to help with that, BTW.) -- Best, Eshel From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 14 07:27:21 2023 Received: (at 60338) by debbugs.gnu.org; 14 Jun 2023 11:27:21 +0000 Received: from localhost ([127.0.0.1]:43864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9Oen-0006nv-AM for submit@debbugs.gnu.org; Wed, 14 Jun 2023 07:27:21 -0400 Received: from mout01.posteo.de ([185.67.36.65]:60075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9Oel-0006nd-I5 for 60338@debbugs.gnu.org; Wed, 14 Jun 2023 07:27:20 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 53DD824002B for <60338@debbugs.gnu.org>; Wed, 14 Jun 2023 13:27:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686742033; bh=fjuxAxQbGGhfokbUF/1jiIma1/o6vY8bJhPyWmQz8Kg=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=beKNK8+xGbNR9yb1eYimy7tuWOu7pe1EM0WPewRM4CWMeqHtEHFc7hDjh43FaLgVF fdGbcK1t4L77kcAkgfhYCeH2hRgtUqT4R1zL8RvV8EdiqoImrebvs9CkP7vxtdksXN 7VJXHLk29U0Wnm0OAVxZHz56VOIquyxvEXiueyjZQpJnV/wrxybuJbMIRKfHgTn72q R2vk2IUIAjNKPuaQOIQT+oO66PpXlmbjDeji6YFDQv3898AJh7WJIdBrmnyt0EpcoP zTWq0M+nQtZbFaCekfC0ZeO0zvaY9BJTKWQsI/ba65RydUaQ2QqE694btBZ1wiBuwL IJHMPbuFM46Kw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Qh36m3Wrwz6tvh; Wed, 14 Jun 2023 13:27:12 +0200 (CEST) From: Philip Kaludercic To: Eshel Yaron Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: (Eshel Yaron's message of "Wed, 14 Jun 2023 09:00:27 +0300") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Wed, 14 Jun 2023 11:27:12 +0000 Message-ID: <87zg52e12n.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: Eli Zaretskii , 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eshel Yaron writes: > FWIW I'd definitely want to use this feature when it lands. > >>> It doesn't necessarily have to be the full-fledged diffs, it could be >>> something approximate. After all, this is for human consumption. >> >> Not really, the point is that you can apply these diffs directly. Also, >> I would not say that diffs are not for human consumption. > > I agree, it'd be nice to get a proper diff buffer with all the benefits > of `diff-mode`. Right. > I also see how it would be useful for Emacs to be able to generate such > a diff buffer directly from the change description that the LSP server > provides, without applying the change and running the diff program, but > it doesn't seem quite trivial so I hope that can be implemented as an > enhancement down the line. (I'd be happy to help with that, BTW.) Yes, and we were to do this, I'd rather add it to a pure-elisp `diff' to diff.el so that it can be transparently reused anywhere where the "diff" program is missing. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 18 07:38:28 2023 Received: (at 60338) by debbugs.gnu.org; 18 Jun 2023 11:38:28 +0000 Received: from localhost ([127.0.0.1]:53420 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAqjj-0006Sl-Tz for submit@debbugs.gnu.org; Sun, 18 Jun 2023 07:38:28 -0400 Received: from mout01.posteo.de ([185.67.36.65]:58615) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAqji-0006SY-8j for 60338@debbugs.gnu.org; Sun, 18 Jun 2023 07:38:27 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 79DEA240028 for <60338@debbugs.gnu.org>; Sun, 18 Jun 2023 13:38:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1687088300; bh=mfjguq+Fc+ltO27+a9QGaKFoYthCMIFw3n8dyL7FAd8=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=lqMn+ZuCaL/jxDf6lcbILSRDCAnPk3uLdsstkoEEYuextXsX5YawGupaI4E9LKwL3 KfHCeb0w6zbZH3DC+KJwkXKAYjKmsjIf2ikz0vqgYz1CXCZJCviL5TpbLw+C02wNdb AOJ6NDL64KaUXgL+YcAP+8EPNj2xMUt1ndDKwvyowVLNXwGAMu0XjoU4KrX85zLrJa QmEH2kKeQ6ifDTjHYnb68c3VbHe5G5TnS4DQ+MHLxEdwx+2EMx10/JH/XoSeoOx6yV LiIsOWt3/jiIwPyhlG0pGb131uZHEjSmsUzq6RTM8x0KSdv99ymQQD+uE2obnN0cTa cltQoLiN1P8Hw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QkW9l4RLRz9rxG; Sun, 18 Jun 2023 13:38:19 +0200 (CEST) From: Philip Kaludercic To: Eshel Yaron Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <87zg52e12n.fsf@posteo.net> (Philip Kaludercic's message of "Wed, 14 Jun 2023 11:27:12 +0000") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> X-Hashcash: 1:20:230618:me@eshelyaron.com::IMPklKqe7ymEyvHZ:0dHe X-Hashcash: 1:20:230618:60338@debbugs.gnu.org::Vp2je59F26X2WvDi:0IQz X-Hashcash: 1:20:230618:joaotavora@gmail.com::lMORpwj4GzrHSijJ:1YvB X-Hashcash: 1:20:230618:eliz@gnu.org::s8OSvSlSznhwVBxK:2iAO Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Sun, 18 Jun 2023 11:38:19 +0000 Message-ID: <871qi9q9uc.fsf@posteo.net> 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: Eli Zaretskii , 60338@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Jo=C3=A3o, do you have anything to add to this discussion? Philip Kaludercic writes: > Eshel Yaron writes: > >> FWIW I'd definitely want to use this feature when it lands. >> >>>> It doesn't necessarily have to be the full-fledged diffs, it could be >>>> something approximate. After all, this is for human consumption. >>> >>> Not really, the point is that you can apply these diffs directly. Also, >>> I would not say that diffs are not for human consumption. >> >> I agree, it'd be nice to get a proper diff buffer with all the benefits >> of `diff-mode`. > > Right. > >> I also see how it would be useful for Emacs to be able to generate such >> a diff buffer directly from the change description that the LSP server >> provides, without applying the change and running the diff program, but >> it doesn't seem quite trivial so I hope that can be implemented as an >> enhancement down the line. (I'd be happy to help with that, BTW.) > > Yes, and we were to do this, I'd rather add it to a pure-elisp `diff' to > diff.el so that it can be transparently reused anywhere where the "diff" > program is missing. --=20 Philip Kaludercic From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 18 11:15:53 2023 Received: (at 60338) by debbugs.gnu.org; 18 Jun 2023 15:15:53 +0000 Received: from localhost ([127.0.0.1]:54832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAu89-0004Eb-27 for submit@debbugs.gnu.org; Sun, 18 Jun 2023 11:15:53 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]:53423) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAu87-0004EL-0L for 60338@debbugs.gnu.org; Sun, 18 Jun 2023 11:15:51 -0400 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-31126037f41so2088440f8f.2 for <60338@debbugs.gnu.org>; Sun, 18 Jun 2023 08:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687101345; x=1689693345; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z1FUMNTOLbznxkMKblay5vYLZhZYXsEY0SX4gtkBUNw=; b=q9OzubXjxWNLsr/08SdetfbziFNfKYbbIrEBaevJ5rrNCxqbbTnOOCLycDzpzQTExN MIiFyl8QT462Ck8XDEb1P+2Y94VeR1/itVewxfcgb/fDF6e5uKKcMSjbGtG1EabBbRrU /8RmqIFXnNowjaw9zNY8RMj/X4pLYahyBqSAo48OyqiY4mx1UPQZIzPAubCzgpa3sI5Z YA2xEM8yVKB5SHd/6HXDHvfJSZ4iT+7Kw2J00cuRvpRLaIooTE09iJuzY5lgd9iVR9LC 58FOZuh6hpniRU7TvhnBLz9jrW/DY8yrP3GHrdT0GQe8iyXRd66/xnCFkTNiaDEKyrdc 8pkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687101345; x=1689693345; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z1FUMNTOLbznxkMKblay5vYLZhZYXsEY0SX4gtkBUNw=; b=fhOHJVW0lqkmIpTtU0RnPG+sYggBaPScPM0goxK9zagPiOMzGcQSuPTFNfLWm9l1v3 2aIMUKmkFH3tJB5034d4E/Dqt9fI6v+9Bmg8mTmu84r+Adv4jJTIkLv+q6C/ePKuTPdg I+qNdiaUkPXk20nUhSd28wAXElQ9aixHLz1Mc/2crr142L9FN+D6DSSEoUFj4Mm9HLWu VcSm7fNcJgwdVhYOjILiI7e3EjpZ13O6IzKGysneijpYprsMBKOZRw3IirxColg1modj KZB4pglBJdWOL+QrKahS00hbuugqN2kWc8RVlP7e8ALmYfuqZOaYkUu8qKKQoWgXEdVl hpYg== X-Gm-Message-State: AC+VfDz1V5TLjac31SUjRcDHbKsh79H+UoMoAy09uLW43PoSLm/8I9Tx 32wMCT39q+iO8ZUFrOen6ZkeLdOwGeM= X-Google-Smtp-Source: ACHHUZ7LvcCllpLy3vlmNn3hXq2sng0yjmhYmvl+nNL9ckQ26FZHwOZuIs3zSNh+iD1us15cwg/lcQ== X-Received: by 2002:adf:fc4e:0:b0:30f:cf52:9194 with SMTP id e14-20020adffc4e000000b0030fcf529194mr5990884wrs.58.1687101344569; Sun, 18 Jun 2023 08:15:44 -0700 (PDT) Received: from krug ([87.196.73.15]) by smtp.gmail.com with ESMTPSA id e16-20020adffc50000000b0030fbb834074sm21183971wrs.15.2023.06.18.08.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 08:15:44 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Philip Kaludercic Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <871qi9q9uc.fsf@posteo.net> (Philip Kaludercic's message of "Sun, 18 Jun 2023 11:38:19 +0000") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> Date: Sun, 18 Jun 2023 16:18:12 +0100 Message-ID: <87a5ww7qa3.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) 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: 60338 Cc: Eli Zaretskii , 60338@debbugs.gnu.org, Eshel Yaron X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Philip Kaludercic writes: > Jo=C3=A3o, do you have anything to add to this discussion? Yes, a bit. To the "should it use diff" objection, I think it's OK to keep it as is. Especially if we frame this new 'diff' value to Eglot's eglot-confirm-server-initiated-edits as a "Present changes as 'diff', and user takes it from there". I'd say most programmers can read diffs and apply them by hand if required. Anyway this usage of the entirely separate 'diff-mode' is the strongest point of this feature anyway, it keeps the concerns "propose changes" and "apply changes" neatly separated. I also think the second patch adding 'diff-apply-everything' is fine. Now I've tried your patch very briefly and I like it, in general. But I have a few comments after my sig. Jo=C3=A3o > @@ -108,6 +108,7 @@ > (require 'filenotify) > (require 'ert) > (require 'text-property-search nil t) > +(require 'diff) >=20=20 > ;; These dependencies are also GNU ELPA core packages. Because of > ;; bug#62576, since there is a risk that M-x package-install, despite > @@ -387,8 +388,13 @@ eglot-events-buffer-size > (integer :tag "Number of characters"))) >=20=20 > (defcustom eglot-confirm-server-initiated-edits 'confirm > - "Non-nil if server-initiated edits should be confirmed with user." > + "Control how server edits are applied. > +If set to `confirm', a prompt is presented to confirm server > +changes. If set to `diff', a buffer will pop up with changes > +that can be applied manually. If set to nil, modifications are > +made automatically." > :type '(choice (const :tag "Don't show confirmation prompt" nil) > + (const :tag "Present as diffs in a buffer" diff) > (const :tag "Show confirmation prompt" confirm))) This is the most important comment. Later on, you add a condition (eq eglot-confirm-server-initiated-edits t) Which would seem to mean "confirm unconditionally". But 't' is not presented as an option in the defcustom. What meaning should it have? Should it use a prompt or a diff? >=20=20 > (defcustom eglot-extend-to-xref nil > @@ -740,7 +746,8 @@ eglot-execute > (eglot--dcase action > (((Command)) (eglot--request server :workspace/executeCommand actio= n)) > (((CodeAction) edit command) > - (when edit (eglot--apply-workspace-edit edit)) > + (when edit > + (eglot--apply-workspace-edit edit (eq eglot-confirm-server-initi= ated-edits t))) > (when command (eglot--request server :workspace/executeCommand com= mand)))))) This is where the 't' value is used. These types of edits are usually automatically confirmed. Why? Not easy to say, but normally when the server suggests them they are more localized. Also by this point the client already knows what is about to change, whereas we don't know what diff the server will provide with the ones of "Command"-type, which require a further round trip. Anyway it would be very helpful to describe this in the manual and in the docstrings. So that a user can say: "even in those simple edits I want a diff-style presentation of what is about to happen". This may require another custom option of more added syntax to the existing eglot-confirm-server-initiated-edits option. Though I would appreciate if you could take this opportunity to address them, you can also choose to simply not answer these tough questions. But in this case, this hunk should be reverted > (cl-defgeneric eglot-initialization-options (server) > @@ -3408,18 +3415,43 @@ 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 > + (cond > + ((eq confirm 'diff) > + (with-current-buffer (get-buffer-create " *Changes*") > + (buffer-disable-undo (current-buffer)) > + (let ((buffer-read-only t)) > + (diff-mode)) Why bind buffer-read-only to t here? Why not re-enter diff-mode at the end of cosntruction? > + (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)) pop-to-buffer is fine, I guess, though I wonder if some users wouldn't prefer display-buffer. > + (font-lock-ensure))) I think this logic should be in a new helper function. And the generated buffer name should be more Eglotish, and not hidden. It should read something like "*EGLOT (/) proposed changes*". Ideally the logic for generating the usual prefix "*EGLOT (/)" should also be extracted, so that we can switch to something less ugly in the fugure. In a different commit or patch, of course.=20=20 > - (cl-loop for edit in prepared > - for (path edits version) =3D edit > - do (with-current-buffer (find-file-noselect path) > - (eglot--apply-text-edits edits version)) > - finally (eldoc) (eglot--message "Edit successful!"))))) > + (mapconcat #'identity (mapcar #'car prepared)= "\n "))))) > + (jsonrpc-error "User canceled server edit")) > + ((cl-loop for (path edits version) in prepared > + do (with-current-buffer (find-file-noselect path) > + (eglot--apply-text-edits edits version)) > + finally (eldoc) (eglot--message "Edit successful!")))))= )) This last bit of cl-loop change, though better, doesn't seem related to the new feature being developed. It's not very important, but it does complicate reading the patch. You can always provide such improvements=20 > (defun eglot-rename (newname) > "Rename the current symbol to NEWNAME." > @@ -3434,7 +3466,7 @@ eglot-rename > (eglot--request (eglot--current-server-or-lose) > :textDocument/rename `(,@(eglot--TextDocumentPosition= Params) > :newName ,newname)) > - current-prefix-arg)) > + (and current-prefix-arg eglot-confirm-server-initiated-edits))) I get the idea and I like it. Now one can preview the renames. But if 'eglot-confirm-server-initiated-edits' is nil, now I can't use C-u to override this decision. Not necessarily something we need to fix in your patch, but it should be taken in consideration with the first comment about documentating the semantics of this variable. =20=20 > (defun eglot--region-bounds () > "Region bounds if active, else bounds of things at point." From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 18 18:34:54 2023 Received: (at 60338) by debbugs.gnu.org; 18 Jun 2023 22:34:54 +0000 Received: from localhost ([127.0.0.1]:55216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qB0z0-0000tz-CK for submit@debbugs.gnu.org; Sun, 18 Jun 2023 18:34:54 -0400 Received: from mail-oo1-f51.google.com ([209.85.161.51]:56673) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qB0yy-0000th-Iv for 60338@debbugs.gnu.org; Sun, 18 Jun 2023 18:34:53 -0400 Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-55e41318185so679286eaf.1 for <60338@debbugs.gnu.org>; Sun, 18 Jun 2023 15:34:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687127686; x=1689719686; 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=w5Aa3LD24pY7xgKClfMIVEIOAyEjdWAjoT8x7Dp9hng=; b=QwuiLMn1EcmlgSPOx0w5vp0EcMdRiss5Xb7Xaa6Ikt3vprDmpsi60hwI6ad5kkmamn oh5GDc926a5H4TzPIfp+d5xbdT7EmM/whqRseWSWlSmuOfzthd3lNOJzY5InX6a/Gdzq OIz/qmqep44wPYYV5n5p5X9yilA3HP6SgKHfroz/wlyM7LxUKFTttHoia3xMG3wQ0cV0 0gSLtV3lp7KpXpS/V7OorcQBmSmQO22wPcD2OXhTPV7rOeyBylIPF4wlW3ph7d3eyGh7 SJwDeSWTU4m5ZT2HpXTytGZ19zRGyMTo/3dpG9qCF7b7gUIqEP1I6KCoM2Y8Y1ZXwon1 t+5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687127686; x=1689719686; 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=w5Aa3LD24pY7xgKClfMIVEIOAyEjdWAjoT8x7Dp9hng=; b=K5xLFtfdOAtfTtUBIYKTK/W/swrjpuwS4G+Qp+yKEBT9mE5H476BJ32bISdbkutp0J ParldiGEtFq62lKHo6B1ErRfdpVzgz9ehQqWPYYX4KunelWJ+e5/NIAyAdBhN4nIM/ml SzvVYb31cwqkqWXUNc949+Ix7UGtcSqCDQRR2OnEu9EvNnPw0+8+0O/ETcYpJfFP4xtD pwOQk5TA56BZLvQWDktYG1XluoiSFrKTRS3MmqxqNe8NUsZA7Xx1Q0rGvLLnADBFEUD5 aXCJdX5Kj9dJtULylEH96TBAC3AUaLNXbIO+Vnzh2dfuucjM4WsOz0iGC/xZeknNIrtw ACGw== X-Gm-Message-State: AC+VfDyP/Qn2Nzq/izo15eBmLnt5WMSRI+Enwmn+doZTEWiSAlGWYy/z d5kh5t6kid3gBe3rgTBxom5GmJr+3Xo1yKIJvS0= X-Google-Smtp-Source: ACHHUZ49ZLV7xi+zSkFfNuL2kLW/MKRO0WSp4mAN8lvKxF7uzs4gL6RwWuKrC5iLX+Lkl9MvMMn7FUz/rVxIGIZ1ZeQ= X-Received: by 2002:a4a:de82:0:b0:55c:6812:27c5 with SMTP id v2-20020a4ade82000000b0055c681227c5mr5911131oou.9.1687127686569; Sun, 18 Jun 2023 15:34:46 -0700 (PDT) MIME-Version: 1.0 References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> In-Reply-To: <87a5ww7qa3.fsf@gmail.com> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sun, 18 Jun 2023 23:37:04 +0100 Message-ID: Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs To: Philip Kaludercic Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60338 Cc: Eli Zaretskii , 60338@debbugs.gnu.org, Eshel Yaron X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sun, Jun 18, 2023 at 4:15=E2=80=AFPM Jo=C3=A3o T=C3=A1vora wrote: > > Philip Kaludercic writes: > > > Jo=C3=A3o, do you have anything to add to this discussion? > > Yes, a bit. > > To the "should it use diff" objection, I think it's OK to keep it as is. > Especially if we frame this new 'diff' value to Eglot's > eglot-confirm-server-initiated-edits as a "Present changes as 'diff', > and user takes it from there". I'd say most programmers can read diffs > and apply them by hand if required. After thinking a bit, I realized I missed a point of Eli's objection to the implementation of this. It's that the 'diff' program is required just to generate the presentation, not just to apply it. But I don't see any other better ways to summarily present changes to files. Ediff maybe? But that's not so good, and it requires splitting the window and entering a transient mode. And I'm not sure it doesn't rely on the diff program itself (but haven't checked). Anyway, who works with Emacs in a programming context -- which is what LSP is mainly for -- that also doesn't have the diff program for patches, vc-diff, etc? Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 24 12:54:13 2023 Received: (at 60338) by debbugs.gnu.org; 24 Jun 2023 16:54:13 +0000 Received: from localhost ([127.0.0.1]:41392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qD6WM-0002KR-QY for submit@debbugs.gnu.org; Sat, 24 Jun 2023 12:54:13 -0400 Received: from mout01.posteo.de ([185.67.36.65]:58825) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qD6WL-0002KE-2G for 60338@debbugs.gnu.org; Sat, 24 Jun 2023 12:53:58 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 19F6E240029 for <60338@debbugs.gnu.org>; Sat, 24 Jun 2023 18:53:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1687625631; bh=ZD4xC/SCGK/TQhNO+Xyuy8/lwgRXdrGG4BjSOWWwRCE=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=fK4E/k6rThmuC9R2FqXf3ez11f13RU4ZvC9MLTFpMb7DVUDbQa0nq4J/pMQ4UurX0 Y8YR1J5cNhH6tITHKGDq/8YQ5/z6Xxtx2mQloupSD5tASJ7IQ7WdZ/ywOZltxPluaR R4qrQ2uzX8G+Hn04OmCYlOhtqM2gU+lAoB2hWXix8eBLxnJuYfOwgJ9FWvS5ojF0zs 2IYe5ebMHMQGnwPf8k2BoyroxzLKXR/LlIxm5RhA9TvAcDwLb16+m+c1UDbK1QWbAA ziPZ8TP1Ry/+QDNmKHyyTsqOWz1jvjZZtRsiUVTBlyvxlkQ9BQ+6ptg6K5oGEO/EFq 3oYwXCRH3QqGg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QpKv23YkTz9rxN; Sat, 24 Jun 2023 18:53:50 +0200 (CEST) From: Philip Kaludercic To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <87a5ww7qa3.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Sun, 18 Jun 2023 16:18:12 +0100") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> X-Hashcash: 1:20:230624:60338@debbugs.gnu.org::E9JvDwuu2Nsq+lvN:3KJ X-Hashcash: 1:20:230624:me@eshelyaron.com::b5AlSDyIda6dd03r:+JH X-Hashcash: 1:20:230624:joaotavora@gmail.com::XaPLezkUKbAcHSTB:0J8r X-Hashcash: 1:20:230624:eliz@gnu.org::zp1j9jZevM1awxFr:0MZl Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Sat, 24 Jun 2023 16:53:50 +0000 Message-ID: <87jzvsdco1.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60338 Cc: Eli Zaretskii , 60338@debbugs.gnu.org, Eshel Yaron X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jo=C3=A3o T=C3=A1vora writes: > Philip Kaludercic writes: > >> Jo=C3=A3o, do you have anything to add to this discussion? > > Yes, a bit. > > To the "should it use diff" objection, I think it's OK to keep it as is. > Especially if we frame this new 'diff' value to Eglot's > eglot-confirm-server-initiated-edits as a "Present changes as 'diff', > and user takes it from there". I'd say most programmers can read diffs > and apply them by hand if required. > > Anyway this usage of the entirely separate 'diff-mode' is the strongest > point of this feature anyway, it keeps the concerns "propose changes" > and "apply changes" neatly separated. > > I also think the second patch adding 'diff-apply-everything' is fine. > > Now I've tried your patch very briefly and I like it, in general. But I > have a few comments after my sig. > > Jo=C3=A3o > >> @@ -108,6 +108,7 @@ >> (require 'filenotify) >> (require 'ert) >> (require 'text-property-search nil t) >> +(require 'diff) >>=20=20 >> ;; These dependencies are also GNU ELPA core packages. Because of >> ;; bug#62576, since there is a risk that M-x package-install, despite >> @@ -387,8 +388,13 @@ eglot-events-buffer-size >> (integer :tag "Number of characters"))) >>=20=20 >> (defcustom eglot-confirm-server-initiated-edits 'confirm >> - "Non-nil if server-initiated edits should be confirmed with user." >> + "Control how server edits are applied. >> +If set to `confirm', a prompt is presented to confirm server >> +changes. If set to `diff', a buffer will pop up with changes >> +that can be applied manually. If set to nil, modifications are >> +made automatically." >> :type '(choice (const :tag "Don't show confirmation prompt" nil) >> + (const :tag "Present as diffs in a buffer" diff) >> (const :tag "Show confirmation prompt" confirm))) > > This is the most important comment. Later on, you add a condition > > (eq eglot-confirm-server-initiated-edits t) > > Which would seem to mean "confirm unconditionally". But 't' is not > presented as an option in the defcustom. What meaning should it have? > Should it use a prompt or a diff? No, that was a thinko, the check has to be replaced with something else. >>=20=20 >> (defcustom eglot-extend-to-xref nil >> @@ -740,7 +746,8 @@ eglot-execute >> (eglot--dcase action >> (((Command)) (eglot--request server :workspace/executeCommand acti= on)) >> (((CodeAction) edit command) >> - (when edit (eglot--apply-workspace-edit edit)) >> + (when edit >> + (eglot--apply-workspace-edit edit (eq eglot-confirm-server-init= iated-edits t))) >> (when command (eglot--request server :workspace/executeCommand co= mmand)))))) > > > This is where the 't' value is used. These types of edits are usually > automatically confirmed. Why? Not easy to say, but normally when the > server suggests them they are more localized. Also by this point the > client already knows what is about to change, whereas we don't know what > diff the server will provide with the ones of "Command"-type, which > require a further round trip. > > Anyway it would be very helpful to describe this in the manual and in > the docstrings. So that a user can say: "even in those simple edits I > want a diff-style presentation of what is about to happen". > > This may require another custom option of more added syntax to the > existing eglot-confirm-server-initiated-edits option. > Though I would appreciate if you could take this opportunity to address > them, you can also choose to simply not answer these tough questions. > But in this case, this hunk should be reverted I've gone ahead and fixed the check, to pass 'diff if `eglot-confirm-server-initiated-edits' was set to 'diff, otherwise nil. That seems like the most sensible option to me. >> (cl-defgeneric eglot-initialization-options (server) >> @@ -3408,18 +3415,43 @@ 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) prepare= d))) >> - (if (or confirm >> - (cl-notevery #'find-buffer-visiting >> - (mapcar #'car prepared))) >> - (unless (y-or-n-p >> + (cond >> + ((eq confirm 'diff) >> + (with-current-buffer (get-buffer-create " *Changes*") >> + (buffer-disable-undo (current-buffer)) >> + (let ((buffer-read-only t)) >> + (diff-mode)) > > Why bind buffer-read-only to t here? Why not re-enter diff-mode at the e= nd > of cosntruction? I am not sure what you mean by re-enter? The point of binding `buffer-read-only' is just to enable `diff-mode-read-only' on enabling the mode, but we can also set if afterwards. That would require adding a defvar though. >> + (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)) > > pop-to-buffer is fine, I guess, though I wonder if some users wouldn't > prefer display-buffer. I guess that this is a persistent disagreement between users and their expectations. I don't expect it to be resolved here, not at least because I cannot put my own preferences into words. >> + (font-lock-ensure))) > > I think this logic should be in a new helper function. > > And the generated buffer name should be more Eglotish, and not hidden. > It should read something like "*EGLOT (/) proposed > changes*".=20=20 Oh, I was under the impression that this was just the name for "internal" or hidden buffers, that don't interest the user directory. > Ideally the logic for generating the usual prefix "*EGLOT > (/)" should also be extracted, so that we can > switch to something less ugly in the fugure. In a different commit or > patch, of course.=20=20 Should we then keep it the way this is for now, and when this function exists make use of it? >> - (cl-loop for edit in prepared >> - for (path edits version) =3D edit >> - do (with-current-buffer (find-file-noselect path) >> - (eglot--apply-text-edits edits version)) >> - finally (eldoc) (eglot--message "Edit successful!"))))) >> + (mapconcat #'identity (mapcar #'car prepared= ) "\n "))))) >> + (jsonrpc-error "User canceled server edit")) >> + ((cl-loop for (path edits version) in prepared >> + do (with-current-buffer (find-file-noselect path) >> + (eglot--apply-text-edits edits version)) >> + finally (eldoc) (eglot--message "Edit successful!"))))= ))) > > This last bit of cl-loop change, though better, doesn't seem related to > the new feature being developed. It's not very important, but it does > complicate reading the patch. You can always provide such improvements=20 Reverted. >> (defun eglot-rename (newname) >> "Rename the current symbol to NEWNAME." >> @@ -3434,7 +3466,7 @@ eglot-rename >> (eglot--request (eglot--current-server-or-lose) >> :textDocument/rename `(,@(eglot--TextDocumentPositio= nParams) >> :newName ,newname)) >> - current-prefix-arg)) >> + (and current-prefix-arg eglot-confirm-server-initiated-edits))) > > I get the idea and I like it. Now one can preview the renames. But if > 'eglot-confirm-server-initiated-edits' is nil, now I can't use C-u to > override this decision. Not necessarily something we need to fix in > your patch, but it should be taken in consideration with the first > comment about documentating the semantics of this variable. I've modified it, see below. >> (defun eglot--region-bounds () >> "Region bounds if active, else bounds of things at point." --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 9c9c3152472..9c76d4abdef 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -747,7 +747,8 @@ eglot-execute (((Command)) (eglot--request server :workspace/executeCommand action)) (((CodeAction) edit command) (when edit - (eglot--apply-workspace-edit edit (eq eglot-confirm-server-initiated-edits t))) + (let ((confirm (and (eq eglot-confirm-server-initiated-edits 'diff) 'diff))) + (eglot--apply-workspace-edit edit confirm))) (when command (eglot--request server :workspace/executeCommand command)))))) (cl-defgeneric eglot-initialization-options (server) @@ -3401,7 +3402,9 @@ eglot--apply-text-edits (progress-reporter-done reporter)))) (defun eglot--apply-workspace-edit (wedit &optional confirm) - "Apply the workspace edit WEDIT. If CONFIRM, ask user first." + "Apply the workspace edit WEDIT. +CONFIRM should have a value as specified in the user option +`eglot-confirm-server-initiated-edits'." (eglot--dbind ((WorkspaceEdit) changes documentChanges) wedit (let ((prepared (mapcar (eglot--lambda ((TextDocumentEdit) textDocument edits) @@ -3448,7 +3451,8 @@ eglot--apply-workspace-edit (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 (path edits version) in prepared + ((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!"))))))) @@ -3466,7 +3470,7 @@ eglot-rename (eglot--request (eglot--current-server-or-lose) :textDocument/rename `(,@(eglot--TextDocumentPositionParams) :newName ,newname)) - (and current-prefix-arg eglot-confirm-server-initiated-edits))) + (and current-prefix-arg (or eglot-confirm-server-initiated-edits 'confirm)))) (defun eglot--region-bounds () "Region bounds if active, else bounds of things at point." --=-=-= Content-Type: text/plain -- Philip Kaludercic --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 31 20:04:11 2023 Received: (at 60338) by debbugs.gnu.org; 1 Sep 2023 00:04:11 +0000 Received: from localhost ([127.0.0.1]:59456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbrdy-0007uF-Vc for submit@debbugs.gnu.org; Thu, 31 Aug 2023 20:04:11 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:51402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbrdx-0007tx-4W for 60338@debbugs.gnu.org; Thu, 31 Aug 2023 20:04:10 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-401da71b7c5so14601355e9.2 for <60338@debbugs.gnu.org>; Thu, 31 Aug 2023 17:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693526634; x=1694131434; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rblH4AJS0AX7b1FEfJuCZ1jlebVpa6UT/Ggb2OuXcy0=; b=TIdsVEiaeUBFyu+flS0rIxxV6jS/BXGD6IGJTfosgVPC8ypUJS4LiJ9JaK34IAe2AL 2NuagYqu2RG4mJpBoqhP42zgqr0YLamMuSdac1tRkacgM4flI9qrU819ekofZc9z3r8g b2BoR9HQlJDpgxWTlZ/JZkwkZsAH0QoginoPiq5fZapkkpAorVnClg6p1jPWxQce8jwl AlP/fbgsvAAdq03/0wg2inKdAGsIrEcTEMQ7XMQpTRFxNbwhlXXG7UXi25Vz9f30EIta xDBe+HHPJAPDv5FgrnOfnrWPsHvvFHXMO6z4JszlzTbyb+nSSAPaBejAKR0mrtI8gXiy 8Pbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693526634; x=1694131434; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rblH4AJS0AX7b1FEfJuCZ1jlebVpa6UT/Ggb2OuXcy0=; b=NAkOFq9I7S0Wh2Mato+gJ7vtqGPL7/kQtFUaqs7LuzYLxNLRwbGxcPzMx2N+O3cqYs zXj1SX/+KPPpsOi0KkOXl4Ap5HpOzLmtBrr397YXrKmgwcLLmq0wXeuTcFHwGRp5SG6n 96f+1SH9PN+3g7I6VqUaPgxBE8ZSgNLXM5b9kcPbwGsWOTxWjeTX6oR1Fg0UH8bBEDuj ATSu0Cr631towtTV+wqX9vLvjN/36BeCf3hNBU3wSo6+9rwb3DBQw9VG7Ph4Q3p/wHm+ D93NActPoJDPy/6EFEiLcHAJnS6Ajk01h6sgamCPrH8/JIy+A7IkUEM7GyX8hcKYnI6E 000g== X-Gm-Message-State: AOJu0YxinWkSQxX/gjoWBYAJcoS6hDC1j/eS5jh72Yl1kNWUd12C7ZiD +qxkaeyBLIf4it+LNCWzjKg= X-Google-Smtp-Source: AGHT+IFAQkvwjwGZSet1PZ1m3Y0r82uc94EYdPVY90HBErKKe7hB4z0kpSmh/NcAPN1A0Q/1U0NAcw== X-Received: by 2002:a05:600c:218f:b0:401:bdf9:c336 with SMTP id e15-20020a05600c218f00b00401bdf9c336mr582111wme.27.1693526633832; Thu, 31 Aug 2023 17:03:53 -0700 (PDT) Received: from krug (a95-92-228-31.cpe.netcabo.pt. [95.92.228.31]) by smtp.gmail.com with ESMTPSA id n23-20020a1c7217000000b003fee567235bsm6419840wmc.1.2023.08.31.17.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 17:03:53 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Philip Kaludercic Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <87jzvsdco1.fsf@posteo.net> (Philip Kaludercic's message of "Sat, 24 Jun 2023 16:53:50 +0000") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> Date: Fri, 01 Sep 2023 01:06:35 +0100 Message-ID: <87zg2669kk.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) 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: 60338 Cc: dmitry@gutov.dev, Eli Zaretskii , 60338@debbugs.gnu.org, Eshel Yaron X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, I've finally pushed this to master, after working on mostly on the user confirmation logic. I deprecated `eglot-confirm-server-initiated-edits' (had crap semantics anyway) and replaced it with a shiny new 'eglot-confirm-server-edits', with a simpler name but much more powerful (see its docstring). I left in Philip's new implementation of the diff confirmation but I didn't make it the default (although it's my preferred one) because it might appeal to everyone used to the "summary" prompt. Please have a look, give it some testing, and tell me if I missed anything. Thanks to Philip for the original idea. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 01 01:18:40 2023 Received: (at 60338) by debbugs.gnu.org; 1 Sep 2023 05:18:40 +0000 Received: from localhost ([127.0.0.1]:59692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbwYJ-0001rh-Tl for submit@debbugs.gnu.org; Fri, 01 Sep 2023 01:18:40 -0400 Received: from mout02.posteo.de ([185.67.36.66]:51879) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbwYG-0001rS-Qp for 60338@debbugs.gnu.org; Fri, 01 Sep 2023 01:18:38 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C516B240104 for <60338@debbugs.gnu.org>; Fri, 1 Sep 2023 07:18:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1693545501; bh=D7//91VMCADAwag8bEiXoX7IKP3jQiyZFqAFFFbcwaE=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=DpK5NsajMywEBvTzBW9KKUXz9gPLwNEVVMrb1WwYVaWMqFqyW4H4ii/V1osI8Cf8a xacbU8iViiohCSA9k/DtkMUBCQvuUla838s5wV2XEJ6PjUdEtxO3+MKuGfONkVJfGZ 7rt8MDpVxy4gGMDddWmWtSN5yD26wgu7txjAQbBfmDFCHCAOi84N2RZ94RHHv1ckMq KBpxYJPUd5Oh+Bi9qCCGtn6x765N12vF3yQrPFaWgodgjSpu11+e0FOTJ8yEYiL4F6 +8mKH9ib25YpdSexTamN4cmowYjnSSFKW8DqiTo+Lci5FG2rliI3CWKLfU4c2tQAty 8jBAG1+ZuctKA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RcRBj025jz9rxH; Fri, 1 Sep 2023 07:18:20 +0200 (CEST) From: Philip Kaludercic To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <87zg2669kk.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Fri, 01 Sep 2023 01:06:35 +0100") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Fri, 01 Sep 2023 05:18:20 +0000 Message-ID: <87sf7ywjxf.fsf@posteo.net> 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: dmitry@gutov.dev, Eli Zaretskii , 60338@debbugs.gnu.org, Eshel Yaron X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Jo=C3=A3o T=C3=A1vora writes: > Hello, > > I've finally pushed this to master, after working on mostly on the user > confirmation logic. I deprecated `eglot-confirm-server-initiated-edits' > (had crap semantics anyway) and replaced it with a shiny new > 'eglot-confirm-server-edits', with a simpler name but much more powerful > (see its docstring). > > I left in Philip's new implementation of the diff confirmation but I > didn't make it the default (although it's my preferred one) because it > might appeal to everyone used to the "summary" prompt. > > Please have a look, give it some testing, and tell me if I missed > anything. > > Thanks to Philip for the original idea. Thank you very much for finishing up the patch to the end. > Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 01 17:13:24 2023 Received: (at 60338) by debbugs.gnu.org; 1 Sep 2023 21:13:24 +0000 Received: from localhost ([127.0.0.1]:34264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcBSF-0000Jz-Og for submit@debbugs.gnu.org; Fri, 01 Sep 2023 17:13:24 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:38524 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcBSD-0000Jr-Oh for 60338@debbugs.gnu.org; Fri, 01 Sep 2023 17:13:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1693602791; bh=p7+2tpnFQrb/04j8/aR1nUasHtcgaQcE3Xxk1CsBBps=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=B0OaMKpkoMFlKg8kU35Yyvm3L84CtbLQIdaot+YihNKZGOhkYttPQKe1LUwg8+Od2 VFPeHbCMKSAx3yGQlhcJWzIwhzhZ8dBem/6XqqhPdSUhI8NW5QoxwweniSbE9OMewx tfN96C4JnfG3t/c/iFDsIf8dIweK8YsNtLjRtgnFbmeWsUl/+6i2fWjRmwoatSw2MR +/SJz+2+Ll0hpRqialgIQiPZWuVBJyuXUSyREMGArugudiMjAltghbSRtRaKMKRHzX Akn8WkFvMYbixp15V1Cq3YvhYHsOli3Wxf8ZU3Z1QKXtFiCsOxI5e5oRS0CkzSdA3U PKM4sVo+DntlQ== From: Eshel Yaron To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: <87zg2669kk.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Fri, 01 Sep 2023 01:06:35 +0100") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> Date: Fri, 01 Sep 2023 23:12:59 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) 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: 60338 Cc: dmitry@gutov.dev, Philip Kaludercic , 60338@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jo=C3=A3o T=C3=A1vora writes: > I've finally pushed this to master, after working on mostly on the user > confirmation logic. I deprecated `eglot-confirm-server-initiated-edits' > (had crap semantics anyway) and replaced it with a shiny new > 'eglot-confirm-server-edits', with a simpler name but much more powerful > (see its docstring). > [...] > > Please have a look, give it some testing, and tell me if I missed > anything. Great stuff! One issue I came across is with unsaved buffers. Here's a recipe: With emacs -Q, set `eglot-confirm-server-edits` to `diff`. In a fresh git repository, create a new file `foo.go` and insert the following: --8<---------------cut here---------------start------------->8--- package baz type Foobar interface {} --8<---------------cut here---------------end--------------->8--- Now save the file, and do `M-x go-ts-mode` followed by `M-x eglot` to connect to an LSP server (`gopls` in my case). Without saving the buffer, insert `type Baz interface {}` after the last line: --8<---------------cut here---------------start------------->8--- package baz type Foobar interface {} type Baz interface {} --8<---------------cut here---------------end--------------->8--- With point on `Baz`, do `M-x eglot-rename RET Spam RET`. Emacs displays the following diff in *EGLOT proposed server changes*: --8<---------------cut here---------------start------------->8--- diff -u /Users/eshelyaron/tmp/bug/foo.go /var/folders/q1/h0vdt_hx00zgbv3bpy= x2vdr00000gp/T/buffer-content-sgzkbC --- /Users/eshelyaron/tmp/bug/foo.go 2023-09-01 20:55:02 +++ /var/folders/q1/h0vdt_hx00zgbv3bpyx2vdr00000gp/T/buffer-content-sgzkbC = 2023-09-01 20:55:07 @@ -1,3 +1,4 @@ package baz =20 type Foobar interface {} +Spam \ No newline at end of file Diff finished. Fri Sep 1 20:55:08 2023 --8<---------------cut here---------------end--------------->8--- We clearly get an incorrect patch. It seems like the patch is produced by comparing the modified version of the buffer to the visited file, instead of comparing it to the current buffer contents. Another, smaller issue is that while `eglot-rename` is creating the patch it prints messages along the lines of: [eglot] applying 1 edits to `*temp*-207900' Which feels less appropriate in these settings. Lastly, I have an improvement suggestion for the `:type` of `eglot-confirm-server-edits` to make it nicer to deal with via Custom: diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 8d95019c3ed..afb99e4b9ca 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -413,12 +413,17 @@ eglot-confirm-server-edits `eglot-code-actions', `eglot-code-action-quickfix', etc. ACTION is one of the symbols described above. The value `t' for COMMAND is accepted and its ACTION is the default value." - :type '(choice (const :tag "Use diff" diff) + :type (let ((basic-choices + '((const :tag "Use diff" diff) (const :tag "Summarize and prompt" summary) (const :tag "Maybe use diff" maybe-diff) (const :tag "Maybe summarize and prompt" maybe-summary) - (const :tag "Don't confirm" nil) - (alist :tag "Per-command alist"))) + (const :tag "Don't confirm" nil)))) + `(choice ,@basic-choices + (alist :tag "Per-command alist" + :key-type (choice (function :tag "Command") + (const :tag "Default" t)) + :value-type (choice . ,basic-choices))))) =20 (defcustom eglot-extend-to-xref nil "If non-nil, activate Eglot in cross-referenced non-project files." From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 01 17:17:36 2023 Received: (at 60338) by debbugs.gnu.org; 1 Sep 2023 21:17:36 +0000 Received: from localhost ([127.0.0.1]:34272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcBWJ-00035D-UJ for submit@debbugs.gnu.org; Fri, 01 Sep 2023 17:17:36 -0400 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]:54404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcBWI-000350-3r for 60338@debbugs.gnu.org; Fri, 01 Sep 2023 17:17:34 -0400 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2bd0a5a5abbso40144371fa.0 for <60338@debbugs.gnu.org>; Fri, 01 Sep 2023 14:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693603039; x=1694207839; darn=debbugs.gnu.org; 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=Q/6AUDkOI+pNTtebLs9INU7mjuSlZzr8U26b11M+qMY=; b=E0K+m204rqWhpJTcjCA+cnxVGtBHVT5BudpFsklsQSlpwhVVMbmGanRNJTmBVB2yfR oKc4v9TjhSz93PnAXWCAlDfZGz2Bvjzz6cX0wnYsVyyAL4mIKQnhHsjUjT6pojn/oczV Zu37v491l/BrQ+CH0/8W6TH4qC8vSSyEfQtPj4duAmkM6A+sNSRuFgcof7FEP2w7DyXx Pcy8tftvt99J1cifKWWya0aFmF/1/OqtlEbvKK3EaHVyfsaMmEiaiuf6O/TaGOpFrcWN ctNYzJJHCq9oQ7uyciwtrzKE+euW2DjBbm3ObfCLjt92xOotXZIA+o4+h6pY5+hKun3P yzKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693603039; x=1694207839; 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=Q/6AUDkOI+pNTtebLs9INU7mjuSlZzr8U26b11M+qMY=; b=jEBsZWDXJmvNhf/UztigzacnUpoRtNMdik3px2OVlESEIj2h4MQgOkmEwf8ZddWldy Ks1ARt1ElEC+r4MOzXCHHchptSVX3gaOYHIGdN37Vh6q/y23fQXHmhwDEmrZM7sLO37q 1kXykv8wB8147vwiGEEP0t5J3vU72bwIAEQjPuExzNHMqlL0dquWc5+opSZihwFvIvXZ KEMTSD83yvxB7lUcznXopBFFM0y/goPq6vlNLN6B1nYBfoz6Fn4o4E0EmuB5NRHPNwoG z18hjuGGVTpDoc6MAk6b2lfIiHml00lnZPOt9Li4XyLgmyxqqh+D0vnZtDnWzDSv8O1G p4ZA== X-Gm-Message-State: AOJu0YwJr3zrRB5wK7qxjeTrs57GBGGGG29OwxBfUrs5Ude+lH08LoT4 vml6K+D0bWcMkhFdlcYaY933LlD0Xcv0ElyI5MM= X-Google-Smtp-Source: AGHT+IEApwizwAqwqkWLR6efTX1j0B4Ke+XMORuG9AdAa/GFjuaPNu149yMo206Dlqsj6qndWpqvbE/3furyQqsWdSs= X-Received: by 2002:a2e:b6c5:0:b0:2bb:9781:1a4c with SMTP id m5-20020a2eb6c5000000b002bb97811a4cmr2451116ljo.27.1693603038468; Fri, 01 Sep 2023 14:17:18 -0700 (PDT) MIME-Version: 1.0 References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Fri, 1 Sep 2023 22:19:50 +0100 Message-ID: Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs To: Eshel Yaron Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60338 Cc: dmitry@gutov.dev, Philip Kaludercic , 60338@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Fri, Sep 1, 2023 at 10:13=E2=80=AFPM Eshel Yaron wro= te: > > Jo=C3=A3o T=C3=A1vora writes: > > > I've finally pushed this to master, after working on mostly on the user > > confirmation logic. I deprecated `eglot-confirm-server-initiated-edits= ' > > (had crap semantics anyway) and replaced it with a shiny new > > 'eglot-confirm-server-edits', with a simpler name but much more powerfu= l > > (see its docstring). > > > [...] > > > > Please have a look, give it some testing, and tell me if I missed > > anything. > > Great stuff! One issue I came across is with unsaved buffers. I'm fixing that as we speak. I'll read your recipe later, but I'm 90% sure it's the same stuff I've been trying to fix for most of today. > Lastly, I have an improvement suggestion for the `:type` of > `eglot-confirm-server-edits` to make it nicer to deal with via Custom: > > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el > index 8d95019c3ed..afb99e4b9ca 100644 > --- a/lisp/progmodes/eglot.el > +++ b/lisp/progmodes/eglot.el > @@ -413,12 +413,17 @@ eglot-confirm-server-edits > `eglot-code-actions', `eglot-code-action-quickfix', etc. ACTION > is one of the symbols described above. The value `t' for COMMAND > is accepted and its ACTION is the default value." > - :type '(choice (const :tag "Use diff" diff) > + :type (let ((basic-choices > + '((const :tag "Use diff" diff) > (const :tag "Summarize and prompt" summary) > (const :tag "Maybe use diff" maybe-diff) > (const :tag "Maybe summarize and prompt" maybe-summary) > - (const :tag "Don't confirm" nil) > - (alist :tag "Per-command alist"))) > + (const :tag "Don't confirm" nil)))) > + `(choice ,@basic-choices > + (alist :tag "Per-command alist" > + :key-type (choice (function :tag "Command") > + (const :tag "Default" t)) > + :value-type (choice . ,basic-choices))))) > > (defcustom eglot-extend-to-xref nil > "If non-nil, activate Eglot in cross-referenced non-project files." I'll look at this bit, too. I looks sane, and I'm glad I found a custom.e= l expert to call on :-) Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 01 17:59:23 2023 Received: (at 60338) by debbugs.gnu.org; 1 Sep 2023 21:59:23 +0000 Received: from localhost ([127.0.0.1]:34327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcCAk-0004BT-Sk for submit@debbugs.gnu.org; Fri, 01 Sep 2023 17:59:23 -0400 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]:51294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcCAj-0004BB-8c for 60338@debbugs.gnu.org; Fri, 01 Sep 2023 17:59:22 -0400 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-1c4d67f493bso1674743fac.2 for <60338@debbugs.gnu.org>; Fri, 01 Sep 2023 14:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693605546; x=1694210346; darn=debbugs.gnu.org; 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=+okwWO1jKOjWmMKke56ieiQ/j3zXnubMFruI7bS7SXQ=; b=R3xeGUkjDgfZPTrAflG+kOORqX16L0U6jeqdR4QIRDeIgFLNCuSETgLwKvs+NabhoK TXNMWLgIuEwX5m7Tx5Y1qYv7HhSyhWImW132dhZBuTI3DvC5zHKofYCP55v93hxb7509 2aFpZEr2AD2+FrcQh02SgVCaQaCMclaiG1vBfbLbPD8+3tMIS1UFcxm7o8gJfrOXUQJ5 9iM8mCpo+vOO6THJFU0D6/T667anNZSboCE6TBDbTciZ15KTLFTRkjtmi9M40PHzXSXn whw+LMsbNcQFGgqaouK1Efl1saVqhwD4Z4mhurDKTq0YP9wflGKn7eTM7OJeG0Ljrkzr 2h/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693605546; x=1694210346; 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=+okwWO1jKOjWmMKke56ieiQ/j3zXnubMFruI7bS7SXQ=; b=k2DYkBR4aNsApSj0Vcoh1IgPnRUMGTWImKLKeeQWnHnSJVvuXECXaeVZopyBj5efhz Zo9PJMmZ5bEYw5502jZMI1ym36djTze4/P/80nEWbPjLzXNTSu/WdQ0G9GD+0CHjY/as VNnFRw3gB2KaX2ag2qPnpIdYb5fbrHYi4TjZ2R1YOjzfS4mKwrfva1qB9K4iPxzFpM9A Zskn9fcs9CMNvc+RCb6OGgpG67vIqwEOW5WrLgBLb6zSAupp5lZjOSosjAA5dC2eAmVG pkIHwpZfBy2CKj6NoER/voz74bcDyz/lqs3U2v4prPCMRfKquBUkBiRsDK6gj/eB5mjI JGMw== X-Gm-Message-State: AOJu0YzVwnQj3WeSRDBWO3KTjCmo6q7nsZSbmbkblj1aLi17ywNSR+tD s+YhnDsPait3nxa0G5yhPlgZTdq7gZOpncxCo+A= X-Google-Smtp-Source: AGHT+IFsAlIYl/6w12YXgygUHt/xj3CfwqMrYLPsGqu4Ujkcy0aSPYV28KG20SJmmVFVWLkCCBX38FUKCP95k20SEjk= X-Received: by 2002:a05:6870:f61b:b0:1c8:ca70:dd0c with SMTP id ek27-20020a056870f61b00b001c8ca70dd0cmr4022244oab.19.1693605545735; Fri, 01 Sep 2023 14:59:05 -0700 (PDT) MIME-Version: 1.0 References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Fri, 1 Sep 2023 23:01:37 +0100 Message-ID: Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs To: Eshel Yaron Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60338 Cc: dmitry@gutov.dev, Philip Kaludercic , 60338@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) OK, Eshel I think I fixed all these issues in the latest fdf6c164efd0bb467d0d46460161c146e955a48c which I just pushed to master. Please have a look. Thanks, Jo=C3=A3o On Fri, Sep 1, 2023 at 10:13=E2=80=AFPM Eshel Yaron wro= te: > > Jo=C3=A3o T=C3=A1vora writes: > > > I've finally pushed this to master, after working on mostly on the user > > confirmation logic. I deprecated `eglot-confirm-server-initiated-edits= ' > > (had crap semantics anyway) and replaced it with a shiny new > > 'eglot-confirm-server-edits', with a simpler name but much more powerfu= l > > (see its docstring). > > > [...] > > > > Please have a look, give it some testing, and tell me if I missed > > anything. > > Great stuff! One issue I came across is with unsaved buffers. > Here's a recipe: > > With emacs -Q, set `eglot-confirm-server-edits` to `diff`. In a fresh > git repository, create a new file `foo.go` and insert the following: > > --8<---------------cut here---------------start------------->8--- > package baz > > type Foobar interface {} > --8<---------------cut here---------------end--------------->8--- > > Now save the file, and do `M-x go-ts-mode` followed by `M-x eglot` to > connect to an LSP server (`gopls` in my case). Without saving the > buffer, insert `type Baz interface {}` after the last line: > > --8<---------------cut here---------------start------------->8--- > package baz > > type Foobar interface {} > type Baz interface {} > --8<---------------cut here---------------end--------------->8--- > > With point on `Baz`, do `M-x eglot-rename RET Spam RET`. Emacs displays > the following diff in *EGLOT proposed server changes*: > > --8<---------------cut here---------------start------------->8--- > diff -u /Users/eshelyaron/tmp/bug/foo.go /var/folders/q1/h0vdt_hx00zgbv3b= pyx2vdr00000gp/T/buffer-content-sgzkbC > --- /Users/eshelyaron/tmp/bug/foo.go 2023-09-01 20:55:02 > +++ /var/folders/q1/h0vdt_hx00zgbv3bpyx2vdr00000gp/T/buffer-content-sgzkb= C 2023-09-01 20:55:07 > @@ -1,3 +1,4 @@ > package baz > > type Foobar interface {} > +Spam > \ No newline at end of file > > Diff finished. Fri Sep 1 20:55:08 2023 > --8<---------------cut here---------------end--------------->8--- > > We clearly get an incorrect patch. It seems like the patch is produced > by comparing the modified version of the buffer to the visited file, > instead of comparing it to the current buffer contents. > > Another, smaller issue is that while `eglot-rename` is creating the > patch it prints messages along the lines of: > > [eglot] applying 1 edits to `*temp*-207900' > > Which feels less appropriate in these settings. > > Lastly, I have an improvement suggestion for the `:type` of > `eglot-confirm-server-edits` to make it nicer to deal with via Custom: > > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el > index 8d95019c3ed..afb99e4b9ca 100644 > --- a/lisp/progmodes/eglot.el > +++ b/lisp/progmodes/eglot.el > @@ -413,12 +413,17 @@ eglot-confirm-server-edits > `eglot-code-actions', `eglot-code-action-quickfix', etc. ACTION > is one of the symbols described above. The value `t' for COMMAND > is accepted and its ACTION is the default value." > - :type '(choice (const :tag "Use diff" diff) > + :type (let ((basic-choices > + '((const :tag "Use diff" diff) > (const :tag "Summarize and prompt" summary) > (const :tag "Maybe use diff" maybe-diff) > (const :tag "Maybe summarize and prompt" maybe-summary) > - (const :tag "Don't confirm" nil) > - (alist :tag "Per-command alist"))) > + (const :tag "Don't confirm" nil)))) > + `(choice ,@basic-choices > + (alist :tag "Per-command alist" > + :key-type (choice (function :tag "Command") > + (const :tag "Default" t)) > + :value-type (choice . ,basic-choices))))) > > (defcustom eglot-extend-to-xref nil > "If non-nil, activate Eglot in cross-referenced non-project files." --=20 Jo=C3=A3o T=C3=A1vora From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 02:13:21 2023 Received: (at 60338) by debbugs.gnu.org; 2 Sep 2023 06:13:21 +0000 Received: from localhost ([127.0.0.1]:34961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcJsn-0007Ux-Fi for submit@debbugs.gnu.org; Sat, 02 Sep 2023 02:13:21 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:40152 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcJsj-0007Un-QU for 60338@debbugs.gnu.org; Sat, 02 Sep 2023 02:13:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1693635187; bh=WbL8ff6VJ06/12TyghPtk4WXOvXOWQYLjTVWx+Q+6WQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=lUOvaL46YWFzmNY9BItm1t6ILfEwoMj6oRpQDZivX6XNkkEupmxt/2YSGYf9Ju/fk D+TKwVMj6vlFsSklFL2foaTvL9HUmVZGDWHvG+uI772DYZqPYVrlNKAqg6gxvTgLcb R3erDekVzRB35n3ra5mcMULv1HYSe7fe7FxeDRq2MbCYLhFd67f8naL0seuo/zYj6T B39lOwkaLKn5lPhcwwqoc5+Mo8sz3UZ1vbm+rJw6kbiEwDOCXFK+oVVpp/1maCxDnf WWeLZxSw2gtVRHFEJUNo9J67eREhD3Yb9Pl8h6ud3xMrhVktNDGJM8/mzy99Ec3zCx Z3Su0AyS7Au8Q== From: Eshel Yaron To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Fri, 1 Sep 2023 23:01:37 +0100") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> X-Hashcash: 1:20:230902:joaotavora@gmail.com::UPlYmCKN4cshk2u6:0fOW X-Hashcash: 1:20:230902:philipk@posteo.net::RiAMc1KcLCIa5hPN:3Nf4 X-Hashcash: 1:20:230902:dmitry@gutov.dev::exGRJxMoMOr7Je6C:0jC0 X-Hashcash: 1:20:230902:eliz@gnu.org::I9qJdJIZHLoOEiHp:2UBj X-Hashcash: 1:20:230902:60338@debbugs.gnu.org::+mCj+d09QOmkfevM:57N2 Date: Sat, 02 Sep 2023 08:13:04 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) 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: 60338 Cc: dmitry@gutov.dev, Philip Kaludercic , 60338@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jo=C3=A3o T=C3=A1vora writes: > OK, Eshel > > I think I fixed all these issues in the latest > fdf6c164efd0bb467d0d46460161c146e955a48c which I just > pushed to master. Please have a look. Looks good, and works well too, thank you! From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 05:53:32 2023 Received: (at 60338-done) by debbugs.gnu.org; 2 Sep 2023 09:53:32 +0000 Received: from localhost ([127.0.0.1]:35252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcNJs-0007WQ-8r for submit@debbugs.gnu.org; Sat, 02 Sep 2023 05:53:32 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:57519) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcNJq-0007W9-5q for 60338-done@debbugs.gnu.org; Sat, 02 Sep 2023 05:53:31 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-401b0d97850so28586565e9.2 for <60338-done@debbugs.gnu.org>; Sat, 02 Sep 2023 02:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693648394; x=1694253194; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TRASGpAuceNPWOMRaX57MfrgfdYIYwjIn0pwKefhZQw=; b=D0M1yQGBQOXpolGIPvd5y3Mf5F8jtIadgkAwhWUyGJSzTDAju6qqmpLcdkMvh3V/23 l/5YGG5BYAHs/z5AflRiBOFfMVUVxU5mofWRnirqmCLdJPQpiTvgYhG0gFUpocBgriuO HL9rcQGXjwGvf0cL4lB06H+DruWsvPexMKVDQdagFGXx/5YZWd3XkOqhJWrh+lri6hRt w9c7j0Z8r8lcx7zdmC0oWImU0rImug6GeS9LNGVfSwRFm13lWi0sJq0SoQ2mgJ2jfhhU d58lI18jvxHL/h0c8zDxzZ3PIwOGxPlIF6ZjudFdNSc6pb3qhbpDYcZ1VrGwS0CpdqFq Wrkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693648394; x=1694253194; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TRASGpAuceNPWOMRaX57MfrgfdYIYwjIn0pwKefhZQw=; b=A9Cvg0/fAFqWw433fy+xd0a4cYHklBSujtKthwP1ZsBJtv6HuxxSIdaAZVFwZ6Xoov tAoVEj7rSTiGu9JQGVe4Pb6/5viCfvi87LgSug/scmjKihVyEIXLTr0xEZV9RYXm+LZd 3S8KrkoTkU/tl591VzxWw5qw6RkVWSS9/fysowdPOxJN28GpiXf+A2HdzKzY/LqK7UfI 27VXOoaqhAfza7afyLdpST3ecYBOxnxQfdT+E7mCTD4zeWtEH7OPoEDOykPBvV2ijvDa 26jOGiJXnFt3Z4FMsJZJuVZOusU3ZbempQ4a/fkh+bWrzLrQd7AJDLl5BoGGT3RGAD1F XG7A== X-Gm-Message-State: AOJu0YyeeEGUkL+Dlek4SnWkupd8v29bI9Gkyk5OZvyvX+XsYiFl1ujT PgjWQPCV2LL7aDPjdy/abgFoyxB344ybsA== X-Google-Smtp-Source: AGHT+IEYyw0qDBvAVzEqaf3JE86San1peoV2+NdSoF0zmwEfcnIzJLwU97hFRONqx5eRD9yXniY5gQ== X-Received: by 2002:a05:600c:2249:b0:3fb:b008:2003 with SMTP id a9-20020a05600c224900b003fbb0082003mr3325230wmm.38.1693648393840; Sat, 02 Sep 2023 02:53:13 -0700 (PDT) Received: from krug (a95-92-228-31.cpe.netcabo.pt. [95.92.228.31]) by smtp.gmail.com with ESMTPSA id 10-20020a05600c234a00b003fc06169ab3sm10539323wmq.20.2023.09.02.02.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 02:53:13 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Eshel Yaron Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: (Eshel Yaron's message of "Sat, 02 Sep 2023 08:13:04 +0200") References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> Date: Sat, 02 Sep 2023 10:55:56 +0100 Message-ID: <87sf7w526r.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) 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: 60338-done Cc: dmitry@gutov.dev, Philip Kaludercic , Eli Zaretskii , 60338-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eshel Yaron writes: > Jo=C3=A3o T=C3=A1vora writes: > >> OK, Eshel >> >> I think I fixed all these issues in the latest >> fdf6c164efd0bb467d0d46460161c146e955a48c which I just >> pushed to master. Please have a look. > > Looks good, and works well too, thank you! I'm glad to hear that. I must say that altough I like the new functionality myself -- both the new user option and the diff view -- the current implementation of the latter leaves much to be desired. I've pushed a further commit to simplify it, but it's complicated and brittle. A little change to diff.el would simplify some of it, but then you can't easily publish those changes to Emacs < 29. Anyway I invite everyone to have a look and try to improve it, perhaps moving it out of Eglot into the shiny new "refactoring interface" if those ever become a thing. In the meantime, I'm going to close this. Thanks everybody. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 06 21:00:48 2023 Received: (at 60338-done) by debbugs.gnu.org; 7 Sep 2023 01:00:48 +0000 Received: from localhost ([127.0.0.1]:38181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qe3O3-0005By-No for submit@debbugs.gnu.org; Wed, 06 Sep 2023 21:00:48 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:50733) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qe3O0-0005Bk-3Z for 60338-done@debbugs.gnu.org; Wed, 06 Sep 2023 21:00:45 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 676BF5C01B1; Wed, 6 Sep 2023 21:00:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 06 Sep 2023 21:00:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1694048437; x=1694134837; bh=uEiyNtyZ0cLkrLkfLLlTXtDSMt8gfjzQJ5t 8h+ZvPnU=; b=F5c0sv/eAuyShLPem6eeC8zgmkRFhRVZLuGym2EqvXwRPF2ocGD K39naOYlZEBhSJJ2C9cQLEhfhNMwetQ2h9M24DX6EI6F9EfN1WkBPcZbRWiHP5n2 eU21guZZBhdsSECw/ZqVM8CoeLRNtkZgbeLImQtpAOx9DtAcG5wqNAioq2kWxRV3 rJB4TvtFqAooIofeg0AzsDoro6aozxOZyrokRveNeUUxUrephdOb5efSC3YqIMAr ldYU0vDnsCo1eoL/uAS/dETZyPyuKLj9C6nqWLEuEfZP/KamAASrcgndEpBoeTRX 7MDnWQREaT7MoPa/S8XctR5hD/ZuOcRxfpQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1694048437; x=1694134837; bh=uEiyNtyZ0cLkrLkfLLlTXtDSMt8gfjzQJ5t 8h+ZvPnU=; b=Zi+ko7V8fCHQF9RitIh2qrxrstYsyxNelL/ElniZL0EepIZWHAX ffk1JfOPdAa9ly78CUIbEMI/yZalAPGg8lVWesa4a6FUZD1S4oFwoOqnnP6bHkKl DTdZtRvFP9yIwBMxf12d94aHDFRK9XJNoLnrqDRZk+WcvdPAOo4asjnET7ezSWof 1b5CzEw140BLLjcrWGGSPRmdkEtyIN5X9eBNt+328T3rkxHndxO9yRMbzX480BLo VW/OF92g68vlG3dtnPoiNE8TJpkPBL7sFCDJlgRA8SZqfIV8Bl5LyV31oWMNHAlW 3vSwUnlJfsBOHb0i36DTOdlGzWy3qdJV7BQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehgedggeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhephfffheeljeffgeffueeghfekkedtfffgheejvdegjeettdduheeufffggfef jeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 21:00:35 -0400 (EDT) Message-ID: Date: Thu, 7 Sep 2023 04:00:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs Content-Language: en-US To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= , Eshel Yaron References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> <87sf7w526r.fsf@gmail.com> From: Dmitry Gutov In-Reply-To: <87sf7w526r.fsf@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 60338-done Cc: Philip Kaludercic , Eli Zaretskii , 60338-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.2 (---) On 02/09/2023 12:55, João Távora wrote: > Anyway I invite everyone to have a look and try to improve it, perhaps > moving it out of Eglot into the shiny new "refactoring interface" if > those ever become a thing. Regarding the diff approach vs. "shiny new", I've run a little comparison with VS Code: doing a rename of 'glyph_row' across the Emacs codebase (a moderately sized project) takes about ~1.44s to produce the diff. VS Code's "Refactor Preview" takes about 1/3rd of that time to show. I'm guessing that's because it just paints whatever the language server returns instead of doing a bunch of process calls. If that is the case, one of the approaches seems to have a fundamental performance advantage. Not to belittle the new addition, though - it's a good step for Eglot. Two other thoughts after trying it: - I would probably want to bind the originally proposed 'diff-apply-everything' to 'C-c C-c' (e.g. "commit the change to disk"), but that's already taken in diff-mode. - 'git diff' has a less-frequently used option called '--word-diff' which could reduce the length of the diff in the case I am testing (but I guess diff-mode would have to be updated to support that output). And another way in that direction would be to reduce the size of the diff context (e.g. to 0). From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 07 02:33:39 2023 Received: (at 60338) by debbugs.gnu.org; 7 Sep 2023 06:33:39 +0000 Received: from localhost ([127.0.0.1]:38374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qe8aA-0005Bc-QU for submit@debbugs.gnu.org; Thu, 07 Sep 2023 02:33:39 -0400 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]:57629) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qe8a7-0005BJ-OI for 60338@debbugs.gnu.org; Thu, 07 Sep 2023 02:33:37 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 4F42A1BF20D; Thu, 7 Sep 2023 06:33:25 +0000 (UTC) From: Juri Linkov To: Dmitry Gutov Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs In-Reply-To: (Dmitry Gutov's message of "Thu, 7 Sep 2023 04:00:33 +0300") Organization: LINKOV.NET References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> <87sf7w526r.fsf@gmail.com> Date: Thu, 07 Sep 2023 09:28:31 +0300 Message-ID: <868r9io6lo.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60338 Cc: Philip Kaludercic , 60338@debbugs.gnu.org, Eshel Yaron , =?iso-8859-1?Q?Jo=E3o_T=E1vora?= , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Two other thoughts after trying it: > > - I would probably want to bind the originally proposed > 'diff-apply-everything' to 'C-c C-c' (e.g. "commit the change to disk"), > but that's already taken in diff-mode. If there are no more intuitive keys, maybe then use the proposed by Philip 'C-c C-x'? > - 'git diff' has a less-frequently used option called '--word-diff' which > could reduce the length of the diff in the case I am testing (but I guess > diff-mode would have to be updated to support that output). And another > way in that direction would be to reduce the size of the diff context > (e.g. to 0). Whereas the output of '--word-diff' is closer to VS Code, but it's hard to read for anyone accustomed to the diff unified format ;-) BTW, it looks '--word-diff' could help Samuel in bug#61396? From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 07 08:42:09 2023 Received: (at 60338) by debbugs.gnu.org; 7 Sep 2023 12:42:09 +0000 Received: from localhost ([127.0.0.1]:38822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeEKn-000399-6a for submit@debbugs.gnu.org; Thu, 07 Sep 2023 08:42:09 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:47607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeEKk-00038A-Cv for 60338@debbugs.gnu.org; Thu, 07 Sep 2023 08:42:07 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 657C65C0089; Thu, 7 Sep 2023 08:41:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 07 Sep 2023 08:41:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1694090519; x=1694176919; bh=NLVhao8Cb/mJg9vpDpKuxTrnT6/MPLf0SRR NLC9OIwA=; b=DqmMrHw2v0KeoeJP3h7lgO+9Qp2kRAK+8BUeUPTprLDcbXr+InN JsD74763vl4AX1nhHOqaSKKpF0ayc7uQ4swhaVBXrL5XGsOAx6PGCEpNjlaTJKik isAf/IpDXLlzF26OeOd6oEKaLrxlj7pqs+N8yX2QRYCX9vbUzb4cqEn6cM0WR0co f7YZ7n8NVec2AbOaWng/XkLv4p0bqeoe/D9Zb9IwKynFkoN/fSF4nItIhumAU81/ 4yLvtKqKDHAIOuAm9xaRv2URZaebOJBJ5cI2HZZCAahqVZjYDZbc2SCy/gNJqbQ9 A96xPmAT9PfJA6jyMEXuk92PhQA51CaeN9Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1694090519; x=1694176919; bh=NLVhao8Cb/mJg9vpDpKuxTrnT6/MPLf0SRR NLC9OIwA=; b=riMjpm2XY7/ff8ARIEG4USxbmF3xAtAyBMWOg+HWu2UKc/jQh+p Iq9na6o5yJ0l4eLRL6qngTLN7kgcS+Gfx524GykosM/0vtrDdPR2MzADpcup2tiF qfVW20RcCNGxeLWpVEXHSADp3YsetSK6xkxa4BwckYUcSRPvEdjJLZG1jKbyhi+o hilhP6E5t3jc8j+4jUBVbaDnijlYhfaCIq+kKgCMGRBCkCX9SkH5YXrh9QjU0ORx jjpU180Jd/XLdY/RQAcaVSSd0m9op+R2zDYrWJHnk+7bLPXKXgDXYl4RDZw5aysu /7KR1VHfDwdffDtIE4eEhgGJrtSDLtbiIJw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehhedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Sep 2023 08:41:57 -0400 (EDT) Message-ID: <11e35fa9-0956-b147-ac7e-d54416197df5@gutov.dev> Date: Thu, 7 Sep 2023 15:41:55 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs Content-Language: en-US To: Juri Linkov References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> <87sf7w526r.fsf@gmail.com> <868r9io6lo.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <868r9io6lo.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 60338 Cc: Philip Kaludercic , 60338@debbugs.gnu.org, Eshel Yaron , =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.2 (---) On 07/09/2023 09:28, Juri Linkov wrote: >> Two other thoughts after trying it: >> >> - I would probably want to bind the originally proposed >> 'diff-apply-everything' to 'C-c C-c' (e.g. "commit the change to disk"), >> but that's already taken in diff-mode. > If there are no more intuitive keys, maybe then use the proposed by Philip > 'C-c C-x'? IDK, seems a little dangerous given to its proximity to 'C-x C-c'. Personally, the existing 'C-c C-c' binding seems unnecessary given that this command has 6 other bindings already. If we chose to replace it, we could just start the new command with a prompt (Apply all changes from diff?), so it doesn't surprise anyone. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 07 08:45:24 2023 Received: (at 60338) by debbugs.gnu.org; 7 Sep 2023 12:45:24 +0000 Received: from localhost ([127.0.0.1]:38827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeENv-0003EO-PL for submit@debbugs.gnu.org; Thu, 07 Sep 2023 08:45:24 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:39275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeENt-0003EB-JR for 60338@debbugs.gnu.org; Thu, 07 Sep 2023 08:45:22 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C2AAF5C0179; Thu, 7 Sep 2023 08:45:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 07 Sep 2023 08:45:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1694090714; x=1694177114; bh=TpsFCt6vyTAYi9Dk9HLodKPUzhDKGcxTlnI hxQJpJTE=; b=o4/wCATwoKF1QwJRCADQLNNxBSbPc7WAa3/EOEMJJZHmI4e3ild sdosgOec/ffVK7Wir0UkRdTgUXQlFSWkzUtyveE+4OCOLyZBUGL8P7jphwAwesWk DztgMektIkzxlSvd3DJtZMhxLa97Hoi2aeh9QcIAx4WBlRpJcqaxIkt7GFBReWG6 Qncop0vo9Bv+YQaxNnNxKW8nhv8afsUHKHBnK8C9swYBPLinzYza3geUgSAaTZc6 AczROLLuY7JjsSDjjjVTRXO3WyDGN09uX3uLrCXMRM0XHwb0yAz0f6Eo6hMxN86r CBguv2Y/3FJizNTbyHLshwMQCkQpO1egZbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1694090714; x=1694177114; bh=TpsFCt6vyTAYi9Dk9HLodKPUzhDKGcxTlnI hxQJpJTE=; b=V1EtfsCxUR8uHgDMillIWgGjEv9iBdtsiEgn8A86FtKNt5w0BRu DOovGHd7iR9qBwaW35Bz3ZQ96rRAi6afQXv75OP9x6vCB71Ya9dpwCQDbdCa0ScA fM4uVez97pAsy1e5ubavyO4JOVdeuzANSXgdd+uZJNn78uv5I7uF25g0liR6g60Z 6XL9q03nZUxRI/va43IQVQGYapcGDmXZXXvXAy/2b9JcxjIE8L9173cDJUndcWxC T2r0BjoqKQXMobFH8AKF/QgHRjL+n738VyoU1zIeG987WLLWAhj7DlevN9/MCE2d 9IXJVeE/KR1b3mQgbxtkH6XWbAxIz0xMLJQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehhedgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Sep 2023 08:45:12 -0400 (EDT) Message-ID: Date: Thu, 7 Sep 2023 15:45:11 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: bug#60338: [PATCH] Add option to present server changes as diffs Content-Language: en-US To: Juri Linkov References: <87ilhy1dub.fsf@posteo.net> <877cs97kgb.fsf@posteo.net> <83jzw8yjv5.fsf@gnu.org> <877cs8g8oy.fsf@posteo.net> <83fs6wyhak.fsf@gnu.org> <87y1koerm6.fsf@posteo.net> <83bkhkyeze.fsf@gnu.org> <87v8fr6o86.fsf@posteo.net> <87zg52e12n.fsf@posteo.net> <871qi9q9uc.fsf@posteo.net> <87a5ww7qa3.fsf@gmail.com> <87jzvsdco1.fsf@posteo.net> <87zg2669kk.fsf@gmail.com> <87sf7w526r.fsf@gmail.com> <868r9io6lo.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <868r9io6lo.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 60338 Cc: Philip Kaludercic , 60338@debbugs.gnu.org, Eshel Yaron , =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.2 (---) On 07/09/2023 09:28, Juri Linkov wrote: > BTW, it looks '--word-diff' could help Samuel in bug#61396? Quite possible, but it'd also require changes in diff-mode, and the currently discussed alternative (in refine logic, I think) might be more localized. Also, 'git apply' doesn't work on word diffs :( From unknown Sun Aug 17 22:11:22 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 06 Oct 2023 11:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator