On Sat, 30 Apr 2011 21:59:44 +0100, Peter Stephenson
wrote:
> On Thu, 28 Apr 2011 16:46:19 +0200
> Haakon Riiser wrote:
>> Decided to clean it up further. Obviously it is better to avoid
>> having
>> Perl as a dependency, so the attached version does everything using
>> zsh
>> scripting. It also uses _call_program and $words[1] instead of
>> "ffmpeg"
>> directly.
>
> Thanks, committed this without doing more than a cursory scan of it
> ---
> no doubt someone will say if they're having problems.
Thank you for committing the patch so soon. Unfortunately, I found a
couple of more things to improve. :)
First of all, there was a bug in the pixel format completion - it
included an invalid match. This bug was not introduced by my previous
patch, it has been there for a long time.
The second thing I changed was not a bug, but probably something that
was poor form. Previously, I did this:
local BOLD=$'\e[1m'
local NORM=$'\e[m'
compadd -X "${BOLD}description{NORM}" -q -S '' -a array
Here, "array" contains a list of keywords to be completed (e.g., a list
of codec names), and "description" contains a description headline to be
displayed at the top, above the list of keywords. The $BOLD and $NORM
escape codes were used to make it visually identical to description
headers in other functions (e.g., _files). This method worked, but I
never liked hard-coding ANSI escape codes directly. Now, this is
replaced by:
_wanted ffmpeg-XXX expl 'description' compadd -a array
Seems to work just as well, and I don't need the ANSI escapes.
Hopefully, this is the correct way to insert matches directly. If you
notice something else that is poor form, let me know and I will fix it.
PS: I have also recently written a completion function for nmcli (the
command-line interface to NetworkManager, which is used in a lot of
Linux distros). It was a bit tricky to get right, because a deep nesting
of subcommands and non-standard command line parsing. I think I got it
right, but I haven't posted it here yet. Thought I'd get the _ffmpeg
improvements out of the way first, so that I don't make the same
mistakes in _nmcli.
--
Haakon