From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#72765: Eglot + Clangd + Company + non-empty suffix = duplicate text Date: Sun, 1 Sep 2024 04:43:06 +0300 Message-ID: <48e0fa23-623e-4a73-b968-ba10d766cf37@gutov.dev> References: <83e5b9c4-0f5f-49c4-a4b2-fe553c59b2f6@gutov.dev> <86o75bftql.fsf@gnu.org> <119819e3-fc54-4f9a-9075-b07af637db12@gutov.dev> <864j71dw8e.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33895"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 72765@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 01 03:44:33 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1skZdo-0008hV-RB for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 01 Sep 2024 03:44:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1skZdN-00015k-R5; Sat, 31 Aug 2024 21:44:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1skZdM-00015T-4A for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 21:44:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1skZdL-00078l-R0 for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 21:44:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:From:References:MIME-Version:Date:To:Subject; bh=5on1qkZi/7bIdZ4Xs8mzp+zmyt1f58Ih2UIEH5kt0PE=; b=cSdaHmde6wQqMMzXWgLQxTcHOguxN+wEMvCfn7KKmgcv011frKL39jFq0p0HfYDKTJUtztFXKGsUnGdfBD9iTQij5viFUVVNTl4QPIxFGSi6YbgQaMDu9cyHAhLZQCUWfSeKJY5AlTqIrFVNT2ekfHU1kMnypqKc79otyy0g96NpOB9pvLAQx6iUrQmMpRvodhg7dOGhTjC68u8MYLyim01R3H/rfmOCFE7SUALxDnPzehVHZojd13SLC1NJjGGuKgqYqlXQb4LVlM5qxlyW7Fue5ruoCO98UYGm7KP2XAnODdwHPm765LGbz+nGE1ZNKssXrhX8OGTpsIQzdbULwA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1skZeH-0003yx-L6 for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 21:45:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 Sep 2024 01:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72765 X-GNU-PR-Package: emacs Original-Received: via spool by 72765-submit@debbugs.gnu.org id=B72765.172515505815245 (code B ref 72765); Sun, 01 Sep 2024 01:45:01 +0000 Original-Received: (at 72765) by debbugs.gnu.org; 1 Sep 2024 01:44:18 +0000 Original-Received: from localhost ([127.0.0.1]:59042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1skZdZ-0003xo-IU for submit@debbugs.gnu.org; Sat, 31 Aug 2024 21:44:18 -0400 Original-Received: from fhigh4-smtp.messagingengine.com ([103.168.172.155]:43031) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1skZdX-0003xc-Qq for 72765@debbugs.gnu.org; Sat, 31 Aug 2024 21:44:16 -0400 Original-Received: from phl-compute-04.internal (phl-compute-04.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 92ED51140108; Sat, 31 Aug 2024 21:43:10 -0400 (EDT) Original-Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sat, 31 Aug 2024 21:43:10 -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:subject:subject:to:to; s=fm3; t=1725154990; x=1725241390; bh=5on1qkZi/7bIdZ4Xs8mzp+zmyt1f58Ih2UIEH5kt0PE=; b= aK1W4zMEBmeRTlEh6rBwQesvVuy8eBn54OnuEWuuZsNa3POpKZgB0Xzoz9hra+I4 nRc/Z8WahllKAfhmK6K6KNSlGFlfAClK1l79f2xkRI3uSiGa0SS79w8wQbJZu2Eq +bZmMdfYsbvRWqsEXyWbIDh5uaCyR9YAG6+VzVGbQ10xR0fqWkbDizfhwye+qZ6z yYVi9rSnGvttGgQJpPABitWsXjTgcCVZnR/Atpk4jV8B+H0rg5iaY9f1f39uVE9v zeyaZXarVq3NSLEuC7fO5dVfJpYj3Cq/IO/Z7pzvtbXxCLuBZthlHohI8ZRmYq1F r8NDZ6+70cY5qQeJRf/K+Q== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725154990; x= 1725241390; bh=5on1qkZi/7bIdZ4Xs8mzp+zmyt1f58Ih2UIEH5kt0PE=; b=b /ey/NpV3/HgOi57rTMG1QL5ovlB78fdPBQW4ZhtPpM9fiuWcRwNP1gOr7yUl0uUj hKoNOE55ENsxAD46Y65TnHfnaiEyAfNVX8G//R0VROFstt0OL/LmP/yz2opDl5r9 75OnosG1Urq8pDdYPc7nvK+zz7HMlj8GzkDeUnpnNaf4kskRE05/OWNp3rr7pf4f 1q8I55axCkCW/6KsE838iW3D9mh7W0669+0jJJbA24RB9ntte5CmqK7hVAsTsEFD p0A9EQUSGWD9rEBQM7GW1YZLE6nFWMPbkHNVe+TyU6RrcThf54xsE42EBp6tWOeD uAmvzUyBHM0Lxhi5y2K0Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudegtddgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdej necuhfhrohhmpeffmhhithhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdrug gvvheqnecuggftrfgrthhtvghrnhepgeelfeetkefghfdvhfdtgeevveevteetgeetveeg tedthefhudekteehffeukeeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthho peefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehjohgrohhtrghvohhrrgesgh hmrghilhdrtghomhdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrghdprhgtphhtthho peejvdejieehseguvggssghughhsrdhgnhhurdhorhhg X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 31 Aug 2024 21:43:08 -0400 (EDT) Content-Language: en-US In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291038 Archived-At: On 31/08/2024 15:03, João Távora wrote: > Eglot aims primarily at that, since it's what's in Emacs proper. But > Eglot also aims at supporting Company in particular as fully > as possible. > > Anyway, I don't have time to investigate this. The :exit-function in > eglot.el should be stepped through to understand exactly who's at > fault. And I don't think differences between servers matter: > clangd is likely following the spec correctly here. It seems the difference comes from bug#70968 as well (which came up recently). When the completion style emacs22 is used, Company doesn't delete the suffix text before inserting completion. Which is an improvement for some other completion sources, but not Eglot, so far. To to fix this here, we can avoid a fail-over to emacs22 by only matching the prefix in eglot--dumb-allc like this: diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 59d9c346424..20c15584d2d 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3138,7 +3138,9 @@ eglot--dumb-flex nil comp) finally (cl-return comp))) -(defun eglot--dumb-allc (pat table pred _point) (funcall table pat pred t)) +(defun eglot--dumb-allc (pat table pred point) + (funcall table (substring pat 0 point) pred t)) + (defun eglot--dumb-tryc (pat table pred point) (let ((probe (funcall table pat pred nil))) (cond ((eq probe t) t) That fixes the scenario in Company, with seemingly no change with completion-at-point. Or if we want 100% compatibility, we can use 'or': (or (funcall table pat pred t) (funcall table (substring pat 0 point) pred t)) But in any case this doesn't help with the completion-at-point behavior described at the end of the report (where foo_|bar_2 turns into foo_bar_2bar_2|). If we consider it okay - then the above patch fixes the discrepancy with Company completion, and done. But if we think it a problem, then the fix might be required somewhere in the area of (cond (textEdit ;; Revert buffer back to state when the edit ;; was obtained from server. If a `proxy' After (and if) that is done, we might not need to change the completion style in the end.