monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] enhancements to monotone auto-completion modules


From: Joel Reed
Subject: Re: [Monotone-devel] enhancements to monotone auto-completion modules
Date: Tue, 31 May 2005 21:22:26 -0400
User-agent: Mutt/1.5.5.1i

On Tue, May 31, 2005 at 05:49:53PM -0700, Nathaniel Smith wrote:
> On Mon, May 30, 2005 at 11:21:23PM -0400, Joel Reed wrote:
> > I'm thinking thru some enhancements to monotone's zsh auto-complete module,
> > and wanted to bounce a few ideas around on the mailing list.
> > 
> > When completing "mt dropkey ...", we can present a somewhat helpful
> > list of keys and the corresponding owners, by using "monotone ls keys"
> > 
> > 70a0f283898a18815a83df37c902e5f1492e9aa2 address@hidden
> > 0d607d8724f015664fa0ca0e1a282fe708f2674b address@hidden
> > ca09aeca875237679c4bb193d5b2d02747da9ead address@hidden
> > d9e7a76879a99dad705f058e24299a7b289f03d8 address@hidden
> > 367e100f480a7345783051788f37447381a0774f address@hidden
> > a58fe1c0786c74d536bfd58c2139130a4b7377fd address@hidden
> > 919607f11569c0fc0a4e232628c7c18868017757 address@hidden
> > 
> > However, we don't have a "mt complete key ..." command to use
> > once the user starts typing a key. Can I add such a subcommand?
> 
> Don't see why not.
> 
> Don't the various shell completion libraries already have ways to deal
> with this, though?

yes, the current contrib/monotone.zsh_completion does something like
this:

(( $+functions[_monotone_keys] )) ||
_monotone_keys() {
  local keys
  keys=$(monotone ls keys)
  compadd -X $keys -n -- $(echo $keys | grep "[0-9a-f]\{40\}" | cut -f 1 -d ' ')
}

where -X says here's what to show on the terminal, and everything after
the "--" is what we complete on. BUT, this code doesn't really handle partial
completions very well. It could be further mangled to do so, but the shell code
could be very simple in all completion cases if we could do something like:

(( $+functions[_monotone_keys] )) ||
_monotone_keys() {
  local id="$words[CURRENT]:gs/-//"
  compadd -X $(monotone complete key --brief $id) -- $(monotone complete key 
$id)
}

where "complete key --brief $id" gives just matching ids, and 
"complete key $id" gives shortened hashes (see my other post), and helpful
human-grokkable info. And do the same for completing revisions, files, etc...

the only drawback being executing "complete key" twice. maybe there's some
format that "mt complete" could use to make the above simpler still,
and only one query.

jr




reply via email to

[Prev in Thread] Current Thread [Next in Thread]