[Bash-completion-devel] using external helpers for completion

Guillaume Rousse Guillaume.Rousse at inria.fr
Sun Nov 7 19:23:06 UTC 2010


Le 07/11/2010 10:03, Ville Skyttä a écrit :
> On Sunday 07 November 2010, Guillaume Rousse wrote:
>> Le 31/10/2010 23:59, Freddy Vulto a écrit :
>>> The remaining error reported by the test suite however, was that perldoc
>>> option-completion is now missing; it's not in the pure perl perldoc
>>> completion helper, whereas the code underneath was in the bash perldoc
>>> completion:
>>>
>>> -    if [[ "$cur" == -* ]]; then
>>> -        COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w
>>> -d \ -            -D -p -n -a -F -l -0 -I -m -M -P -S -x -i -e ' --
>>> "$cur" ) )
>>>
>>> Are you aware of that?  Anyway, I removed the test case from the test
>>> suite for now.
>>
>> Good catch, I didn't notice.
>>
>> I just fixed this,
> 
> Shouldn't the perldoc test case be re-enabled now then?
I attempted to do it, but the test suite is still quite mysterious for
me. I reverted commit 325b1c2, and added a test similar to the one for perl.

>> and also generalized the helper to be used for perl
>> command also. Now we have 100% pure perl completions for those commands,
>> allowing to get rid of ugly perl oneliners embedded in shell functions
>> for listing perl modules. However, we also have to reimplement compgen
>> -d, and filedirs, with no garanty of providing a consistent behaviour :/
>>
>> I wonder if the correct solution would be to keep a shell completion
>> functions, and only delegate the specialized parts (modules and function
>> completions) to external perl code.
> 
> Sounds like a plan to me (offhand).
> 
> BTW after this change we now have the perl testcase in a fairly bad shape.
> 
> $ ./runCompletion perl.exp                                                                                                                                                                       
> [...]
> # of expected passes            3
> # of unexpected failures        2
> # of unresolved testcases       3
I fixed it, by implementing the proposed scheme. Basically, I replaced
the helper modules completion code by our oneliner, while fixing some
issues with it.

The original code has a nice trick: instead of returning all perl
modules matching the current word, it just complete on current namespace
segment:
X -> XML:: XMLRPC:: XPath XSLoader
The result is quicker, and also easier to handle for the user. However,
it also relies on using -o nospace option to be able to continue
completion directly, rather than using backspace first.

Also, we face the painful 'every : character start a new completion'
issue again :(
-- 
BOFH excuse #381:

Robotic tape changer mistook operator's tie for a backup tape.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4251 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20101107/44d21213/attachment.bin>


More information about the Bash-completion-devel mailing list