[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exclude builtins from command completion
From: |
kaycee gb |
Subject: |
Re: Exclude builtins from command completion |
Date: |
Thu, 23 Jan 2020 13:51:19 +0000 |
Le Sat, 18 Jan 2020 19:05:46 -0500,
Chet Ramey <address@hidden> a écrit :
> On 1/17/20 4:18 PM, kaycee gb wrote:
[...]
>
> Did you try and complete the `:' or after inserting a space or similar?
> If you try and complete the `:', what happens depends on whether you have
> a programmable completion function set.
It was a colon at beginning of line without any character before.
>
> Either way, since readline considers `:' a word separator character, the
> colon it is not part of the word readline wants to be completed.
>
> >>
> >> This comes up every now and then.
> >>
> >> http://lists.gnu.org/archive/html/bug-bash/2003-01/msg00088.html
> >> https://lists.gnu.org/archive/html/bug-bash/2016-12/msg00029.html
> >> https://lists.gnu.org/archive/html/bug-bash/2019-06/msg00038.html
> >>
> >> In this case, readline completes an empty filename.
>
> That's the default readline behavior.
>
> If there are programmable completions installed, bash runs through the
> programmable completion code attempting to complete the word readline
> asks it to (the empty string). It's not in a command position, though,
> so it won't run the -I compspec. It finds that `:' is the command name,
> but it finds that there's no separator between the end of the command
> name and the word readline wants to complete, so there's no reason to
> call its programmable completion. At that point, it attempts the default
> bash completion given the text readline asked for it to complete -- the
> empty string. That doesn't do anything special, so readline performs
> its default filename completion.
Ok. I think I see the point.
>
> > Removing colon from wordbreaks COMP_WORDBREAKS=${COMP_WORDBREAKS//:} now do
> > nothing.
>
> Now, readline wants ":" as the word to be completed. In this case, bash
> will call the -I compspec, if any, and ask to complete `:'. If you have
> your command name completion function that ignores builtins, it will find
> no matches and do nothing. If you have some other -I compspec, it will
> insert whatever that returns as usual. If you use the default bash
> completion, it will complete the `:' and insert a space.
Yes I confirm that. With default bash completion, it inserts a space. With -I
it does nothing. That's what I want for my -I compspec. One problem solved :)
>
> >
> > By curiousity, why other breakwords do not have the same comportment ? Some
> > do nothing, some list files from CWD, some list all commands from my custom
> > list. Is there a place where I can have simple information for that ?
>
> It depends on the character and the meaning it has to the shell. `>' will
> perform filename completion if you have it in COMP_WORDBREAKS and do
> nothing if you don't, since you probably don't have any commands or
> filenames beginning with `>'. `|' will do command completion, since the
> (empty) word readline wants to complete is in a command position. In
> general, if the character is in COMP_WORDBREAKS, you'll get readline
> trying completion on the empty string, and whether that is command or
> filename completion depends on whether the character is one that separates
> commands; if it's not, readline will attempt to complete a word starting
> with that character.
Thanks for clarification :)
>
> > Moreover, the links above talks about filename completion. In this case
> > isn't it command completion ? Shouldn't it behave differently ? Or like in
> > E13, filename completion and command completion enter in word completion in
> > general ?
>
> As above, yes or no.
Ok. I think I see this point too.
>
> >
> > And last, with COMP_WORDBREAKS empty, quote and double quote continue to
> > list files from CWD. Others do nothing. Shouldn't all do nothing ?
>
> Readline understands how to complete within quoted strings regardless of
> the value of COMP_WORDBREAKS/rl_completer_word_break_characters. This is
> controlled by a separate application-settable variable,
> rl_completer_quote_characters. Bash sets that to the usual set of shell
> quoting characters.
>
I understand that by application-settable variable, you mean it can't be
altered at run time, like COMP_WORDBREAKS for example. All the references to
rl_completer_quote_characters I can find are with c/c++/python/... code. Is
there any chance to change that variable without having to rebuild something ?
Which is not really portable in my opinion and in my case :/
kaycee,
- Re: Exclude builtins from command completion, (continued)
Re: Exclude builtins from command completion, Chet Ramey, 2020/01/10
- Re: Exclude builtins from command completion, kaycee gb, 2020/01/10
- Re: Exclude builtins from command completion, Greg Wooledge, 2020/01/13
- Re: Exclude builtins from command completion, kaycee gb, 2020/01/13
- Re: Exclude builtins from command completion, kaycee gb, 2020/01/17
- Re: Exclude builtins from command completion, Chet Ramey, 2020/01/17
- Re: Exclude builtins from command completion, kaycee gb, 2020/01/17
- Re: Exclude builtins from command completion, Chet Ramey, 2020/01/18
- Re: Exclude builtins from command completion,
kaycee gb <=
- Re: Exclude builtins from command completion, Chet Ramey, 2020/01/23
- Re: Exclude builtins from command completion, kaycee gb, 2020/01/23
- Re: Exclude builtins from command completion, Chet Ramey, 2020/01/23
- Re: Exclude builtins from command completion, kaycee gb, 2020/01/23
Re: Exclude builtins from command completion, Stephane Chazelas, 2020/01/11
Re: Exclude builtins from command completion, František Kučera, 2020/01/18