zsh-workers
 help / color / mirror / code / Atom feed
From: Haakon Riiser <haakon.riiser@fys.uio.no>
To: <zsh-workers@zsh.org>
Subject: How to do completion of toggle flag sequences separated by +/-
Date: Sun, 01 May 2011 12:16:05 +0200	[thread overview]
Message-ID: <7965011ce0f14864142f9006d881bba9@ulrik.uio.no> (raw)

 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

 In the above example, three toggle flags are set:

 gmc is enabled (+)
 global_header is disabled (-)
 cgop is enabled (+)

 Ideally, I would like the completion to behave like this:

 ffmpeg -flags ^I

 Typing the above should generate two matches: "+" and "-". Next,

 ffmpeg -flags +^I

 should generate a list of all possible flag values (gmc, cgop, etc). 
 Next, select one of the flags, e.g.:

 ffmpeg -flags +gmc^I

 An important point here is that *no space should be inserted* after the 
 inserted flag; the cursor must be placed immediately after "+gmc". 
 Pressing TAB again should repeat the process by again suggesting "+" or 
 "-" to add more flags. Once I'm done adding flags, I type in a space and 
 completion should no longer be in toggle flag mode.

 Achieving this seems very hard to do, because there could be ambiguity 
 in some cases. Assume that "foo" and "foobar" are both valid flags, and 
 I type this:

 ffmpeg -flags +foo^I

 Here, there are two possibilities: Either suggest "+" or "-" as if a 
 new flag is to be completed (because +foo is a valid flag), or complete 
 to +foobar because there is also a flag by that name. Resolving this is 
 probably complicated, so I'll probably compromise on something. Does 
 anyone have any suggestions on how to get as close to the above ideal 
 completion behavior using standard zsh completion functions (_values, 
 _arguments, etc)?

-- 
  Haakon


             reply	other threads:[~2011-05-01 10:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-01 10:16 Haakon Riiser [this message]
2011-05-01 16:18 ` Peter Stephenson
2011-05-02  9:16   ` Haakon Riiser
2011-05-03 10:27     ` Peter Stephenson
2011-05-03 13:49       ` Haakon Riiser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7965011ce0f14864142f9006d881bba9@ulrik.uio.no \
    --to=haakon.riiser@fys.uio.no \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).