Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14145

Re: [PATCH] Add nofirstword completion option

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: [PATCH] Add nofirstword completion option
Date 2018-05-25 14:40 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.491.1527273653.1292.bug-bash@gnu.org> (permalink)
References (2 earlier) <1527068652.6997.5.camel@debian.org> <76b1d3fa-4cb1-3e70-d93c-ada07c04dfa2@case.edu> <1527082457.6997.14.camel@debian.org> <4ccfc554-15a9-2ec1-55e1-b2df687f0bee@case.edu> <1527270167.6997.22.camel@debian.org>

Show all headers | View raw


On 5/25/18 1:42 PM, Luca Boccassi wrote:

>> There is already logic that determines whether the shell is trying to
>> complete a command word (in_command_position). The existing code does
>> not attempt programmable completion if in_command_position == 1. The
>> additional functionality would:
>>
>> 1. Add an option to the complete builtin to specify how to complete
>>    command names, and store it in a specially-named compspec, like
>>    completion for empty lines does.
>>
>> 2. Add code to invoke that completion, if it exists and programmable
>>    completion is active, before attempting bash's default completion,
>>    if in_command_position == 1.
>>
>> Chet
> 
> Hi,
> 
> Thanks for the guidance! Unfortunately I'm still not quite there yet -
> inlined are the changes based on my understanding of the above. It
> implements a "usercmd/-U" option similar to the existing -E for empty
> line.
> 
> But at the moment all it does is to allow (via "complete -U -F foo") to
> complete when nothing is typed in, which seemed to be possible already
> with -E. If some characters are already typed in, it will still do the
> default completion to commands in the PATH.
> 
> What have I missed?

You should make sure you don't add your code in the section with the rest
of the programmable completions, since that block is not entered if
in_command_position != 0.


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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH] Add nofirstword completion option Chet Ramey <chet.ramey@case.edu> - 2018-05-25 14:40 -0400

csiph-web