From: Spencer Baugh <sbaugh@janestreet.com>
To: Juri Linkov <juri@linkov.net>
Cc: 62700@debbugs.gnu.org, Spencer Baugh <sbaugh@catern.com>
Subject: bug#62700: 29.0.60; minibuffer-{previous,next,choose}-completion behave unintuitively when point is not at end of buffer
Date: Thu, 20 Apr 2023 14:46:45 -0400 [thread overview]
Message-ID: <iera5z2z90q.fsf@janestreet.com> (raw)
In-Reply-To: <868rema032.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 20 Apr 2023 21:18:57 +0300")
Juri Linkov <juri@linkov.net> writes:
>>>>> It just needs more testing for different categories of completion.
>>>>
>>>> Which categories do you have in mind?
>>>
>>> Actually, I can't find categories where it could fail.
>>> So your patch looks safe to push.
>>
>> Can we go ahead and push it to Emacs master, then? I will work on the
>> changing-only-new-code backport for Emacs 29 as Eli requested.
>
> But your patch changes only new code.
Ah, I thought Eli still wanted a backport version because this changes
code which has been on Emacs 29 for over a year.
I'm happy either way. (well, of course I prefer to not make a backport
version, but happy to do it if Eli wants one)
>>>>> Maybe you could find another heuristic for insertion of completion?
>>>>> The code is located in the same function 'minibuffer-completion-help':
>>>>>
>>>>> (if (and (stringp start) (stringp end))
>>>>> (progn
>>>>> (delete-minibuffer-contents)
>>>>> (insert start choice)
>>>>> ;; Keep point after completion before suffix
>>>>> (save-excursion (insert end)))
>>>>>
>>>>> Currently it keeps point before the suffix.
>>>>
>>>> I will try. Although this is a case where completion-base-position feels
>>>> more suited than completion-base-affixes...
>>>
>>> Can you get the same info about positions by calculating the
>>> lengths of prefix/choice/suffix?
>>
>> Hm I have thought about it but I can't see a simple heuristic.
>>
>> It's not actually clear what behavior we want, anyway. When TAB
>> completes a string fully, it sends point to the end of the buffer. This
>> happens even if completion-cycle-threshold is non-nil, and
>> completion-cycle-threashold feels like a pretty similar feature to
>> minibuffer-{previous,next}-completion. So maybe that's correct for us to
>> do here too?
>>
>> But a different behavior feels like it could also makes sense. For
>> example, if I'm completing from ffap-|-path (| is point), I'm just
>> cycling between ffap-bib-path, ffap-c++-path, ffap-c-path, and it feels
>> like as I cycle through those, point should stay right before "-path",
>> like ffap-bib|-path, ffap-c++|-path, ffap-c|-path. No idea how to
>> achieve this behavior though.
>
> This also makes sense: ffap-|bib-path, ffap-|c++-path, ffap-|c-path.
Agreed.
> I tried it with this tentative patch and it feels quite natural,
> so maybe could be turned into an option:
>
> diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
> index a6af65dfa14..733f7710378 100644
> --- a/lisp/minibuffer.el
> +++ b/lisp/minibuffer.el
> @@ -2366,6 +2371,7 @@ minibuffer-completion-help
> (let* ((start (or start (minibuffer--completion-prompt-end)))
> (end (or end (point-max)))
> (string (buffer-substring start end))
> + (pos (1- (point)))
> (md (completion--field-metadata start))
> (completions (completion-all-completions
> string
> @@ -2493,7 +2503,8 @@ minibuffer-completion-help
> (delete-minibuffer-contents)
> (insert start choice)
> ;; Keep point after completion before suffix
> - (save-excursion (insert end)))
> + (save-excursion (insert end))
> + (move-to-column pos))
> (unless (or (zerop (length prefix))
> (equal prefix
> (buffer-substring-no-properties
Interesting idea. Although it breaks down with ?, I notice:
1. C-h v ff-|-p
2. ? to pop up completions
3. M-<down> to select diff-font-lock-prettify
4. Get dif|f-font-lock-prettify which seems fairly wrong
>> Anyway, the behavior with my earlier patch now feels fine to me, I don't
>> think we need any improvements to point's behavior for now.
>
> Maybe your patch still could be pushed to emacs-29 because it fixes
> the new feature.
Agreed.
next prev parent reply other threads:[~2023-04-20 18:46 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <b921ea5c-71a2-4e8f-b1cf-dd26831f8104@email.android.com>
2023-04-10 18:20 ` bug#62700: 29.0.60; minibuffer-{previous,next,choose}-completion behave unintuitively when point is not at end of buffer Juri Linkov
2023-04-20 16:52 ` Spencer Baugh
2023-04-20 18:18 ` Juri Linkov
2023-04-20 18:46 ` Spencer Baugh [this message]
2023-04-20 19:00 ` Eli Zaretskii
2023-04-21 18:56 ` sbaugh
2023-04-22 10:48 ` Eli Zaretskii
2023-04-22 12:57 ` sbaugh
2023-04-22 13:15 ` Eli Zaretskii
2023-04-22 21:38 ` sbaugh
2023-04-23 6:13 ` Eli Zaretskii
2023-04-23 11:48 ` sbaugh
2023-04-24 11:22 ` Eli Zaretskii
2023-05-02 15:13 ` sbaugh
2023-05-02 17:57 ` Eli Zaretskii
2023-05-08 15:48 ` Juri Linkov
2023-05-08 16:11 ` Eli Zaretskii
2023-06-03 0:58 ` Spencer Baugh
2023-06-04 7:09 ` Eli Zaretskii
2023-06-10 10:51 ` Eli Zaretskii
2023-06-12 18:27 ` Juri Linkov
2023-06-13 2:32 ` Eli Zaretskii
2023-06-13 16:54 ` Juri Linkov
2023-06-13 16:59 ` Eli Zaretskii
2023-06-13 20:59 ` Spencer Baugh
2023-06-14 17:32 ` Juri Linkov
2023-09-03 17:37 ` Juri Linkov
2023-09-04 0:30 ` sbaugh
2023-09-04 6:51 ` Juri Linkov
2023-11-14 7:39 ` Juri Linkov
2023-11-15 17:42 ` Juri Linkov
2023-04-20 18:51 ` Eli Zaretskii
2023-04-06 17:56 Spencer Baugh
2023-04-06 18:22 ` Eli Zaretskii
2023-04-06 18:58 ` Spencer Baugh
2023-04-06 19:30 ` Eli Zaretskii
2023-04-06 20:42 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-06 18:55 ` Juri Linkov
2023-04-06 19:22 ` Spencer Baugh
2023-04-07 16:37 ` Juri Linkov
2023-04-07 21:02 ` sbaugh
2023-04-08 6:34 ` Eli Zaretskii
2023-04-08 10:58 ` sbaugh
2023-04-08 13:19 ` Eli Zaretskii
2023-04-08 18:36 ` Juri Linkov
2023-04-08 19:32 ` Eli Zaretskii
2023-04-09 16:40 ` Juri Linkov
2023-04-09 17:38 ` Eli Zaretskii
2023-04-08 18:30 ` Juri Linkov
[not found] ` <ierbk6lup79.fsf@janestreet.com>
2024-04-07 17:16 ` Juri Linkov
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=iera5z2z90q.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=62700@debbugs.gnu.org \
--cc=juri@linkov.net \
--cc=sbaugh@catern.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).