Patchwork zsh_completion: make use of `debuglabelcomplete` command

login
register
mail settings
Submitter Nikolaj Sjujskij
Date April 12, 2013, 1:14 p.m.
Message ID <35111d556de83375db9b.1365772467@VerkDatorn.npdb>
Download mbox | patch
Permalink /patch/1284/
State Accepted
Commit 5df602551eea982e8e2d81d354cedb1dad4442bd
Headers show

Comments

Nikolaj Sjujskij - April 12, 2013, 1:14 p.m.
# HG changeset patch
# User Nikolaj Sjujskij <sterkrig@myopera.com>
# Date 1365425498 -14400
#      Mon Apr 08 16:51:38 2013 +0400
# Node ID 35111d556de83375db9b5a5231e95c0df925fab3
# Parent  8c0a7eeda06d2773ec92b14527280db3e0167588
zsh_completion: make use of `debuglabelcomplete` command

Use `debuglabelcomplete` command when populating labels list, instead of
calling `hg` three times: for branches, bookmarks and tags. Do not pass string
being completed to `hg debuglabelcomplete` (as `$words[$CURRENT]`), since it
breaks `_hg_revrange` completion (`--rev 2.5:2.5.<Tab>`) for no apparent
benefit.
Also complete `hg view` with labels, not just tags, and drop unused `_hg_tags`.
Bryan O'Sullivan - April 12, 2013, 3:37 p.m.
On Fri, Apr 12, 2013 at 6:14 AM, Nikolaj Sjujskij <sterkrig@myopera.com>wrote:

> zsh_completion: make use of `debuglabelcomplete` command
>

Pushed to crew, thanks.
Nikolaj Sjujskij - April 12, 2013, 5:04 p.m.
> # HG changeset patch
> # User Nikolaj Sjujskij <sterkrig@myopera.com>
> # Date 1365425498 -14400
> #      Mon Apr 08 16:51:38 2013 +0400
> # Node ID 35111d556de83375db9b5a5231e95c0df925fab3
> # Parent  8c0a7eeda06d2773ec92b14527280db3e0167588
> zsh_completion: make use of `debuglabelcomplete` command
  If anyone wants to test the patch (or rather file in crew, thanks to  
Bryan), here's how I do it.

# Setting up (once):
  % mkdir ~/tmp/zsh-completion
  % ln -s `pwd`/contrib/zsh_completion ~/tmp/zsh-completion/_hg

# Enabling this directory as a completion path (once per testing session):
  % fpath=(~/tmp/zsh-completion $fpath)

# Reloading function after editing or something:
  % unfunction _hg; autoload -U _hg

Patch

diff --git a/contrib/zsh_completion b/contrib/zsh_completion
--- a/contrib/zsh_completion
+++ b/contrib/zsh_completion
@@ -163,21 +163,10 @@ 
 }
 
 _hg_labels() {
-  _hg_tags "$@"
-  _hg_bookmarks "$@"
-  _hg_branches "$@"
+  labels=("${(f)$(_hg_cmd debuglabelcomplete)}")
+  (( $#labels )) && _describe -t labels 'labels' labels
 }
 
-_hg_tags() {
-  typeset -a tags
-  local tag rev
-
-  _hg_cmd tags | while read tag
-  do
-    tags+=(${tag/ #[0-9]#:*})
-  done
-  (( $#tags )) && _describe -t tags 'tags' tags
-}
 _hg_bookmarks() {
   typeset -a bookmark bookmarks
 
@@ -940,7 +929,7 @@ 
 _hg_cmd_view() {
   _arguments -s -w : $_hg_global_opts \
   '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
-  ':revision range:_hg_tags'
+  ':revision range:_hg_labels'
 }
 
 # MQ