bug-bash
[Top][All Lists]
Advanced

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

Re: Tab completion and ':'s


From: Chet Ramey
Subject: Re: Tab completion and ':'s
Date: Fri, 14 Nov 2014 14:47:02 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

On 11/14/14, 10:49 AM, Vadim Berezniker wrote:
> Thanks for the reply Chet,
> 
> The completer is being setup in Bash, not directly through readline (sorry
> if I wasn't detailed enough in my original post).
> Even though readline might break the completion on the ':', we can use
> COMP_LINE/COMP_POINT to figure out the URL that needs to be completed
> (ignoring the ':').

OK, I see.  You can also use the arguments passed to the completion
function or the COMP_WORDS array to see readline's idea of the previous
word and use that as the prefix.

> The problem of course is inserting the results. No matter what we return
> from the completer, readline is going to insert it after the ':' which
> means we have to strip off everything up to ':' in the completion results.

Yes.  Something like "${results[@]/${prefix}/}" can be useful there,
assuming you put the possible completions into a `results' array and
build $prefix as described above.

> If the completer had a way to tell readline (through Bash) where the
> completion should be inserted that would allow a workaround for this issue
> without requiring any actions from the user. 

It's not only that, but the text that would have to be removed from the
buffer (the `previous' word) before inserting any possible completions,
and making sure that text isn't removed from the line inappropriately.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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