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

Re: How to do completion of toggle flag sequences separated by +/-



On Sun, 1 May 2011 17:18:46 +0100, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
On Sun, 01 May 2011 12:16:05 +0200
Haakon Riiser <haakon.riiser@xxxxxxxxxx> wrote:
I'm still working on perfecting the FFmpeg completion function, and one of the most important things missing is good completion of toggle flags.

 Here's an example of FFmpeg's toggle flag syntax:

 ffmpeg -flags +gmc-global_header+cgop
[...]

I don't think there's a prepackaged way of doing this.  I've had some
luck with the following. One thing it doesn't do is treat the + and - as separate from the options following, but a bit of patience might sort
that out.

It's actually written to complete options for the fictitious "flags"
command, so you also have to insinuate it into ffmpeg completion
somehow.
[...]

Thanks, that's an excellent starting point. I will try to integrate this into _ffmpeg shortly.

By the way: When defining sub-functions inside a completion function, is it recommended to test for their existence before defining them? E.g.,

(( $+functions[_ffmpeg_foo] )) || _ffmpeg_foo() {
  ...
}

I see this in a lot of completers included with zsh, and I assumed it was done for performance reasons (although it seems strange that the performance hit could be significant, considering that the code is only executed once per TAB keypress).

--
 Haakon



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