Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Various completion contributions



On Fri, 7 Jan 2011 20:42:15 -0500
gi1242+zsh@xxxxxxxxx wrote:
> I updated/modified a couple of default completion scripts, and wrote a
> couple of new ones. I'm attaching them to this message in case they
> would be useful. (Please let me know the "official" way to submit
> patches / bugs, and I will do so in future).

Thanks for those.  You need to send things as "diff -u"s, preferably
against the latest CVS or git archive, though if you're reasonably
confident nothing much has changed a diff against the source tree of the
last release would be OK (a diff against installed files isn't as much
use).  I've attached what I'm submitting, which shows the form.  Because
you didn't, I can't be absolutely sure I'm not regressing previous
changes, but I don't think I am.  See notes on Patches in
Etc/zsh-development-guide.

General comments:  Define functions as

  funcname() {
    ...
  }

You don't need the () *and* "function" in front: the "()" is a bit of a
con, it's got nothing to do with a parameter list.

The convention for defining multiple functions is that the main function
is itself defined as a nested function, then called at the end.  This
saves the additional functions being redefined each time the main
function is called.  E.g., in _foo:

  _foo_helper() {
    ...
  }
  
  _foo() {
    ...
  }
  
  _foo "$@"

I haven't actually bothered to fix this because it should be minor in
the cases in question.

I've only lightly skimmed the changes, I have not tried them all out, so
anyone else should have a play if there favourite completions are
affected.

>     _okular	Added non-qt/kde options, and complete all files which
> 		okular can view. (I got the list from /etc/mailcap on my
> 		system, so I'm not sure if the list is complete or not)

Not sure what this is supposed to be adding to, there isn't an _okular.
I've removed "okular" from the _pdf compdef.

>     _tex	New completion file

There's already one in Completion/Unix/Type/_tex, so I've ignored this.

>     _unison	New completion file
>     _xournal	New completion file (only completes filenames).

No idea what these are but put them in Completion/Unix/Command (again, a
diff would have shown where it should go).

Here's the diff, created with "cvs diff -puN" from the top level of the
archive.  Don't know if you need an equivalent of the -N (show new
files) with "git diff", but I would imagine "git show", which Mikael
reminded me about, would show new files if you got it to show your local
git commit.

Index: Completion/Linux/Command/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Linux/Command/.distfiles,v
retrieving revision 1.17
diff -p -u -r1.17 .distfiles
--- Completion/Linux/Command/.distfiles	16 Apr 2009 12:52:31 -0000	1.17
+++ Completion/Linux/Command/.distfiles	8 Jan 2011 20:52:48 -0000
@@ -27,5 +27,6 @@ _tune2fs
 _uml
 _valgrind
 _vserver
+_wpa_cli
 _yast
 '
Index: Completion/Linux/Command/_modutils
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Linux/Command/_modutils,v
retrieving revision 1.16
diff -p -u -r1.16 _modutils
--- Completion/Linux/Command/_modutils	14 Jul 2009 08:57:13 -0000	1.16
+++ Completion/Linux/Command/_modutils	8 Jan 2011 20:52:48 -0000
@@ -1,8 +1,23 @@
 #compdef lsmod modinfo modprobe rmmod insmod
 
