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: Spencer Baugh
Subject: Re: Access to readline completions without line editing
Date: Tue, 03 Oct 2023 19:50:44 +0000 (UTC)

Chet Ramey <chet.ramey@case.edu> writes:
> On 9/26/23 9:54 PM, sbaugh@catern.com wrote:
>> 
>> Hi,
>> 
>> GNU Emacs wraps many readline-using programs, but disables readline in
>> favor of its own line-editing commands.  However, it would be great for
>> Emacs to still be able to access readline completions on demand; then
>> Emacs would display those completions to the user in Emacs-y ways.
>
> What do you mean by `readline completions'? Readline has builtin support
> for only a few things: filename and directory name completion, username
> completion for tilde expansion, and very little else.
>
> Readline primarily offers support for determining the word to be completed,
> calling an application-specific completion function if one is set, and
> inserting or displaying the results. All of this requires that readline
> be used to perform line editing and is part of the readline API.
>
>> Right now there's no support in Emacs for accessing these completions,
>> so completion in such programs is usually reimplemented inside Emacs in
>> ad-hoc ways, or isn't supported at all.
>
> Again, it's not clear what you mean by `these completions'. Do you mean
> something like bash-completion? If you do, then any access to application-
> specific completion functions has to be provided by the application.

I'm referring to both readline's builtin completions and also
application specific completions.

>> How should we access these completions if we want to disable
>> line-editing? 
>
> If you want to disable readline, then readline won't have any access to
> the line editing data, and can't really do anything.

Yes, I said this badly.  readline would be enabled, since we'd be using
completions from it.  But Emacs would handle displaying the available
completions - somehow they would be communicated from readline to Emacs.

>> What do you recommend?  Is there an existing mechanism
>> which would be suitable for this? 
>
> There are application-specific mechanisms like bash's `compgen' builtin.

Unfortunately almost all applications which use readline to do
completion, tightly couple their completion mechanisms to readline, and
don't provide a way to get completions other than through readline.

Random example readline tutorial from the web:
https://thoughtbot.com/blog/tab-completion-in-gnu-readline

Nowhere does this tutorial talk about providing these completions in a
non-readline way.  And indeed, the developers behind this tutorial have
not implemented a non-readline way to get completions for their own
application (gitsh).

That's why it would be nice to have an API to ask readline to trigger
completion, including application-specific completions.  Since those
completions are often not available any other way.

It seems reasonable for developers to decide that they don't want to go
to the trouble of specifying and implementing an alternative API for
accessing completions - they might not care about good support for
Emacs.  But in Emacs, for the sake of our users, we'd like to have
good-enough support for these applications without requiring extra work
from the developers of the application.  Which perhaps we can do by
going through readline.

>> Or could a new feature for this be
>> added to readline?
>
> How would that work? Readline's not in the picture here.

Right, as I said, we'd keep readline enabled, since most applications
don't have a way to provide completions other than through readline.
The new feature would be some way to get readline to trigger completion
and then return the completions in a structured form, so that Emacs (or
other terminals) can display them.



reply via email to

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