diff contrib/zsh_completion @ 5868:838fa52abcc1

[PATCH] zsh_completion tag/mq fixes Been using these for almost a month now without problems, so I figured some other people might want them. This allows the zsh completion to work with tags and mq patch names containing spaces, and adds support for qgoto.
author Nicholas Riley <njriley@uiuc.edu>
date Fri, 18 Jan 2008 08:23:29 -0600
parents e21644bbf01e
children 694223a29ad4
line wrap: on
line diff
--- a/contrib/zsh_completion	Fri Jan 18 03:06:05 2008 +0200
+++ b/contrib/zsh_completion	Fri Jan 18 08:23:29 2008 -0600
@@ -13,6 +13,9 @@
 # option) any later version.
 #
 
+emulate -LR zsh
+setopt extendedglob
+
 local curcontext="$curcontext" state line
 typeset -A _hg_cmd_globals
 
@@ -153,9 +156,9 @@
   typeset -a tags
   local tag rev
 
-  _hg_cmd tags 2> /dev/null | while read tag rev
+  _hg_cmd tags 2> /dev/null | while read tag
   do
-    tags+=($tag)
+    tags+=(${tag/ #    [0-9]#:*})
   done
   (( $#tags )) && _describe -t tags 'tags' tags
 }
@@ -674,13 +677,13 @@
 # MQ
 _hg_qseries() {
   typeset -a patches
-  patches=($(_hg_cmd qseries 2>/dev/null))
+  patches=(${(f)"$(_hg_cmd qseries 2>/dev/null)"})
   (( $#patches )) && _describe -t hg-patches 'patches' patches
 }
 
 _hg_qapplied() {
   typeset -a patches
-  patches=($(_hg_cmd qapplied 2>/dev/null))
+  patches=(${(f)"$(_hg_cmd qapplied 2>/dev/null)"})
   if (( $#patches ))
   then
     patches+=(qbase qtip)
@@ -690,7 +693,7 @@
 
 _hg_qunapplied() {
   typeset -a patches
-  patches=($(_hg_cmd qunapplied 2>/dev/null))
+  patches=(${(f)"$(_hg_cmd qunapplied 2>/dev/null)"})
   (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
 }
 
@@ -730,6 +733,12 @@
   '*:unapplied patch:_hg_qunapplied'
 }
 
+_hg_cmd_qgoto() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--force -f)'{-f,--force}'[overwrite any local changes]' \
+  ':patch:_hg_qseries'
+}
+
 _hg_cmd_qguard() {
   _arguments -s -w : $_hg_global_opts \
   '(--list -l)'{-l,--list}'[list all patches and guards]' \