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


Groups > gnu.bash.bug > #14133

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-23 09:53 -0400
Message-ID <mailman.328.1527083598.1292.bug-bash@gnu.org> (permalink)
References <20180518110611.5099-1-bluca@debian.org> <96bcb197-40d1-aac8-c214-c513a6db805d@case.edu> <1527068652.6997.5.camel@debian.org> <76b1d3fa-4cb1-3e70-d93c-ada07c04dfa2@case.edu> <1527082457.6997.14.camel@debian.org>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 5/23/18 9:34 AM, Luca Boccassi wrote:
> On Wed, 2018-05-23 at 09:15 -0400, Chet Ramey wrote:
>> On 5/23/18 5:44 AM, Luca Boccassi wrote:
>>
>>> So by that, do you mean that it's possible to stop autocompleting
>>> to
>>> files/dirs/binaries just using a programmable completion script? Or
>>> did
>>> I misunderstand? Apologies if that's the case.
>>>
>>> Right now we do have completion scripts to implement the help text
>>> for
>>> the commands (and for the empty set, which displays a general help
>>> with
>>> a summary), what's missing is stopping files/dirs/binaries
>>> completion
>>> for the first word, so that exclusively the commands are shown.
>>
>> Exactly. What you want, I gather, is a way to restrict completions on
>> the
>> command word to the small set of router commands valid in whichever
>> mode
>> the console happens to be. Programmable completion provides a
>> mechanism to
>> do that, but there is a missing piece of functionality that would
>> allow it
>> to work on the command word. That's the change I would prefer to see.
>>
>> Chet
> 
> Ah I see - I am more than happy to work on that instead, but (forgive
> my n00bness, first time hacking on Bash) could you please describe in a
> couple of lines what the missing piece is and what it should look like?

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
-- 
``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-23 09:53 -0400

csiph-web