all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Herman@debbugs.gnu.org, Géza <geza.herman@gmail.com>
To: Eshel Yaron <me@eshelyaron.com>
Cc: 67514@debbugs.gnu.org, "Géza Herman" <geza.herman@gmail.com>
Subject: bug#67514: 30.0.50; completion preview symbol length calculation should use point
Date: Wed, 29 Nov 2023 00:17:42 +0100	[thread overview]
Message-ID: <87edg9bg4s.fsf@gmail.com> (raw)
In-Reply-To: <m1jzq17dqf.fsf@dazzs-mbp.home>


Eshel Yaron <me@eshelyaron.com> writes:

> Géza Herman <geza.herman@gmail.com> writes:
>
>> There is a thing which maybe can be improved (so this is not a 
>> bug
>> report, just a suggestion): it's how
>> completion-preview-require-minimum-symbol-length calculates the
>> length.  Currently it just returns the length of the symbol 
>> under the
>> cursor.  I think it would be better to use the length of the 
>> part that
>> actually will be used for completion, because if the point is 
>> inside a
>> word, then it should only consider the part between the symbol 
>> start
>> end the point.
>
> Could you please explain why you consider that preferable?  The 
> current
> behavior is intentional and, unless I'm missing something, 
> correct.
> `completion-at-point-functions` take into account text that 
> follows
> point as well as the text that precedes point, and Completion 
> Preview
> mode works also when you're typing in the middle of a symbol. 
> For
> example, consider the following text in an Elisp buffer:
>
> --8<---------------cut 
> here---------------start------------->8---
> (minor
> --8<---------------cut 
> here---------------end--------------->8---
>
> With point between the opening parenthesis and the letter "m", 
> type
> "define-".  The completion preview displays "-mode" just after 
> "minor",
> suggesting that you complete to "define-minor-mode".  That's 
> because the
> text after point ("minor", in this case) plays a role too.

I didn't know about this behavior, it makes sense how it works 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:

--8<---------------cut here---------------start------------->8---
int main() {
    int longVariableName = 0;

    VariableName = 1;
}
--8<---------------cut here---------------end--------------->8---

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).

My suggestion doesn't fix this, it just postpones this problem 
until I write "lon", and then the same thing will happen. The 
reason that I suggested this is that I use evil-mode, and I put 
evil-insert to completion-preview-commands.  So whenever I enter 
insert mode, preview could happen.  And a lot of cases, I enter 
insert mode while the point is at the beginning of some word.  So 
with my suggestion, preview won't be happening, if the point is at 
the beginning of the word.  But currently when I enter insert 
mode, a random preview will be presented, because completion uses 
an empty string.  Perhaps this is what makes the difference? While 
emacs-lisp-mode uses the whole word for completion (so my 
suggestion doesn't make sense in this case), but lsp-mode/clangd 
uses just part of the word until the point (my suggestion makes 
some sense in this case)?





  reply	other threads:[~2023-11-28 23:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28 20:39 bug#67514: 30.0.50; completion preview symbol length calculation should use point Herman, Géza
2023-11-28 21:46 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-28 23:17   ` Herman, Géza [this message]
2023-11-29  8:55     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-29  9:06       ` Herman, Géza
2023-11-29 21:26         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87edg9bg4s.fsf@gmail.com \
    --to=herman@debbugs.gnu.org \
    --cc=67514@debbugs.gnu.org \
    --cc=geza.herman@gmail.com \
    --cc=me@eshelyaron.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.