bug-readline
[Top][All Lists]
Advanced

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

Re: Access to readline completions without line editing


From: matthewktromp
Subject: Re: Access to readline completions without line editing
Date: Sun, 24 Nov 2024 18:55:27 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Chet Ramey <chet.ramey@case.edu> writes:
> Here's the format I decided on. My intent is that it's general enough for
> applications besides emacs:
>
> /* This implements a protocol to export completions to another process or
>    calling application via rl_outstream.
>
>    MATCHES are the possible completions for TEXT, which is the text between
>    START and END in rl_line_buffer.
>
>    We print:
>         N - the number of matches
>         T - the word being completed
>         S:E - the start and end offsets of T in rl_line_buffer
>         then each match, one per line
>
>   If there are no matches, MATCHES is NULL, N will be 0, and there will be
>   no output after S:E.
>
>   Since MATCHES[0] can be empty if there is no common prefix of the elements
>   of MATCHES, applications should be prepared to deal with an empty line
>   preceding the matches.
> */
>
> The bindable function (rl_export_completions) takes the same two arguments
> as any other readline function (count, key), and will clear the readline
> line buffer if count > 1.
>
> This was inspired by a message sent to me privately; the sender described
> the intended use case as:

This was me!  Glad to see this landing.  Thanks!

> "Emacs activates this capability by making and passing in a custom
> inputrc that binds `send-completions`, then uses it by sending the text
> of the line being completed over, navigation commands to move point to
> the right location in the line, and the key bound to `send-completions`.
> Emacs then parses the output to get the boundaries of the word being
> completed over and the list of completions, which it can use to render
> the completions and allow choosing between them in an Emacs-native way."
>
> The documentation I write for this bindable command (I haven't finished
> it) will be in the next push to the bash devel branch, and, sometime
> after that, the next push to the readline devel branch.

I'll publish my emacs support for this once this has landed with a
stable format.




reply via email to

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