unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74408: 30.0.92; FR: Add a function completion-list-candidate-at-point
@ 2024-11-17 21:10 Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-11-17 21:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-17 21:10 UTC (permalink / raw)
  To: 74408; +Cc: Stefan Monnier

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





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-29 17:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-17 21:10 bug#74408: 30.0.92; FR: Add a function completion-list-candidate-at-point Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-17 21:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-18  0:06   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-18 23:25     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-18 23:36       ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-19  2:59         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-19 10:03           ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-29 17:27             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).