Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#519535: history expansion: modifier completion missing



2009/3/19 Peter Stephenson <pws@xxxxxxx>:
> Mikael Magnusson wrote:
>> Is it supposed to work here? $PWD:<tab> (it doesn't for me).
>
> No, wihin parameters the completion system doesn't handle any case
> except parameter names and values properly.  It doesn't know there's
> anything special to do there.  Parsing it would be horrible.  (It will,
> of course, expand a complete expression as an entirely separate matter.)
>
>> It does
>> complete if you write $PWD(:<tab>, but also in ${PWD(:<tab>, but
>> accepting one of the latter produces a syntax error:
>> % echo ${PWD(:A)}
>> zsh: bad substitution
>> (regardless of which modifier you use)
>
> That's because it is a syntax error.  Same answer: the completion system
> doesn't know that's special, handling all these special cases is
> horrific.  It ought to be possible for someone with that sort of time on
> their hands to extend check_param() in compcore.c to add new parameter
> contexts, but it seems a funny thing to do with your life.  (Actually,
> in the case of brace parameters that ought to be easy, it already knows
> you're in a brace parameter and it already knows the brace isn't
> complete, so it could do the same as it does for completing the
> parameter but set a different context to show it's in the trailing
> matter.  But that still leaves the non-brace case.)
>
> (Of course, the right way to do this is to have the shell parsed by
> examining a grammar which is also used for generating the cases for
> completing shell syntax.  Our infinite team of monkeys should have this
> done by the next ice age.)

Heh, i think i'll just go with typing the extra ( when i need the hints then.

>> Also, i get this:
>> $PWD(:s-<tab>
>> _history_modifiers:34: bad math expression: operand expected at `^-'
>> _history_modifiers:34: bad math expression: operand expected at `^-'
>> _history_modifiers:34: bad math expression: operand expected at `^-'
>> _history_modifiers:34: bad math expression: operand expected at `^-'
>> _history_modifiers:34: bad math expression: operand expected at `^-'
>> _history_modifiers:34: bad math expression: operand expected at `^-'
>> (same with / or other separator (but it says `^/' then, of course))
>
> I obviously didn't try this bit.  It's supposed to give you hints.  Note
> this doesn't currently work for !-history itself---out of fear, I used a
> very simple test in _normal that only works with a trailing ":".
>
>> As an aside, after i write $PWD(:<tab> to get the s, how do i "accept"
>> the completion to make tab complete the - instead of cycling to the
>> next completer? The only way i found is typing something and deleting
>> it... When completing directories i usually just type a /.
>
> Just type the string that's got to come next; it always does, or the s
> is useless: there's no point typing anything you need to delete, just
> use what you don't need to delete.  Actually, why don't you just type
> "s-"?  The "completion" is really only there as a mnemonic of what can
> go at that point, it doesn't save you any typing even in the optimal
> case.

Well, i sometimes am in the same situation with other completions where the
next string is something you would want to complete. I can't come up with any
examples at the moment though... I agree it is a bit silly in this specific
case.

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author