+_modules_caching_policy()
+{
+  # Rebuild every week, or if $modules_dir is newer than the cache
+  local -a oldp
+
+  oldp=( "$1"(Nmw+1) )
+  (( $#oldp )) || [[ $modules_dir -nt $1 ]]
+}
+
 local curcontext="$curcontext" expl state line modules ign args ret=1
 local -r modules_dir=/lib/modules
 
+local update_policy
+zstyle -s ":completion:*:*:$service:*" cache-policy update_policy
+if [[ -z "$update_policy" ]]; then
+  zstyle ":completion:*:*:$service:*" cache-policy _modules_caching_policy
+fi
+
 args=(
   '(-)'{-V,--version}'[print version]'
   '(-)'{-h,--help}'[print help text]'
@@ -39,6 +54,7 @@ case "$service" in
       "(-v --verbose $ign)"{-v,--verbose}'[print all commands as executed]' \
       '(-C --config)'{-C,--config}'[specify config file]:config file:_files' \
       "(-r --remove -l --list -t --type -a --all $ign)"{-r,--remove}'[remove module (stacks)]' \
+      "(-l --list -t --type -a --all $ign)"{'-i[ignore install/remove commands in config file]','--ignore-install[ignore install commands in config file]','--ignore-remove[ignore remove commands in config file]'} \
       "(* -l --list -r --remove $ign)"{-l,--list}'[list matching modules]' \
       "(-c $ign)1:modules:->loadable_modules" \
       "(-c -l --list -t --type $ign)*:params:->params" && ret=0
@@ -87,7 +103,13 @@ case "$state" in
     else
       kver=$(uname -r)
     fi
-    modules=( $modules_dir/$kver/(*~(source|build))/**/*(.:t:r) )
+    if [[ -z $modules ]] && ! _cache_invalid modules-$kver && \
+      ! _retrieve_cache modules-$kver;
+    then 
+      # 2011-01-02 gi1242: Do we need .o files? Or is .ko enough?
+      modules=( $modules_dir/$kver/(*~(source|build))/**/*.(o|ko)(.:t:r) )
+      _store_cache modules-$kver modules
+    fi
 
     if [[ $state = loadable_modules ]]; then
         modules=( ${modules:#(${(j:|:)~${=loaded_modules//_/-}})} )
Index: Completion/Linux/Command/_wpa_cli
===================================================================
RCS file: Completion/Linux/Command/_wpa_cli
diff -N Completion/Linux/Command/_wpa_cli
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Linux/Command/_wpa_cli	8 Jan 2011 20:52:48 -0000
@@ -0,0 +1,13 @@
+#compdef wpa_cli
+
+_arguments \
+    '-p:path to ctrl sockets:_files -g "*(=)"' \
+    '-i:ifname:_net_interfaces' \
+    '-h[help]' \
+    '-v[shown version information]' \
+    '-B[run a daemon in the background]' \
+    '-a[run in daemon mode]:action file:_files' \
+    '-P:pid file:_files' \
+    '-g:global ctrl:_files -g "*(=)"' \
+    '-G:ping interval:' \
+    ':command:(status ping mib help interface level license quit set logon logoff pmksa reassociate preauthenticate identity password new_password pin otp passphrase bssid list_networks select_network enable_network disable_network add_network remove_network set_network get_network save_config disconnect reconnect scan scan_results bss get_capability reconfigure terminate interface_add interface_remove interface_list ap_scan stkstart ft_ds wps_pbc wps_pin wps_reg)'
Index: Completion/Unix/Command/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/.distfiles,v
retrieving revision 1.110
diff -p -u -r1.110 .distfiles
--- Completion/Unix/Command/.distfiles	5 Aug 2010 19:33:47 -0000	1.110
+++ Completion/Unix/Command/.distfiles	8 Jan 2011 20:52:48 -0000
@@ -146,6 +146,7 @@ _pbm
 _perforce
 _perl
 _perldoc
+_pgrep
 _php
 _pine
 _ping
@@ -222,6 +223,7 @@ _unace
 _uname
 _unexpand
 _uniq
+_unison
 _units
 _user_admin
 _uzbl
@@ -238,6 +240,7 @@ _wiggle
 _xargs
 _xmlsoft
 _xmms2
+_xournal
 _yafc
 _yodl
 _yp
Index: Completion/Unix/Command/_lp
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_lp,v
retrieving revision 1.4
diff -p -u -r1.4 _lp
--- Completion/Unix/Command/_lp	10 Feb 2009 18:33:22 -0000	1.4
+++ Completion/Unix/Command/_lp	8 Jan 2011 20:52:48 -0000
@@ -1,52 +1,219 @@
-#compdef lp lpr lpq lprm
+#compdef lp lpr lpq lprm lpoptions lpstat
 
 local expl ret=1 printer list disp strs shown
 
-if compset -P '-[dP]' || [[ "$words[CURRENT-1]" = -[dP] ]]; then
-  _printers
-else
-  if [[ "$service" = (lpq|lprm) ]]; then
-    if [[ "$words" = *-P* ]]; then
-      printer=(-P "${${words##*-P( |)}%% *}")
-    else
-      printer=()
-    fi
-    list=( ${(M)"${(f@)$(_call_program jobs lpq $printer 2> /dev/null)}":#[0-9]*} )
+_lp_get_printer()
+{
+  # No reason to call _lp_get_printer when service == lpstat. Others matched
+  # below.
+  case $service in
+    (lpr|lpq|lprm)
+      [[ "$words" == (#I)*-P* ]] && printer="${${words##*(#I)-P( |)}%% *}"
+      ;;
+    (lp)
+      [[ "$words" == (#I)*-d* ]] && printer="${${words##*(#I)-d( |)}%% *}"
+      ;;
+    (lpoptions)
+      [[ "$words" == (#I)*-(d|p)* ]] && \
+	printer="${${words##*(#I)-(d|p)( |)}%% *}"
+      ;;
+  esac
+}
+
+_lp_job_options()
+{
+  local -a lopts_with_args lopts_no_args
+
+  # Generic options (from lp manual page)
+  lopts_with_args=( media orientation-requested sides number-up scaling cpi lpi
+    page-{bottom,left,right,top} )
+
+  lopts_no_args=(fitplot landscape)
 
-    if (( $#list )); then
-      _tags users jobs
+  _lp_get_printer
+  [[ -n "$printer" ]] && printer=(-p $printer)
 
-      while _tags; do
-        if _requested users; then
-          strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
-          if [[ -z "$shown" ]] &&
-             zstyle -T ":completion:${curcontext}:users" verbose; then
-            disp=(-ld list)
-  	  shown=yes
-          else
-  	  disp=()
-          fi
-	  _all_labels users expl user compadd "$disp[@]" -a strs ||
-              _users && ret=0
-        fi
-        if _requested jobs; then
-          strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
-          if [[ -z "$shown" ]] &&
-             zstyle -T ":completion:${curcontext}:jobs" verbose; then
-            disp=(-ld list)
-  	  shown=yes
-          else
-  	  disp=()
-          fi
-          _all_labels jobs expl job compadd "$disp[@]" -a strs && ret=0
-        fi
-        (( ret )) || return 0
-      done
+  # The program specified by the style list-printer-options should list jobs in
+  # the same style as lpoptions -l.
+  if compset -P '*='; then
+    # List values for the option
+    case ${IPREFIX%=} in
+      (media)
+	compadd "$@" a4 letter legal
+	;;
+      (orientation-requested)
+	compadd "$@" 4
+	;;
+      (sides)
+	compadd "$@" one-sided two-sided-{long,short}-edge
+	;;
+      (number-up)
+	_description -V option-o-1 expl "pages per sheet"
+	compadd "$expl[@]" 2 4 6 9 16
+	;;
+      (scaling|cpi|lpi|page-(bottom|left|right|top))
+	return 0; # Don't complete anything
+	;;
+      (*)
+	compadd "$@" \
+	  $(_call_program list-printer-options lpoptions $printer -l | \
+	    grep "^${IPREFIX%=}" | cut -d: -f2 | tr -d \* )
+	;;
+    esac
+  else
+    # List options
+    local eq_suffix
+
+    # Don't add an '=' suffix when completing lpoptions -r
+    if [[ $service == lpoptions && $words[CURRENT-1] == "-r" ]]; then
+      eq_suffix=()
     else
-      _message 'no print jobs'
+      eq_suffix=(-S '=')
     fi
-    return 1
+
+    _description lpopts expl "generic printer options"
+    compadd "$expl[@]" $eq_suffix $lopts_with_args
+    compadd "$expl[@]" $lopts_no_args
+
+    _description printeropts expl "printer specific options"
+    compadd "$expl[@]" $eq_suffix \
+      $(_call_program list-printer-options \
+	lpoptions $printer -l | cut -d/ -f1)
+  fi
+}
+
+_lp_list_jobs()
+{
+  _lp_get_printer
+  [[ -n "$printer" ]] && printer=(-P $printer)
+
+  list=( ${(M)"${(f@)$(_call_program jobs lpq $printer 2> /dev/null)}":#[0-9]*} )
+
+  if (( $#list )); then
+    _tags users jobs
+
+    while _tags; do
+      if _requested users; then
+	strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
+	if [[ -z "$shown" ]] &&
+	   zstyle -T ":completion:${curcontext}:users" verbose;
+	then
+	  disp=(-ld list)
+	  shown=yes
+	else
+	  disp=()
+	fi
+	_all_labels users expl user compadd "$disp[@]" -a strs ||
+	    _users && ret=0
+      fi
+      if _requested jobs; then
+	strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
+	if [[ -z "$shown" ]] &&
+	   zstyle -T ":completion:${curcontext}:jobs" verbose; then
+	  disp=(-ld list)
+	shown=yes
+	else
+	disp=()
+	fi
+	_all_labels jobs expl job compadd "$disp[@]" -a strs && ret=0
+      fi
+      (( ret )) || return 0
+    done
   else
-    _pspdf
+    _message 'no print jobs'
   fi
-fi
+  return 1
+}
+
+case $service in
+  (lpq)
+    _arguments \
+      '-E[Force encryption]' \
+      '-U:username (for connection to server):_users' \
+      '-h:alternate server:_hosts' \
+      '(-a)-P+[destination printer]:printers:_printers' \
+      '(-P)-a[all printers]' \
+      '-l[long listing]' \
+      '*:poll interval (+seconds):'
+    ;;
+
+  (lprm)
+    _arguments \
+      '-E[Force encryption]' \
+      '-U:username (for connection to server):_users' \
+      '-h:alternate server:_hosts' \
+      '-P+[destination printer]:printers:_printers' \
+      '*:job ids:_lp_list_jobs'
+    ;;
+
+  (lpoptions)
+    _arguments \
+      '-E[Force encryption]' \
+      '-U:username (for connection to server):_users' \
+      '-h:alternate server:_hosts' \
+      '(-p -l -r -x)-d[set default printer]:printers:_printers' \
+      '(-l -x)*-o:job options:_lp_job_options' \
+      '(-d -x)-p[destination printer for options]:printers:_printers' \
+      '(-d -o -r -x)-l[list options]' \
+      '(-d -l -x)*-r:remove option:_lp_job_options' \
+      '(-d -l -r -o)-x[remove all options]:printers:_printers'
+    ;;
+
+  (lpstat)
+    _arguments \
+      '-E[Force encryption]' \
+      '-R[Shows print job ranking]' \
+      '-U:username (for connection to server):_users' \
+      '-W:which jobs:(completed not-completed)' \
+      '-a[Show accepting state]:printers:_printers' \
+      '-c:printer classes:' \
+      '-d[Show current default destination]' \
+      '-h:hostname (alternate server):_hosts' \
+      '-l[long listing]' \
+      '-o[destinations]:printers:_printers' \
+      '-p:printers:_printers' \
+      '-r[CUPS server running status]' \
+      '-s[Status summary]' \
+      '-t[All status info]' \
+      '-u[list jobs by users]:users:_users' \
+      '-v[show devices]:printers:_printers'
+    ;;
+
+  (lpr)
+    _arguments \
+      '-E[Force encryption]' \
+      '-H:hostname (alternate server):_hosts' \
+      '(-C -J -T)'-{C,J,T}':job name:' \
+      '-P+[destination printer]:printers:_printers' \
+      '-U:username (for connection to server):_users' \
+      '-#[Copies]:copies (1--100):' \
+      '-h[Disables banner printing]' \
+      '-l[raw file]' \
+      '-m[Send an email on job completion]' \
+      '*-o:print job options:_lp_job_options' \
+      '-p[format with shaded header incl. date, time etc.]' \
+      '-q[Hold job for printing.]' \
+      '-r[delete files after printing]' \
+      '*:PS/PDF files:_pspdf'
+    ;;
+
+  (lp)
+    _arguments \
+      '-E[Force encryption]' \
+      '-U[username (for connection to server)]:username:_users' \
+      '-c[(OBSOLETE) copy to spool dir before printing]' \
+      '-d[destination printer]:printers:_printers' \
+      '-h:hostname (alternate server):_hosts' \
+      '-i[job id to modify]:job id:' \
+      '-m[Send an email on job completion]' \
+      '-n[Copies]:copies (1--100):' \
+      '*-o:print job options:_lp_job_options' \
+      '-q[Job priority -- 1 (lowest) to 100 (highest)]:priority:' \
+      '-s[Dont report resulting job IDs]' \
+      '-t[Sets the job name]:job name:' \
+      '-u[job submission username]:username:_users' \
+      '-H[Time to print]:print time (or enter hh\:mm):(hold immediate restart resume)' \
+      '-P:page range list:' \
+      '*:PS/PDF files:_pspdf'
+    ;;
+esac
Index: Completion/Unix/Command/_pgrep
===================================================================
RCS file: Completion/Unix/Command/_pgrep
diff -N Completion/Unix/Command/_pgrep
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_pgrep	8 Jan 2011 20:52:48 -0000
@@ -0,0 +1,112 @@
+#compdef pgrep pkill 
+
+local context state line
+typeset -A opt_args
+typeset -a arguments
+
+arguments=('-P[parent process id]:parent process id:->ppid' 
+	   '-g[match only in process group ids]:group:->pgid' 
+	   '-G[match only real group id]:group:->group' 
+	   '-s[match only session id]:session id:->sid' 
+	   '-t[match only controlled by terminal]:terminal device:->tty'
+	   '-u[match only effective user id]:user:->user' 
+	   '-U[match only real user id]:user:->user' 
+           '(-n)-o[oldest process]' 
+	   '(-o)-n[newest process]' 
+	   '-f[match against full command line]' 
+	   '-v[negate matching]' 
+	   '-x[match exactly]' 
+	   '*:process name:->pname')
+
+if [[ $service == 'pkill' ]]
+then
+	arguments+=('-'${^signals}'[signal]')
+elif [[ $service == 'pgrep' ]]
+then
+	arguments+=('-d[output delimiter]:delimiter:compadd ${(s\:\:)IFS}'
+		    '-l[list name in addition to id]')
+fi
+
+_arguments -s -w $arguments
+
+case $state in
+	(tty)
+		compset -P '*,'
+
+		local -a used
+		used=(${(s:,:)IPREFIX})
+
+		compadd -S ',' -q -F used /dev/tty*(:t)
+		;;
+		
+	(sid)
+		compset -P '*,'
+
+		local -a used sid
+		used=(${(s:,:)IPREFIX})
+		sid=(${(uon)$(ps -A o sid=)})
+
+		compadd -S ',' -q -F used $sid
+		;;
+	
+	(ppid)
+		compset -P '*,'
+
+		local -a used ppid
+		used=(${(s:,:)IPREFIX})
+		ppid=(${(uon)$(ps -A o ppid=)})
+
+		compadd -S ',' -q -F used $ppid
+		;;
+
+	(pgid)
+		compset -P '*,'
+
+		local -a used pgid
+		used=(${(s:,:)IPREFIX})
+		pgid=(${(uon)$(ps -A o pgid=)})
+
+		compadd -S ',' -q -F used $pgid
+		;;
+	
+	(pname)
+		if (( ${+opt_args[-x]} )) && (( ${+opt_args[-f]} ))
+		then
+			compadd ${(u)${(f)"$(ps -A o cmd=)"}}
+		else
+			compadd ${(u)${(f)"$(ps -A co cmd=)"}}
+		fi
+		;;
+	
+	(group)
+		compset -P '*,'
+
+		local group
+		group=$(getent group)
+
+		local -a groups ids
+		groups=(${${(f)group}%%:*})
+		ids=(${${${(f)group}#*:*:}%%:*})
+
+		local -a used
+		used=(${(s:,:)IPREFIX})
+
+		compadd -S ',' -q -F used -d ids $groups $groups
+		;;
+
+	(user)
+		compset -P '*,'
+
+		local passwd
+		passwd=$(getent passwd)
+
+		local -a users ids
+		users=(${${(f)passwd}%%:*})
+		ids=(${${${(f)passwd}#*:*:}%%:*})
+		
+		local -a used
+		used=(${(s:,:)IPREFIX})
+
+		compadd -S ',' -q -F used -d ids $users $users
+		;;
+esac
Index: Completion/Unix/Command/_subversion
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_subversion,v
retrieving revision 1.31
diff -p -u -r1.31 _subversion
--- Completion/Unix/Command/_subversion	17 Dec 2009 09:48:12 -0000	1.31
+++ Completion/Unix/Command/_subversion	8 Jan 2011 20:52:48 -0000
@@ -4,6 +4,12 @@ _svn () {
   local curcontext="$curcontext" state line expl ret=1
   typeset -A opt_args
 
+  local update_policy
+  zstyle -s ":completion:*:*:$service:*" cache-policy update_policy
+  if [[ -z "$update_policy" ]]; then
+    zstyle ":completion:*:*:$service:*" cache-policy _svn_caching_policy
+  fi
+
   _arguments -C \
     '(-)--help[print help information]' \
     '(- *)--version[print client version information]' \
@@ -12,9 +18,12 @@ _svn () {
 
   if [[ -n $state ]] && (( ! $+_svn_cmds )); then
     typeset -gHA _svn_cmds
-    _svn_cmds=(
-      ${=${(f)${${"$(LC_ALL=C _call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
-    )
+    if ! _cache_invalid svn_cmds && ! _retrieve_cache svn_cmds; then 
+      _svn_cmds=(
+	${=${(f)${${"$(LC_ALL=C _call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
+      )
+      _store_cache svn_cmds _svn_cmds
+    fi
   fi
 
   case $state in
@@ -29,10 +38,20 @@ _svn () {
       if (( $#cmd )); then
         curcontext="${curcontext%:*:*}:svn-${cmd}:"
 
-        usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
-        args=(
-          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
-        )
+	if ! _cache_invalid svn-${cmd}-usage && \
+	    ! _retrieve_cache svn-${cmd}-usage;
+	then
+	  usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
+	  _store_cache svn-${cmd}-usage usage
+	fi
+	if ! _cache_invalid svn-${cmd}-usage && \
+	    ! _retrieve_cache svn-${cmd}-args;
+	then
+	  args=(
+	    ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+	  )
+	  _store_cache svn-${cmd}-args args
+	fi
 
         case $cmd in;
           (add)
@@ -297,4 +316,13 @@ _subversion () {
   esac
 }
 
+_svn_caching_policy() {
+  # Rebuild every week
+  local -a oldp
+
+  oldp=( "$1"(Nmw+1) )
+  (( $#oldp ))
+}
+
+
 _subversion "$@"
Index: Completion/Unix/Command/_unison
===================================================================
RCS file: Completion/Unix/Command/_unison
diff -N Completion/Unix/Command/_unison
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_unison	8 Jan 2011 20:52:48 -0000
@@ -0,0 +1,92 @@
+#compdef unison
+
+local context state line
+typeset -A opt_args
+
+_arguments \
+    '-auto[automatically accept default (nonconflicting) actions]' \
+    '-batch[batch mode\: ask no questions at all]' \
+    '-doc[show documentation]:topics:(about people lists status copying ack install tutorial basics failures running ssh news all topics)' \
+    '-follow[add a pattern to the follow list]:pattern:' \
+    '-force[force changes from this replica to the other]:replica:' \
+    '-group[synchronize group attributes]' \
+    '-ignore[add a pattern to the ignore list]:pattern:' \
+    '-ignorenot[add a pattern to the ignorenot list]:pattern:' \
+    '-owner[synchronize owner]' \
+    '-path[path to synchronize]:path:_files' \
+    '-perms[part of the permissions which is synchronized]:perms:' \
+    '-prefer[choose this replicas version for conflicting changes]:replica:' \
+    '-root[root of a replica (should be used exactly twice)]:path:_files -/' \
+    '-silent[print nothing except error messages]' \
+    '-terse[suppress status messages]' \
+    '-testserver[exit immediately after the connection to the server]' \
+    '-times[synchronize modification times]' \
+    '-version[print version and exit]' \
+    '-addprefsto[add new prefs to]:file:_files' \
+    '-addversionno[add version number to name of unison on server]' \
+    '-backup[add a pattern to the backup list]:pattern:' \
+    '-backupcurr[add a pattern to the backupcurr list]:pattern:' \
+    '-backupcurrnot[add a pattern to the backupcurrnot list]:pattern:' \
+    '-backupdir[directory for storing centralized backups]:directory:_files -/' \
+    '-backuploc[where backups are stored]:backup location:(local central)' \
+    '-backupnot[add a pattern to the backupnot list]:pattern:' \
+    '-backupprefix[prefix for the names of backup files]:prefix:' \
+    '-backups[keep backup copies of all files]' \
+    '-backupsuffix[a suffix to be added to names of backup files]:suffix:' \
+    '-confirmbigdel[ask about whole-replica (or path) deletes (default true)]' \
+    '-confirmmerge[ask for confirmation before commiting results of a merge]' \
+    '-contactquietly[suppress the "contacting server" message during startup]' \
+    '-copyprog[external program for copying large files]:program:_files -g "*(-x)"' \
+    '-copyprogrest[variant of copyprog for resuming partial transfers]:program:_files -g "*(-x)"' \
+    '-copyquoterem[add quotes to remote file name for copyprog]:quote style:(true false default)]' \
+    '-copythreshold[use copyprog on files bigger than this]:size (kb):' \
+    '-debug:debug module:(all verbose)' \
+    '-diff[command for showing differences between files]:program:_files -g "*(-x)"' \
+    '-dontchmod[When set, never use the chmod system call]' \
+    '-dumbtty[do not change terminal settings in text UI]' \
+    '-fastcheck:fast update detection:(true false default)' \
+    '-forcepartial[add a pattern to the forcepartial list]:pattern:' \
+    '-height[height of main window in graphical interface]:number (lines):' \
+    '-host[bind the socket to this host name in server socket mode]:host:_hosts' \
+    '-ignorecase[identify upper/lowercase filenames]:ignorecase:(true false default)' \
+    '-ignorelocks[ignore locks left over from previous run (dangerous!)]' \
+    '-immutable[add a pattern to the immutable list]:pattern:' \
+    '-immutablenot[add a pattern to the immutablenot list]:pattern:' \
+    '-key[define a keyboard shortcut for this profile (in some UIs)]:shortcut:' \
+    '-killserver[kill server when done (even when using sockets)]' \
+    '-label[provide a descriptive string label for this profile]:label:' \
+    '-log[record actions in logfile (default true)]' \
+    '-logfile:logfile name:_files' \
+    '-maxbackups[number of backed up versions of a file]:number:' \
+    '-maxthreads[maximum number of simultaneous file transfers]:number:' \
+    '-merge[add a pattern to the merge list]:pattern:' \
+    '-mountpoint[abort if this path does not exist]:mountpoint:_files -/' \
+    '-numericids[dont map uid/gid values by user/group names]' \
+    '-preferpartial[add a pattern to the preferpartial list]:pattern:' \
+    '-pretendwin[Use creation times for detecting updates]' \
+    '-repeat[synchronize repeatedly (text interface only)]:repeat:' \
+    '-retry[re-try failed synchronizations N times (text ui only)]:retry times:' \
+    '-rootalias[register alias for canonical root names]:root alias:' \
+    '-rsrc:synchronize resource forks:(true false default)' \
+    '-rsync[activate the rsync transfer mode (default true)]' \
+    '-selftest[run internal tests and exit]' \
+    '-servercmd[name of unison executable on remote server]:program:_files -g "*(-x)"' \
+    '-showarchive[show "true names" (for rootalias) of roots and archive]' \
+    '-socket[act as a server on a socket]:socket:_files -g "*(-=)"' \
+    '-sortbysize[list changed files by size, not name]' \
+    '-sortfirst[add a pattern to the sortfirst list]:pattern:' \
+    '-sortlast[add a pattern to the sortlast list]:pattern:' \
+    '-sortnewfirst[list new before changed files]' \
+    '-sshargs[other arguments (if any) for remote shell command]:ssh args:' \
+    '-sshcmd[path to the ssh executable]:program:_files -g "*(-x)"' \
+    '-ui:user interface:(text graphic)' \
+    '-xferbycopying[optimize transfers using local copies (default true)]' \
+    '*:profile:->profile'
+
+if [[ $state == profile ]]; then
+    local -a profiles
+
+    profiles=( ~/.unison/*.prf(N) )
+    (( $#profiles )) && \
+	compadd "$@" - ${${profiles#~/.unison/}%.prf}
+fi
Index: Completion/Unix/Command/_xournal
===================================================================
RCS file: Completion/Unix/Command/_xournal
diff -N Completion/Unix/Command/_xournal
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_xournal	8 Jan 2011 20:52:48 -0000
@@ -0,0 +1,6 @@
+#compdef xournal
+
+local expl
+
+_description files expl 'PDF and Xournal files'
+_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'
Index: Completion/Unix/Type/_pdf
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_pdf,v
retrieving revision 1.8
diff -p -u -r1.8 _pdf
--- Completion/Unix/Type/_pdf	5 Jan 2009 14:14:16 -0000	1.8
+++ Completion/Unix/Type/_pdf	8 Jan 2011 20:52:48 -0000
@@ -1,4 +1,4 @@
-#compdef pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext pdfopt pdffonts kpdf okular
+#compdef pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext pdfopt pdffonts kpdf
 
 local expl ext=''
 
Index: Completion/X/Command/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/.distfiles,v
retrieving revision 1.17
diff -p -u -r1.17 .distfiles
--- Completion/X/Command/.distfiles	1 Aug 2007 21:38:34 -0000	1.17
+++ Completion/X/Command/.distfiles	8 Jan 2011 20:52:48 -0000
@@ -4,6 +4,8 @@ _acroread       _dcop
 _gnome-gv       _gqview         _gv             _kfmclient
 _mozilla        _mplayer        _nautilus
 _nedit          _netscape
+_okular
+_pdftk
 _qiv            
 _setxkbmap
 _urxvt          _vnc
Index: Completion/X/Command/_gv
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_gv,v
retrieving revision 1.3
diff -p -u -r1.3 _gv
--- Completion/X/Command/_gv	31 Aug 2005 09:28:30 -0000	1.3
+++ Completion/X/Command/_gv	8 Jan 2011 20:52:48 -0000
@@ -34,7 +34,7 @@ _arguments \
   '--arguments=:ghostscript arguments:' \
   '--page=:label of first page:' \
   '--media=:page size:(Letter Legal Statement Tabloid Ledger Folio Quarto 10x14 Executive A3 A4 A5 B4 B5)' \
-  '--orientation=:orientation:' \
+  '--orientation=:orientation:(landscape seascape upsidedown portrait)' \
   '--scale=:scale entry:' \
   '--scalebase=:scale base:' \
   '--ad=:resource file:_files' \
Index: Completion/X/Command/_okular
===================================================================
RCS file: Completion/X/Command/_okular
diff -N Completion/X/Command/_okular
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/X/Command/_okular	8 Jan 2011 20:52:48 -0000
@@ -0,0 +1,10 @@
+#compdef okular
+local extns
+
+extns="{pdf,ps,eps,dvi}(.gz|.bz2)(#c,1)|djvu|tiff|chm|cbr|cbz"
+
+_arguments \
+  '(-p --page)'{-p,--page}'[Page of the document to be shown]:page: ' \
+  '--presentation[Start the document in presentation mode]' \
+  '--unique[Unique instance control]' \
+  "*:Okular documents:_files -g '*.(#i)($extns)(-.)'"
Index: Completion/X/Command/_pdftk
===================================================================
RCS file: Completion/X/Command/_pdftk
diff -N Completion/X/Command/_pdftk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/X/Command/_pdftk	8 Jan 2011 20:52:48 -0000
@@ -0,0 +1,63 @@
+#compdef pdftk
+
+_pdfwithhandle()
+{
+    compset -P '(#I)[A-Z]='
+    _files "$@" -g '(#i)*.pdf'
+}
+
+local expl
+local -a opts operations
+
+opts=(output encrypt_40bit encrypt_128bit allow owner_pw user_pw flatten
+	compress uncompress keep_first_id keep_final_id drop_xfa verbose
+	dont_ask do_ask)
+operations=(cat attach_files unpack_files burst fill_form background stamp
+	generate_fdf multibackground multistamp dump_data dump_data_fields
+	update_info)
+
+case $words[CURRENT-1] in
+    ((input|owner|user)_pw)
+	_message "password, or PROMPT"
+	;;
+
+    (allow)
+	#_description permissions expl "permission"
+	#compadd $expl \
+	_values -s , permissions \
+	    Printing DegradedPrinting ModifyContents Assembly CopyContents \
+	    ScreenReaders ModifyAnnotations FillIn AllFeatures
+	;;
+
+    (attach_files)
+	_files "$@"
+	;;
+
+    (fill_form)
+	_description files expl 'FDF and XFDF files'
+	_files "$@" $expl -g '(#i)*.(fdf|xfdf)'
+	;;
+
+    ((multibackground|background|stamp|multistamp|output))
+	_description files expl 'PDF files'
+	_files "$@" $expl -g '(#i)*.pdf'
+	;;
+
+    (update_info)
+	_files
+	;;
+
+    (*)
+	false
+	;;
+esac && return 0
+
+if [[ -n $words[(r)(${(j:|:)operations})] ]]; then
+    _description options expl "options"
+    compadd $@ $expl $opts
+else
+    _tags files operations
+    _alternative \
+	'files:PDF files:_pdfwithhandle' \
+	"operations:operations:($operations)"
+fi
Index: Completion/X/Command/_vnc
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_vnc,v
retrieving revision 1.6
diff -p -u -r1.6 _vnc
--- Completion/X/Command/_vnc	16 Jun 2005 23:12:11 -0000	1.6
+++ Completion/X/Command/_vnc	8 Jan 2011 20:52:48 -0000
@@ -25,6 +25,7 @@ case $service in
       '-depth:depth' \
       '-passwd:file:_files' \
       '(1)-listen:display number' \
+      '-via:host:_hosts' \
       '(-listen)1::display:_x_display'
   ;;
 esac
Index: Completion/X/Command/_xrandr
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_xrandr,v
retrieving revision 1.2
diff -p -u -r1.2 _xrandr
--- Completion/X/Command/_xrandr	24 Jun 2008 23:00:45 -0000	1.2
+++ Completion/X/Command/_xrandr	8 Jan 2011 20:52:48 -0000
@@ -1,4 +1,11 @@
 #compdef xrandr
+local context state line
+typeset -A opt_args
+local outputs modes expl
+
+# User configurable. TODO -- styles?
+outputs=(LVDS1 TV1 VGA1)
+modes=(1280x800 1024x768 800x600 640x480)
 
 _arguments \
   '(-d -display)'{-d,-display}':X display:_x_display' \
@@ -6,28 +13,50 @@ _arguments \
   '(-o --orientation)'{-o,--orientation}':rotation:(normal inverted left right 0 1 2 3)' \
   '(-q --query)'{-q,--query}'[display current state]' \
   '(-s --size)'{-s,--size}':size:' \
-  '(-r --rate --refresh)'{-r,--rate,--refresh}':target refresh rate:' \
+  '(-r --rate --refresh)'{*-r,*--rate,*--refresh}':target refresh rate:' \
   '(-v --version)'{-v,--version}'[display version]' \
   '-x[reflect across X axis]' \
   '-y[reflect across Y axis]' \
   '--screen:X screen number' \
   '--verbose[be more verbose]' \
   '--dryrun' \
+  '--nograb' \
   '(--prop --properties)'{--prop,--properties}'[display the contents of properties for each output]' \
   '--fb:size:' \
   '--fbmm:size:' \
   '--dpi:dpi:' \
-  '--output:output to reconfigure:' \
-  '--auto' \
-  '--mode:mode:' \
-  '--preferred' \
-  '--pos:position:' \
-  '--reflect:axes:(normal x y xy)' \
-  '--rotate:rotation:(normal inverted left right)' \
-  '--left-of:output' \
-  '--right-of:output' \
-  '--above:output' \
-  '--below:output' \
-  '--same-as:output' \
-  '--off[disable the output]' \
-  '--crtc:crtc to use:'
+  "*--output:output to reconfigure:($outputs)" \
+  '*--auto' \
+  "*--mode:mode:($modes)" \
+  '*--preferred' \
+  '*--pos:position:' \
+  '*--reflect:axes:(normal x y xy)' \
+  '*--rotate:rotation:(normal inverted left right)' \
+  "*--left-of:relative position to:($outputs)" \
+  "*--right-of:relative position to:($outputs)" \
+  "*--above:relative position to:($outputs)" \
+  "*--below:relative position to:($outputs)" \
+  "*--same-as:relative position to:($outputs)" \
+  '*--set:property:(Backlight scaling\ mode):value:->value' \
+  '*--scale:output scaling:' \
+  '*--transform:transformation matrix:' \
+  '*--off[disable the output]' \
+  '*--crtc:crtc to use:' \
+  '*--panning:panning:' \
+  '*--gamma:r\:g\:b:' \
+  '*--primary' \
+  '--noprimary' \
+  '*--newmode:name: :clock MHz: :hdisp: :hsync-start: :hsync-end: :htotal: :vdisp: :vsync-start: :vsync-end: :vtotal:' \
+  '*--rmmode:Mode name:' \
+  "*--addmode:output:($outputs):name:" \
+  "*--delmode:output:($outputs):name:" \
+  && return 0
+
+if [[ $state == value ]]; then
+    case $words[CURRENT-1] in
+	(scaling* mode)
+	    _description value expl "output property 'scaling mode'"
+	    compadd "$@" "$expl[@]" None Full Center Full\ aspect && return 0
+	    ;;
+    esac
+fi
 

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author