Subject: Re: bug#74408: 30.0.92; FR: Add a function completion-list-candidate-at-point

From: Stefan Monnier <[email-masked]>
Date: Mon, 18 Nov 2024 18:25:31 -0500

> Thanks. Patch attached.

Thanks, Daniel.  Minor comments below.

> @@ -2628,8 +2628,10 @@ minibuffer-completion-help
>                (when-let* ((buffer (get-buffer "*Completions*"))
>                            (window (get-buffer-window buffer 0)))
>                  (with-current-buffer buffer
> -                  (when-let* ((beg (completions--start-of-candidate-at (window-point window))))
> -                    (cons (get-text-property beg 'completion--string) (- (point) beg))))))
> +                  (when-let* ((cand (save-excursion
> +                                     (goto-char (window-point window))
> +                                     (completion-list-candidate-at-point))))
> +                    (cons (car cand) (- (point) (cadr cand)))))))
>               ;; If the *Completions* buffer is shown in a new
>               ;; window, mark it as softly-dedicated, so bury-buffer in
>               ;; minibuffer-hide-completions will know whether to

AFAICT, it's easy to make `completion-list-candidate-at-point` accept an
optional position argument (which would default to point), which would
be helpful in the two places where we use that function.
WDYT?

> +(defun completion-list-candidate-at-point ()
> +  "Return candidate string at point and bounds in completions buffer."

I suggest you use something like "(STRING BEG END)" to describe the format.

        Stefan