Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion script for the ctags program
Jacob Gelbman wrote on Sun, 07 Mar 2021 21:57 +00:00:
>
>
> > On Mar 7, 2021, at 3:42 PM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > Thanks for the revision. Not a full review; just two points:
> >
> > Jacob Gelbman wrote on Sun, 07 Mar 2021 19:18 +00:00:
> >>> On Feb 24, 2021, at 8:24 AM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >>> Jacob Gelbman wrote on Wed, Feb 24, 2021 at 01:20:24 -0600:
> >>>> "--fields=[include selected extension fields (flags afmikKlnsStz)]:flags"
> >>>
> >>> Recommend to move the afmikKlnsStz thing to after the colon, so it'll be
> >>> shown at a more appropriate point. Also, it would be helpful to display
> >>> descriptions to the flags using, e.g., «compset» (for the leading plus
> >>> sign) followed by «_values -s ''».
> >>
> >> I moved the possible values to the argument description, but I don’t
> >> have enough time to figure out how to complete them automatically right
> >> now.
> >
> > Like this:
> >
> > _f() { _arguments : '--foo:bar: _values -s "" baz "a[access]" "f[file]" "i[inheritance]"' }
>
> Right, I can do that. I wasn’t sure if the extra + and - symbols would
> make it complicated.
Oh, sorry. I forgot about those. In that case, something like this:
_f() { _arguments : '--foo:bar:_g' }
_g() { compset -P '[-+]'; _values -s "" baz "a[access]" "f[file]" "i[inheritance]" }
Plus or minus some code to offer «+» and «-» when there's nothing to the
left of the cursor.
Also, I suspect --fields should be declared repeatable.
> >>>> elif [ "$state" = "languages" ]; then
> >>>> _values -s , languages $languages
> >>>
> >>> Don't pass unsanitized command output to a builtin. I don't know the
> >>> fix off the top of my head.
> >
> > This point has been neither responded to nor implemented.
>
> I sanitize the output a little bit, by cutting just the first word from
> the list that’s returned. That fixes lines like "OldC++ [disabled]" And
> I’m not that worried about possibly feeding in incorrectly formatted
> data. What’s the worst that could happen? The listing will look messed
> up?
An option flag could be injected from an external command into compadd.
You don't know in advance what flag that would be and what it would mean
in compadd (you need to consider future compadd too), so this is
essentially undefined behaviour.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author