From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#68699: Eglot completion has stopped working in some cases Date: Thu, 25 Jan 2024 01:35:08 +0000 Message-ID: References: <87mssutqm8.fsf@prescott.mail-host-address-is-not-set> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="767"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68699@debbugs.gnu.org To: Brennan Vincent , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 25 02:36:28 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 1rSofL-000AVn-LU for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Jan 2024 02:36:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSoes-00019g-5d; Wed, 24 Jan 2024 20:35:58 -0500 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 1rSoeq-00019T-NM for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 20:35:56 -0500 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 1rSoeq-0003oF-Ee for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 20:35:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rSoev-0005S4-V0 for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 20:36:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jan 2024 01:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68699 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170614653520918 (code B ref -1); Thu, 25 Jan 2024 01:36:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Jan 2024 01:35:35 +0000 Original-Received: from localhost ([127.0.0.1]:46929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSoeV-0005RJ-EX for submit@debbugs.gnu.org; Wed, 24 Jan 2024 20:35:35 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:33956) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSoeT-0005R6-ET for submit@debbugs.gnu.org; Wed, 24 Jan 2024 20:35:34 -0500 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 1rSoeH-00016m-91 for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 20:35:21 -0500 Original-Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rSoeE-0003kJ-W8 for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 20:35:20 -0500 Original-Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5100ed2b33dso2306422e87.0 for ; Wed, 24 Jan 2024 17:35:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706146516; x=1706751316; darn=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=48jT720GU+/8XZEmAROTghency4ZFs7Q9zU+RumsyI8=; b=DtF0pckNAYbLEaEnvw0Kq47vAcggdIOw4NwlSXDLKD1ukFGply8JntRrqY6EGhISid 0qusNM7I7Dq72+tG4b8/Q8fD87haEEEWqoSK/ShLi9lo4UmbTvBeM8Rgx3dXVLzvU4NN EMXro/XchBws89vliVqQxh+tur+xeBfqhsAsRyITZBZyMMW+IdrudiX0YKEaTRfZfV07 /TzzO1yYEQzPy1BOkV9iii7grPtUqCMVYMCuIwJi+jJQJjizQLwctaErh9UNdeoauTGw WQ37JE7HpkVLrS6UElddJG21bBnOYWgPUj6tS4Lan1ditvI6qw3CLmPumWkUdWv/NtM2 6N1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706146516; x=1706751316; 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=48jT720GU+/8XZEmAROTghency4ZFs7Q9zU+RumsyI8=; b=OFlNWKd8tVksaajzx9KNwJpE3ZEa2wUyVgGCwxLE2vx9EQ+Mc5H3TiD2jFjb3RjvtW ZWWMpqSDVcKUzrMPxiX73yaIb1SpJyhac6Selwtn/R3Zfmvs/B+7/SRAkceFWWSnMvGF TOVzkB160hdB3qHVC7UnYE/P+KtNPh+EunXKmsFbfQMh5OUNfpQImS9y6BBMoKNuIkYA DzXEj7jmcGDLE312l5ySbmsL1NBTzv935nHf5C86yNGBcyCKaqGtMJCIXlYhJPHybMgC fuYeLoEeghuYq5z6MNo82YnEjJXjaIWT9OP1KWUvbUyIgTsTFef9lnuTrWkiVShnottX ybCA== X-Gm-Message-State: AOJu0YxMZiz2cTBi/juCdYsj2oTnEZYhy9H0YUW2lNHichdRazqfkOaH pPUWgOeqF+C8xmmMB/QUTPJ/l+ijk4okJKIwekmYHK6WHkGD5qi9WlSl2zXBJXCIZUUCHDGzc3E veUQgvrlffT8guRnYPP32gVbF1fQ= X-Google-Smtp-Source: AGHT+IGbCKAfEBsWkb03VJeyFF/D5RR0M1JUzWRY2btcQkJY/j+0IC7FGdU/P8/nrDz7aZ5wHWDawsgY/MU8T9GiyIU= X-Received: by 2002:a05:6512:e96:b0:50e:712b:393f with SMTP id bi22-20020a0565120e9600b0050e712b393fmr74549lfb.80.1706146515470; Wed, 24 Jan 2024 17:35:15 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=joaotavora@gmail.com; helo=mail-lf1-x133.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:278826 Archived-At: On Thu, Jan 25, 2024 at 12:43=E2=80=AFAM Jo=C3=A3o T=C3=A1vora wrote: > > On Wed, Jan 24, 2024 at 8:37=E2=80=AFPM Brennan Vincent wrote: > > > For example, in a Rust crate with the following main file: > > > > fn foo_len() { > > } > > > > fn main() { > > len > > } > > I've reproduced this with latest master: > > ~/Source/Emacs/emacs/src/emacs -Q ~/MoreSource/Rust/hello/src/main.rs > -f rust-ts-mode -f eglot > > where main.rs is the provided snippet. > > Pressing C-M-i with point after 'len' yields the error. > > The error only happens in partial-completion is in the completion-styles > variable, so a workaround is to remove partial-completion from > completion-styles, at least in Eglot enabled buffers. > > I will look now for the underlying cause. Stefan, this is down to partial-completion somehow thinking that "\\'len" should match at least some LSP-provided completion candidate, otherwise it's an "internal error" I wish I could turn off all the styles from the table but I can only add to them. I simply cannot write a reasonable try-completion thing for LSP completions. LSP completions are really designed to be navigated using a company-like popup. Without it they should almost always use the *Completions* buffer, and rarely ever Emacs partial completion shenanigans. Nevertheless, I need to plug this bug somehow in Eglot. Brennan, can you try this patch I've just pushed? diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 511000927cf..c5fbf5eb9d5 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3060,9 +3060,13 @@ eglot--dumb-flex finally (cl-return comp))) (defun eglot--dumb-allc (pat table pred _point) (funcall table pat pred t)= ) +(defun eglot--dumb-tryc (pat table pred point) + (if-let ((probe (funcall table pat pred nil))) + (cons probe (length probe)) + (cons pat point))) (add-to-list 'completion-category-defaults '(eglot-capf (styles eglot--dumb-flex))) -(add-to-list 'completion-styles-alist '(eglot--dumb-flex ignore eglot--dumb-allc)) +(add-to-list 'completion-styles-alist '(eglot--dumb-flex eglot--dumb-tryc eglot--dumb-allc)) (defun eglot-completion-at-point () "Eglot's `completion-at-point' function." Jo=C3=A3o