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

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 29 Nov 2024 17:28:02 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74408: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74408
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74408: 30.0.92; FR: Add a function completion-list-candidate-at-point
From: Stefan Monnier <[email-masked]>
To: Daniel Mendler <[email-masked]>
Cc: [email-masked]
Date: Fri, 29 Nov 2024 12:27:06 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

> Thanks. I've attached the latest version of the patch, where the
> function is simplified without save-excursion.

Merged, closing, thank you,

        Stefan

Subject: 30.0.92; FR: Add a function completion-list-candidate-at-point
From: Daniel Mendler <[email-masked]>
To: [email-masked]
Date: Sun, 17 Nov 2024 22:10:08 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Emacs 31 comes with the internal function
`completions--start-of-candidate-at' in simple.el, which returns the
position of the completion candidate at point in the completions buffer.
I propose to replace this function with a slightly improved version,
which returns the candidate string in addition to the candidate bounds.
It could be made part of the public API:

(defun completion-list-candidate-at-point ()
  "Return completion candidate string at point with bounds in completions buffer."
  (let (beg end)
    (when (cond
           ((and (not (eobp)) (get-text-property (point) 'completion--string))
            (setq end (point) beg (1+ (point))))
           ((and (not (bobp)) (get-text-property (1- (point)) 'completion--string))
            (setq end (1- (point)) beg (point))))
      (list (get-text-property
             (previous-single-property-change beg 'completion--string)
             'completion--string)
            beg end))))

For a few years, the GNU ELPA packages like Embark and Consult had
versions of this function. These packages need to obtain the completion
candidate at point when acting on the candidate. If
`completion-list-candidate-at-point' is made available in Emacs, I can
port it back via the GNU ELPA Compat package, such that external
packages can take advantage of the new function, and don't have to rely
on internals like the `completion--string' property.

If there is interest, I can provide a patch for simple.el which replaces
`completions--start-of-candidate-at'. Thank you for your consideration.

Daniel