GNU bug report logs - #74408
30.0.92; FR: Add a function completion-list-candidate-at-point

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Sun, 17 Nov 2024 21:11:02 UTC

Severity: wishlist

Found in version 30.0.92

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Daniel Mendler <mail <at> daniel-mendler.de>
Subject: bug#74408: closed (Re: bug#74408: 30.0.92; FR: Add a function
 completion-list-candidate-at-point)
Date: Fri, 29 Nov 2024 17:28:02 +0000
[Message part 1 (text/plain, inline)]
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 74408 <at> debbugs.gnu.org.

-- 
74408: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74408
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Mendler <mail <at> daniel-mendler.de>
Cc: 74408-done <at> debbugs.gnu.org
Subject: Re: bug#74408: 30.0.92; FR: Add a function
 completion-list-candidate-at-point
Date: Fri, 29 Nov 2024 12:27:06 -0500
> Thanks. I've attached the latest version of the patch, where the
> function is simplified without save-excursion.

Merged, closing, thank you,


        Stefan


[Message part 3 (message/rfc822, inline)]
From: Daniel Mendler <mail <at> daniel-mendler.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.92; FR: Add a function completion-list-candidate-at-point
Date: Sun, 17 Nov 2024 22:10:08 +0100
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



This bug report was last modified 172 days ago.

Previous Next


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