GNU bug report logs - #62700
29.0.60; minibuffer-{previous,next,choose}-completion behave unintuitively when point is not at end of buffer

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Thu, 6 Apr 2023 17:57:01 UTC

Severity: normal

Found in version 29.0.60

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #41 received at 62700 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: sbaugh <at> catern.com
Cc: 62700 <at> debbugs.gnu.org, Spencer Baugh <sbaugh <at> janestreet.com>
Subject: Re: bug#62700: 29.0.60;
 minibuffer-{previous,next,choose}-completion behave unintuitively when
 point is not at end of buffer
Date: Sat, 08 Apr 2023 21:30:39 +0300
> Here's one heuristic which works decently well:
>
> The reasoning here is that if completion returns the full string which
> should be in the minibuffer, then we should replace the minibuffer with
> that string, so base-suffix should be "".  But if we're completing only
> part of the string, base-suffix should be something else.  AFAIK only
> file completion falls into the latter category, and it always completes
> just one component of a path, so I set base-suffix to not include the
> component of the path that point is in, so that completion replaces it
> entirely.
>
> I think this is basically a satisfactory heuristic, although I'm sure
> I'm missing some categories of completion besides file completion which
> complete only part of the string.

Thanks, this looks like a satisfactory heuristic indeed.  It just needs
more testing for different categories of completion.

> Regardless of whether this is a satisfactory heuristic, it's revealed to
> me an unexpected behavior of a solution to this bug using base-suffix,
> which may or may not be fine: Point is moved to the end of the
> completion inserted.
>
> So e.g. if point is at | and I'm completing |-path, then when I choose
> the completion load-path, point will be at load-path| rather than
> load|-path.  This isn't a huge issue but it might be a little annoying?
> I don't know if there's any way to fix this.

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.




This bug report was last modified 1 year and 39 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.