bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39600: [PATCH] Fix handling of non-exclusive non-prefix completion f


From: Lars Ingebrigtsen
Subject: bug#39600: [PATCH] Fix handling of non-exclusive non-prefix completion functions
Date: Sat, 08 Aug 2020 16:04:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Amai Kinono <amaikinono@gmail.com> writes:

> Currently, with non-exclusive completion functions, Emacs will do
> `try-completion` on the current text, and decide whether to try next
> completion function based on that. This makes completion functions that
> can do non-prefix completions fails when the current text only occurs in
> the middle of the candidates. This is a problem I found in a FIXME in
> the code.
>
> # How does this work?
>
> I use `completion-all-completions` instead. As far as I know, this
> respects the `completion-styles`.

[...]

Stefan, how does this patch look to you?

> -               ;; FIXME: Here we'd need to decide whether there are
> -               ;; valid completions against the current text.  But this 
> depends
> -               ;; on the actual completion UI (e.g. with the default 
> completion
> -               ;; it depends on completion-style) ;-(
> -               ;; We approximate this result by checking whether prefix
> -               ;; completion might work, which means that non-prefix 
> completion
> -               ;; will not work (or not right) for completion functions that
> -               ;; are non-exclusive.
> -               (null (try-completion (buffer-substring-no-properties
> -                                      (car res) (point))
> -                                     (nth 2 res)
> -                                     (plist-get (nthcdr 3 res) :predicate)))
> +               (null (completion-all-completions
> +                      (buffer-substring-no-properties (car res) (point))
> +                      (nth 2 res)
> +                      (plist-get (nthcdr 3 res) :predicate)
> +                      (- (point) (car res))))


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]