From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Newsgroups: gmane.emacs.bugs Subject: bug#67514: 30.0.50; completion preview symbol length calculation should use point Date: Wed, 29 Nov 2023 10:06:07 +0100 Message-ID: <87ttp4evde.fsf@gmail.com> References: <87y1ehfw8a.fsf@gmail.com> <87edg9bg4s.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33051"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67514@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Herman To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 29 10:57:15 2023 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 1r8HJi-0008Jl-Ox for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Nov 2023 10:57:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8HJQ-0004jG-DJ; Wed, 29 Nov 2023 04:56:56 -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 1r8HJP-0004is-07 for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 04:56:55 -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 1r8HJO-0001FL-Nz for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 04:56:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r8HJW-0001E5-3T for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 04:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Nov 2023 09:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67514 X-GNU-PR-Package: emacs Original-Received: via spool by 67514-submit@debbugs.gnu.org id=B67514.17012517754643 (code B ref 67514); Wed, 29 Nov 2023 09:57:02 +0000 Original-Received: (at 67514) by debbugs.gnu.org; 29 Nov 2023 09:56:15 +0000 Original-Received: from localhost ([127.0.0.1]:48920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8HIl-0001Co-5V for submit@debbugs.gnu.org; Wed, 29 Nov 2023 04:56:15 -0500 Original-Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:49238) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8HIi-0001Ca-Rf for 67514@debbugs.gnu.org; Wed, 29 Nov 2023 04:56:13 -0500 Original-Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40b427507b7so26631415e9.2 for <67514@debbugs.gnu.org>; Wed, 29 Nov 2023 01:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701251759; x=1701856559; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:references:from:to:cc:subject:date:message-id :reply-to; bh=eYSMCp8wKSpjuZDHEy4l9oTj6gSGU2GfC+P/6CK1Or4=; b=JvleZJn7IcF1vCEUuPbCCa3yKWx1KFbcu+UUnDSfzDoxcMuabG6e6DP8rQ5v26iwxF EobmBgpN7S75P04L2Dm+vct3GB++n6ft45KUTIIss/aunoBKJe1aPrgf0lsmkuuFhbgl yrlGiH4C/0db3ZQYzNeo+3Bl+F9EEdb7qONcUnrcmyoLALQoPCVVXtk4/Jr3A8aV5pjF r3pgmNXaq70bxWi4BXxm7Tm0B9M/zmCXoGJlO151nHY3+01kdhWLLdCbA7WSlVaBAIfQ vUq1nhKubGNNroz/tX8bNUY8fROeX5ZhYC3Qo+jcbh6XRAttzsI025bXkdsY+fj/tQgK nS9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701251759; x=1701856559; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:references:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=eYSMCp8wKSpjuZDHEy4l9oTj6gSGU2GfC+P/6CK1Or4=; b=RBE5Uyn84DLmXj8Xm7n2DFtKmU5rHwTWa1QFEvIpuNyOYh7bM8vNn5gtfTPs/XrZpt U+VmQZJENeMMW4q4UpWrqQ5ON411tOHfQhrha9TBFSKcBBjBkOlKfOLcWmHVwxcZwsGl bRC8sc3goxEklWai1O1sA4NGOIwddjlKl0W9LMnGzf3lOWheQpiayQ6Qa7E5MTg2VmYq ahTYMyEZN1ERTr4CA6KsY1ZVGKsNAljdBe1E9X5C1z0bo8sACm2k9LirS+Sl/jYd2QRF maztbLJuwI5NrcGjvJSMYvu24h1CQJuB3kdUO7FrQxUhtDtWOoiNxDw7aojPKBR9f2Tm QLtA== X-Gm-Message-State: AOJu0Yy4pegpT3FAil+fiU4CuEIQt84KJ4iecvxM5IL2erZ3CvCQ0jCa KFa0pYowCWphQnsdtSbSoiY= X-Google-Smtp-Source: AGHT+IFYKG/7We3aVNl4INjZ2su68QYi9hhHo2WsJ208bdINdk4Tqz5Z+fYYMKvHeniIRqGP841w9w== X-Received: by 2002:adf:e28a:0:b0:333:950:a1d2 with SMTP id v10-20020adfe28a000000b003330950a1d2mr3407876wri.42.1701251759131; Wed, 29 Nov 2023 01:55:59 -0800 (PST) Original-Received: from localhost (netacc-gpn-4-30-169.pool.yettel.hu. [84.224.30.169]) by smtp.gmail.com with ESMTPSA id d14-20020adff84e000000b00332f6202b73sm11660971wrq.47.2023.11.29.01.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:55:58 -0800 (PST) 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:275207 Archived-At: Eshel Yaron writes: > G=C3=A9za Herman writes: > >> Eshel Yaron writes: >> >>> ...`completion-at-point-functions` take into account text that >>> follows point as well as the text that precedes point, and=20 >>> Completion >>> Preview mode works also when you're typing in the middle of a=20 >>> symbol. >>> For example, consider the following text in an Elisp buffer... >> >> I didn't know about this behavior, it makes sense how it works=20 >> in >> emacs-lisp-mode. I tried this feature with lsp-mode (using the >> clangd language server), and it doesn't play this nicely. >> >> Suppose that you have this C code: >> >> int main() { >> int longVariableName =3D 0; >> >> VariableName =3D 1; >> } >> >> And the point is at the first character at VariableName. Now, >> pressing "l" will preview longVariableName, but it doesn't do >> anything with VariableName, so the buffer looks like >> l(ongVariableName)VariableName (parentheses are not part of the >> text, I used them to mark the greyed out part). > > I see that. I think this is a bug in `lsp-mode`, FWIW. You get=20 > the > same erroneous completion with `completion-at-point` in that=20 > case. > Eglot seems to do the right thing though. Yes, probably it's a bug. Thanks for checking eglot, this means=20 that the behavior comes from lsp-mode, not from clangd. >> My suggestion doesn't fix this, it just postpones this problem >> until I write "lon", and then the same thing will happen. > > Indeed. What follows is a tangent, I'm happy to continue the=20 > discussion > but we can already close this as "notabug", unless you think=20 > otherwise. Sure, feel free to close it. It was just a suggestion in the=20 first place, but in the light of the new information (modes=20 usually use the whole symbol for completion), the current behavior=20 is exactly what we wanted. >> The reason that I suggested this is that I use evil-mode, and I=20 >> put >> evil-insert to completion-preview-commands. > > Note that `completion-preview-commands` is a "list of commands=20 > that > should trigger completion preview", as the docstring says. You=20 > seem to > indicate below that you often want `evil-insert` not to trigger > completion preview, so why add it to this list in the first=20 > place? In general, I want evil-insert to trigger the preview. Suppose=20 that you started to type something, you got the preview, but then=20 you realize that you forgot something, so (without finishing the=20 word) you move to some other part of the code, and do some=20 modification there. Then you move back to your original position,=20 and go to insert mode to continue typeing. It makes sense that=20 preview is triggered right at the moment when insert mode is=20 activated. (Note: I added other evil commands to completion-preview-commands=20 as well. For example, when I type "cw" in a middle of word, I want=20 to trigger preview, just like if the end of a word deleted by=20 usual emacs commands. I know that kill-word is not on the list=20 currently, but maybe it should be?) > AFAICT `lsp-mode` is giving you inappropriate completion=20 > suggestions, > and I don't think that it's up to Completion Preview mode to fix=20 > that. > Is this problem common among other completion backends? If so=20 > we may > consider adding some measure to circumvent it. But it'd be=20 > better to > improve these backends instead, IMO. I tried scad-mode (this also uses capf), and it works correctly,=20 similarly how emacs-lisp-mode works. So it indeed seems that=20 lsp-mode causes the problem. Thanks for your time!