zsh-workers
 help / color / mirror / code / Atom feed
* Various completion contributions
@ 2011-01-08  1:42 gi1242+zsh
  2011-01-08 21:03 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: gi1242+zsh @ 2011-01-08  1:42 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2443 bytes --]

Hi All,

Let me start by thanking the wonderful wonderful zsh devs! I've been
using tcsh for the last 10 years, and recently switched over to zsh. I'm
completely awestruck! Thanks a ton.

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).

Here's a brief description of the changes:

    _gv		Added --monochrome, and options for --orientation

    _lp		Added support for completion of printer options (e.g.
		after lpr -o), and values (as provided by lpoptions).

    _modultils	Added caching for module names. Added -i, --ignore-*
		options. Restricted module names to those ending in *.o
		or *.ko (otherwise too many false positives were
		generated on my system). I'm not sure if *.o is
		necessary. [Also -- some zsh guru should look at my
		caching code. If you put it in the "standard" form, I'll
		use it in future]

    _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)

    _pdftk	New completion file

    _pgrep	New completion file (which I downloaded from the mailing
		list archives). I guess it's pointless to attach here.
		However, the completion file is quite good, and it might
		be helpful to new users if it was distributed by
		default.

    _subversion	Added caching support. (Completion of svn is quite quite
		slow by default. This makes things a little faster,
		though things are still quite slow...) [I would call the
		changes I made here an "ugly hack". If someone knows a
		better way to speed this up, please let me know]

    _tex	New completion file

    _unison	New completion file

    _vnc	Added -via option

    _wpa_cli	New completion file

    _xournal	New completion file (only completes filenames).

    _xrandr	Added new options. Also made some options repeatable
		(e.g. --output). Completed values for displays, modes,
		--set and properties. (I took the completion values from
		my system. One may want to make these user configurable
		styles instead).

Thanks,

GI

-- 
The 10 Commandments of DOS:
6. Thou shall edit and shuffle the sacred lines of CONFIG.SYS and
AUTOEXEC.BAT until DOS functions adequately for the likes of you. Giving
up in disgust is not allowed.

[-- Attachment #2: _gv --]
[-- Type: text/plain, Size: 1309 bytes --]

#compdef gv

_arguments \
  '-geometry:geometry:_x_geometry' \
  '(--nosafer)--safer' \
  '(--safer)--nosafer' \
  '(--noquiet)--quiet' \
  '(--quiet)--noquiet' \
  '(--nocenter)--center' \
  '(--center)--nocenter' \
  '(--noswap)--swap' \
  '(--swap)--noswap' \
  '(--noantialias)--antialias' \
  '(--antialias)--noantialias' \
  '(--nodsc)--dsc' \
  '(--dsc)--nodsc' \
  '(--noeof)--eof' \
  '(--eof)--noeof' \
  '(--nopixmap)--pixmap' \
  '(--pixmap)--nopixmap' \
  '(--nowatch)--watch' \
  '(--watch)--nowatch' \
  '(--noresize)--resize' \
  '(--resize)--noresize' \
  '(--monochrome --color)--grayscale' \
  '(--grayscale --color)--monochrome' \
  '(--landscape --seascape --upsidedown)--portrait' \
  '(--portrait --seascape --upsidedown)--landscape' \
  '(--portrait --landscape --upsidedown)--seascape' \
  '(--portrait --landscape --seascape)--upsidedown' \
  --{help,spartan} \
  -{h,v} \
  '--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:(landscape seascape upsidedown portrait)' \
  '--scale=:scale entry:' \
  '--scalebase=:scale base:' \
  '--ad=:resource file:_files' \
  '--style=:resource file:_files' \
  '*:file: _pspdf -z'

[-- Attachment #3: _lp --]
[-- Type: text/plain, Size: 6356 bytes --]

#compdef lp lpr lpq lprm lpoptions lpstat

local expl ret=1 printer list disp strs shown

function _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
}

function _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)

  _lp_get_printer
  [[ -n "$printer" ]] && printer=(-p $printer)

  # 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
      eq_suffix=(-S '=')
    fi

    _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
}

function _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
    _message 'no print jobs'
  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

[-- Attachment #4: _modutils --]
[-- Type: text/plain, Size: 5137 bytes --]

#compdef lsmod modinfo modprobe rmmod insmod

function _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]'
)

case "$service" in
  lsmod) _arguments -s "$args[@]" && return ;;
  
  modinfo)
    _arguments -s -C "$args[@]" \
      '(-)'{-a,--author}"[display the module's author]" \
      '(-)'{-d,--description}"[display the module's description]" \
      '(-)'{-l,--license}"[display the module's license]" \
      '(-)'{-n,--filename}"[display the module's filename]" \
      '(-)'{-p,--parameters}'[display the typed parameters that a module may support]' \
      '(-)'{-F,--field}"[display only selected module's information]:module_field:(
        alias author depends description filename license parm)" \
      '(-)-k[use modules from a different kernel version]:kernel_version:(
        $(echo $modules_dir/*(/\:t)))' \
      '1:module file:->all_modules' && ret=0
  ;;

  modprobe)
    ign='-h --help -V --version -c --showconfig'
    _arguments -s -C "$args[@]" \
      "(-a --all $ign)"{-a,--all}'[load all matching modules]' \
      '(-)'{-c,--showconfig}'[show current configuration]' \
      "(-d --debug $ign)"{-d,--debug}'[print debug info]' \
      "(-k --autoclean $ign)"{-k,--autoclean}'[set autoclean]' \
      "(-n --show $ign)"{-n,--show}"[don't actually perform action]" \
      "(-q --quiet $ign)"{-q,--quiet}"[don't complain about insmod failures]" \
      "(-s --syslog $ign)"{-s,--syslog}'[report via syslog instead of stderr]' \
      "(* -t --type $ign)"{-t,--type}'[module type]:module type' \
      "(-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
      
      [[ -n $state ]] && (( $+opt_args[-r] )) && state=loaded_modules        
  ;;

  rmmod)
    _arguments -s -C "$args[@]" \
      '(-a --all)'{-a,--all}'[remove all unused autocleanable modules]' \
      '(-e --persist)'{-e,--persist}'[save persistent data]' \
      '(-r --stacks)'{-r,--stacks}'[remove a module stack]' \
      '(-s --syslog)'{-s,--syslog}'[output to syslog]' \
      '(-v --verbose)'{-v,--verbose}'[be verbose]' \
      '*:loaded module:->loaded_modules' && ret=0
  ;;

  insmod)
    _arguments \
      '1:module file:_files' \
      '*:module parameters:' && ret=0
  ;;
esac 

case "$state" in
  loaded_modules|loadable_modules)
    if [[ -r /proc/modules ]]; then
     loaded_modules=(${${(f)"$(</proc/modules)"}%% *})
    elif [[ -x /sbin/lsmod ]]; then
     loaded_modules=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *})
    else
     return 1
    fi

    if [[ $state = loaded_modules ]]; then
        _wanted modules expl 'loaded module' compadd -a loaded_modules && return
        return ret
    fi
  ;&

  all_modules)
    local kver
    integer kver_idx
    if (( kver_idx=${words[(I)-k]} )); then
      kver=${words[kver_idx+1]}
    else
      kver=$(uname -r)
    fi
    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//_/-}})} )
    fi

    _tags files modules
    while _tags; do
      _requested files expl "module file"  _files -g '*.ko' && ret=0
      _requested modules expl module compadd -a modules && ret=0
    done
  ;;

  params)
    if compset -P '*='; then
      _message -e value 'parameter value'
    else
      local params
      params=( ${${(M)${(f)"$(_call_program module_parameter modinfo "$words[2]" 2>/dev/null)"}:#parm:*}##parm:[[:space:]]##} )
      if [[ $#params -eq 0 ]]; then
        _message -e parameter "This modules doesn't have parameters"
      else
        typeset -A val_args

        _values -S = -C -w 'module parameter' \
          ${${${(M)params:#*(:bool|\(bool\))}/:/[}/(bool| \(bool\))/]} \
          ${^${params:#*(:bool|\(bool\))}/:/[}"]:auto added argument: " && ret=0
      fi
    fi
  ;;
esac

return ret

[-- Attachment #5: _okular --]
[-- Type: text/plain, Size: 334 bytes --]

#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)(-.)'"

[-- Attachment #6: _pdftk --]
[-- Type: text/plain, Size: 1378 bytes --]

#compdef pdftk

function _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

[-- Attachment #7: _pgrep --]
[-- Type: text/plain, Size: 2182 bytes --]

#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

[-- Attachment #8: _subversion --]
[-- Type: text/plain, Size: 9919 bytes --]

#compdef svn svnadmin svnadmin-static=svnadmin

_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]' \
    '1: :->cmds' \
    '*:: :->args' && ret=0

  if [[ -n $state ]] && (( ! $+_svn_cmds )); then
    typeset -gHA _svn_cmds
    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
    cmds)
      _wanted commands expl 'svn command' _svn_commands && ret=0
    ;;
    args)
      local cmd args usage
      typeset -gHA _cache_svn_status _cache_svn_mtime

      cmd="${${(k)_svn_cmds[(R)*:$words[1]:*]}:-${(k)_svn_cmds[(i):$words[1]:]}}"
      if (( $#cmd )); then
        curcontext="${curcontext%:*:*}:svn-${cmd}:"

	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)
            args+=(
              '*:file:_files -g "*(^e:_svn_controlled:)"'
            )
          ;;
          (commit)
            args=(
	      ${args/(#b)(*--file*):arg:/$match[1]:file:_files}
              '*:file:_files -g "*(e:_svn_status:)"'
            )
          ;;
          (delete)
            args+=(
              '*:file:_files -g ".svn(/e:_svn_deletedfiles:)"'
            )
          ;;
          (diff)
            args+=(
	      '*: : _alternative "files:file:_files -g \*\(e:_svn_status:\)" "urls:URL:_svn_urls"'
	    )
          ;;
          (help)
            args+=(
              '*::sub command:_svn_commands'
            )
	  ;;
	  (import)
	    args+=(
		'1:project directory or import location: _alternative "files:file:_files" "urls:URL:_svn_urls"'
		'2:import location: _alternative "files:file:_files" "urls:URL:_svn_urls"'
	    )
          ;;
          (log)
            args+=(
              '1: : _alternative "files:file:_files -g \*\(e:_svn_controlled:\)" "urls:URL:_svn_urls"'
	      '*:file:_files -g "*(e:_svn_controlled:)"'
            )
          ;;
	  (propget|propedit)
	    args+=(
		'1:property name:_svn_props'
		'2:target: _alternative "files:file:_files" "urls:URL:_svn_urls"'
	    )
	  ;;
	  (propset)
	    args=(
	    ':propname:(svn:ignore svn:keywords svn:executable svn:eol-style svn:mime-type svn:externals svn:needs-lock)'
	    ${args/(#b)(*--file*):arg:/$match[1]:file:_files}
	    '*:path or url: _alternative "files:file:_files" "urls:URL:_svn_urls"'
	    )
	  ;;
          (resolved)
            args+=(
              '*:file:_files -g "*(e:_svn_conflicts:)"'
            )
          ;;
          (revert)
            args+=(
              '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"'
            )
          ;;
          (*)
            case $usage in
              *(SRC|DST|TARGET|URL*PATH)*)
                args+=(
	          '*: : _alternative "files:file:_files" "urls:URL:_svn_urls"'
	        )
	      ;;
              *URL*) args+=( ':URL:_svn_urls' ) ;;
              *PATH*) args+=( '*:file:_files' ) ;;
            esac
          ;;
        esac

        _arguments "$args[@]" && ret=0

      else
        _message "unknown svn command: $words[1]"
      fi
    ;;
  esac

  return ret
}

_svnadmin () {
  local curcontext="$curcontext" state line ret=1

  _arguments -C \
    '(-)--help[print help information]' \
    '(- *)--version[print client version information]' \
    '1: :->cmds' \
    '*:: :->args' && ret=0

  if [[ -n $state ]] && (( ! $+_svnadmin_cmds )); then
    typeset -gHA _svnadmin_cmds
    _svnadmin_cmds=(
      ${=${(f)${${"$(LC_ALL=C _call_program commands svnadmin help)"#l#*Available subcommands:}}}/(#s)[[:space:]]#(#b)([-a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
    )
  fi

  case $state in
    cmds)
      _wanted commands expl 'svnadmin command' _svnadmin_commands && ret=0
    ;;
    args)
      local cmd args usage

      cmd="${${(k)_svnadmin_cmds[(R)*:$words[1]:*]}:-${(k)_svnadmin_cmds[(i):$words[1]:]}}"
      if (( $#cmd )); then
        curcontext="${curcontext%:*:*}:svnadmin-${cmd}:"

        usage=${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $cmd)"}:#$cmd: usage:*}#$cmd: usage: svnadmin $cmd }
        args=(
          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin 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 [[ $usage == *REPOS_PATH* ]]; then
          args+=( ":path:_files -/" )
        elif [[ $cmd = help ]]; then
          args+=( "*:subcommand:_svnadmin_commands" )
        fi

        _arguments "$args[@]" && ret=0
      else
        _message "unknown svnadmin command: $words[1]"
      fi
    ;;
  esac

  return ret
}

(( $+functions[_svn_controlled] )) ||
_svn_controlled() {
  [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]]
}

(( $+functions[_svn_conflicts] )) ||
_svn_conflicts() {
  [ -n $REPLY.(mine|r<->)(N[1]) ]
}

(( $+functions[_svn_deletedfiles] )) ||
_svn_deletedfiles() {
  # Typical usage would be _files -g '.svn(/e:_svn_deletedfiles:)'
  local cont controlled
  reply=( )
  [[ $REPLY = (*/|).svn ]] || return
  controlled=( $REPLY/text-base/*.svn-base(N:r:t) )
  for cont in ${controlled}; do
    [[ -e $REPLY:h/$cont ]] || reply+=( ${REPLY%.svn}$cont )
  done
}

(( $+functions[_svn_status] )) ||
_svn_status() {
  local dir=$REPLY:h
  local pat="${1:-([ADMR~]|?M)}"

  zmodload -F zsh/stat b:zstat 2>/dev/null
  local key="$(zstat +device $dir):$(zstat +inode $dir)"
  local mtime="$(zstat +mtime $dir/.svn/entries)"

  if (( ! $+_cache_svn_status[$key] || _cache_svn_mtime[$key] != mtime )); then
    _cache_svn_status[$key]="$(_call_program files svn status -N $dir)"
    _cache_svn_mtime[$key]="$mtime"
  fi

  (( ${(M)#${(f)_cache_svn_status[$key]}:#(#s)${~pat}*$REPLY} ))
}

(( $+functions[_svn_remote_paths] )) ||
_svn_remote_paths() {
  local expl remfiles remdispf remdispd suf ret=1 pfx='\^/' sub='^/'

  # prefix must match a valid repository path format, either standard style
  # schema://host/path/.. or ^/path/.. specifying a path relative to the
  # root of the working directory repository.  In the second form, allow the
  # leading '^' be escaped in case the user has the extendedglob option set.
  [[ -prefix *://*/ ]] ||
  [[ -f .svn/entries && ( -prefix '^/' || -prefix '\^/' ) ]] ||
  return 1

  # return if remote access is not permitted
  zstyle -T ":completion:${curcontext}:" remote-access || return 1

  remfiles=( ${(f)"$(svn list $IPREFIX${${PREFIX%%[^/]#}/#$pfx/$sub} 2>/dev/null)"} )
  (( $? == 0 )) || return 1

  # you might consider trying to return early if $#remfiles is zero,
  # but for whatever reason remfiles will always contain at least a
  # single empty string; that case is handled correctly below.

  compset -P '*/'
  compset -S '/*' || suf=file
  remdispf=(${remfiles:#*/})
  remdispd=(${(M)remfiles:#*/})
  _tags files
  while _tags; do
    while _next_label files expl ${suf:-directory}; do
      # add files, unless there is a '/' immediately to the right
      [[ -n $suf ]] &&
      compadd -S ' ' -q "$@" "$expl[@]" -d remdispf $remdispf && ret=0
      # add directories; use empty suffix if there is a '/' immediately to the right
      compadd -S "${suf:+/}" -q "$@" "$expl[@]" -d remdispd ${remdispd%/} && ret=0
    done
    (( ret )) || return 0
  done

  return 1
}

(( $+functions[_svn_urls] )) ||
_svn_urls() {
  local urlsch expl ret=1

  # first try completing a remote path; if successful, we are all done..
  _svn_remote_paths && return 0

  # allow configuring svn repository locations using the 'urls' zstyle.
  # always attempt completion of these because then matcher-list styles
  # which do substring matching will work correctly.
  _urls -S/ && ret=0

  if [[ ! -prefix *://? ]] ; then
    zstyle -a ":completion:${curcontext}:" url-schemas urlsch \
     || urlsch=( file:// http:// https:// svn:// svn+ssh:// )
    
    if (( $#urlsch )) ; then
      compset -S '[^:]*'
      _wanted url-schemas expl 'URL schema' compadd -S '' - $urlsch[@] && ret=0
    fi
  fi

  return ret
}

(( $+functions[_svn_commands] )) ||
_svn_commands() {
  compadd "$@" -k _svn_cmds || compadd "$@" ${(s.:.)_svn_cmds}
}

(( $+functions[_svnadmin_command] )) ||
_svnadmin_commands() {
  compadd "$@" -k _svnadmin_cmds || compadd "$@" ${(s.:.)_svnadmin_cmds}
}

(( $+functions[_svn_props] )) ||
_svn_props() {
  local properties

  properties=( ${${(M)${(f)"$(svn proplist 2>/dev/null)"}:#  [^ ]*}#  } )
  compadd "$@" -a properties && return 0
}

_subversion () {
  case $service in
    (svn) _svn "$@" ;;
    (svnadmin) _svnadmin "$@" ;;
  esac
}

_svn_caching_policy() {
  # Rebuild every week
  local -a oldp

  oldp=( "$1"(Nmw+1) )
  (( $#oldp ))
}


_subversion "$@"

[-- Attachment #9: _tex --]
[-- Type: text/plain, Size: 1877 bytes --]

#compdef tex latex pdftex pdflatex

_arguments : \
    '-enc[enable encTeX extensions]' \
    '(-no-file-line-error -file-line-error)'{-no,}'-file-line-error[enable/disable file\:line\:error style messages]' \
    '-fmt=-[use FMTNAME instead of program name or a %& line]:FMTNAME:' \
    '-halt-on-error[stop processing at the first error]' \
    '-ini[be initex, for dumping formats]' \
    '-interaction[set interaction mode]:STRING:(batchmode nonstopmode  scrollmode errorstopmode)' \
    '-ipc[send DVI output to a socket as well as the usual output file]' \
    '-ipc-start[as -ipc, and also start the server at the other end]' \
    '-jobname=-[set the job name]:STRING:' \
    '-kpathsea-debug=-[set path searching debugging flags according to the bits of NUMBER]:NUMBER:' \
    '(-no-mktex -mktex)'{-no,}'-mktex=-[enable/disable mktexFMT generation]:FMT:(tex tfm)' \
    '-mltex[enable MLTeX extensions]' \
    '-output-comment=-[DVI file comment]:STRING:' \
    '-output-directory=-[directory to write files to]:DIR:' \
    '(-no-parse-first-line -parse-first-line)'{-no,}'-parse-first-line[disable/enable parsing of the first line of the input file]' \
    '-progname=-[set program (and fmt) name]:STRING:' \
    '-recorder[enable filename recorder]' \
    '(-no-shell-escape -shell-escape)'{-no,}-shell-escape'[enable/disable \\write18{SHELL COMMAND}]' \
    '-shell-restricted[enable restricted \\write18]' \
    '-src-specials[insert source specials into the DVI file]' \
    '-src-specials=-[insert source specials in certain places of the DVI file]:WHERE:_values -s , WHERE cr display hbox math par parend vbox' \
    '-translate-file=-[use the TCX file TCXNAME]:TCXNAME:' \
    '-8bit[make all characters printable by default]' \
    '-help[display this help and exit]' \
    '-version[output version information and exit]' \
    '*:TeX file:_files -g "*.tex"'

[-- Attachment #10: _unison --]
[-- Type: text/plain, Size: 5516 bytes --]

#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

[-- Attachment #11: _vnc --]
[-- Type: text/plain, Size: 931 bytes --]

#compdef vncserver vncviewer xvncviewer xtightvncviewer xvnc4viewer

local displays args
displays=( ~/.vnc/$HOST:<->.pid(N:r:t:s/$HOST//) )
displays=( \\${^displays} ) 

case $service in
  vncserver)
    # currently lacking Xvnc arguments
    _arguments \
      - start \
	'-name:desktop name:_x_name' \
	'-geometry:geometry:(1600x1200 1280x1024 1152x864 1024x768 800x600 640x480)' \
	'-depth:pixel depth:(8 16 24 32)' \
	'-pixelformat:pixel format' \
	'1:: :_guard "(|:[0-9]#)" "display number"' \
      - kill \
	"-kill:display number:($displays)" \
      - help \
	'-help'
  ;;
  *vncviewer) 
    _xt_arguments -shared -viewonly -fullscreen -bgr233 -owncmap -truecolour \
      '-encodings:encodings:_values -s " " encoding copyrect hextile corre rre raw' \
      '-depth:depth' \
      '-passwd:file:_files' \
      '(1)-listen:display number' \
      '-via:host:_hosts' \
      '(-listen)1::display:_x_display'
  ;;
esac
    

[-- Attachment #12: _wpa_cli --]
[-- Type: text/plain, Size: 825 bytes --]

#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)'

[-- Attachment #13: _xournal --]
[-- Type: text/plain, Size: 126 bytes --]

#compdef xournal

local expl

_description files expl 'PDF and Xournal files'
_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'

[-- Attachment #14: _xrandr --]
[-- Type: text/plain, Size: 2137 bytes --]

#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' \
  '-help[display help]' \
  '(-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:' \
  '(-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:($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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Various completion contributions
  2011-01-08  1:42 Various completion contributions gi1242+zsh
@ 2011-01-08 21:03 ` Peter Stephenson
  2011-01-16  2:48   ` gi1242+zsh
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2011-01-08 21:03 UTC (permalink / raw)
  To: gi1242+zsh, zsh-workers

On Fri, 7 Jan 2011 20:42:15 -0500
gi1242+zsh@gmail.com 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@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Various completion contributions
  2011-01-08 21:03 ` Peter Stephenson
@ 2011-01-16  2:48   ` gi1242+zsh
  2011-01-16 19:37     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: gi1242+zsh @ 2011-01-16  2:48 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

On Sat, Jan 08, 2011 at 09:03:12PM +0000, Peter Stephenson wrote:

> On Fri, 7 Jan 2011 20:42:15 -0500 gi1242+zsh@gmail.com 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,

Thanks for letting me know. I've made a couple of changes following your
suggestions, and have attached a diff this time.

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

That only completes file types. I'd remove it and replace it with the
version attached (in Completion/Unix/Command instead).

>>     _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).

Sorry. _xournal should go in Completion/X/Command.

I did some "git trickery" to try and generate the diffs. If they don't
work, I can regenerate by hand and resend. Let me know,

Thanks,

GI

-- 
If we don't succeed, we run the risk of failure. --George W. Bush

[-- Attachment #2: zsh-lp --]
[-- Type: text/plain, Size: 7840 bytes --]

diff --git a/Completion/Unix/Command/_lp b/Completion/Unix/Command/_lp
index e6bff64..5d46a75 100644
--- a/Completion/Unix/Command/_lp
+++ b/Completion/Unix/Command/_lp
@@ -1,7 +1,5 @@
 #compdef lp lpr lpq lprm lpoptions lpstat
 
-local expl ret=1 printer list disp strs shown
-
 _lp_get_printer()
 {
   # No reason to call _lp_get_printer when service == lpstat. Others matched
@@ -22,6 +20,7 @@ _lp_get_printer()
 
 _lp_job_options()
 {
+  local expl printer
   local -a lopts_with_args lopts_no_args
 
   # Generic options (from lp manual page)
@@ -84,6 +83,9 @@ _lp_job_options()
 
 _lp_list_jobs()
 {
+  local ret=1 printer shown
+  local -a list disp strs
+
   _lp_get_printer
   [[ -n "$printer" ]] && printer=(-P $printer)
 
@@ -125,95 +127,101 @@ _lp_list_jobs()
   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
+
+_lp()
+{
+  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
+}
+
+_lp "$@"
diff --git a/Completion/Unix/Command/_xournal b/Completion/Unix/Command/_xournal
deleted file mode 100644
index 066ef55..0000000
--- a/Completion/Unix/Command/_xournal
+++ /dev/null
@@ -1,6 +0,0 @@
-#compdef xournal
-
-local expl
-
-_description files expl 'PDF and Xournal files'
-_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'
diff --git a/Completion/Unix/Type/_tex b/Completion/Unix/Type/_tex
deleted file mode 100644
index 3c16dca..0000000
--- a/Completion/Unix/Type/_tex
+++ /dev/null
@@ -1,6 +0,0 @@
-#compdef tex latex slitex pdflatex jadetex pdfjadetex xetex=tex xelatex=latex latexmk
-
-local expl
-
-_description files expl 'TeX or LaTeX file'
-_files "$@" "$expl[@]" -g '*.(tex|TEX|texinfo|texi)(-.)'

[-- Attachment #3: zsh-xournal-tex --]
[-- Type: text/plain, Size: 2496 bytes --]

diff --git a/Completion/Unix/Command/_tex b/Completion/Unix/Command/_tex
new file mode 100644
index 0000000..9943fe1
--- /dev/null
+++ b/Completion/Unix/Command/_tex
@@ -0,0 +1,29 @@
+#compdef tex latex slitex pdftex pdflatex jadetex pdfjadetex xetex=tex xelatex=latex latexmk
+
+_arguments : \
+    '-enc[enable encTeX extensions]' \
+    '(-no-file-line-error -file-line-error)'{-no,}'-file-line-error[enable/disable file\:line\:error style messages]' \
+    '-fmt=-[use FMTNAME instead of program name or a %& line]:FMTNAME:' \
+    '-halt-on-error[stop processing at the first error]' \
+    '-ini[be initex, for dumping formats]' \
+    '-interaction[set interaction mode]:STRING:(batchmode nonstopmode  scrollmode errorstopmode)' \
+    '-ipc[send DVI output to a socket as well as the usual output file]' \
+    '-ipc-start[as -ipc, and also start the server at the other end]' \
+    '-jobname=-[set the job name]:STRING:' \
+    '-kpathsea-debug=-[set path searching debugging flags according to the bits of NUMBER]:NUMBER:' \
+    '(-no-mktex -mktex)'{-no,}'-mktex=-[enable/disable mktexFMT generation]:FMT:(tex tfm)' \
+    '-mltex[enable MLTeX extensions]' \
+    '-output-comment=-[DVI file comment]:STRING:' \
+    '-output-directory=-[directory to write files to]:DIR:' \
+    '(-no-parse-first-line -parse-first-line)'{-no,}'-parse-first-line[disable/enable parsing of the first line of the input file]' \
+    '-progname=-[set program (and fmt) name]:STRING:' \
+    '-recorder[enable filename recorder]' \
+    '(-no-shell-escape -shell-escape)'{-no,}-shell-escape'[enable/disable \\write18{SHELL COMMAND}]' \
+    '-shell-restricted[enable restricted \\write18]' \
+    '-src-specials[insert source specials into the DVI file]' \
+    '-src-specials=-[insert source specials in certain places of the DVI file]:WHERE:_values -s , WHERE cr display hbox math par parend vbox' \
+    '-translate-file=-[use the TCX file TCXNAME]:TCXNAME:' \
+    '-8bit[make all characters printable by default]' \
+    '-help[display this help and exit]' \
+    '-version[output version information and exit]' \
+    '*:TeX or LaTeX file:_files -g "*.(tex|TEX|texinfo|texi)(-.)"'
diff --git a/Completion/X/Command/_xournal b/Completion/X/Command/_xournal
new file mode 100644
index 0000000..066ef55
--- /dev/null
+++ b/Completion/X/Command/_xournal
@@ -0,0 +1,6 @@
+#compdef xournal
+
+local expl
+
+_description files expl 'PDF and Xournal files'
+_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Various completion contributions
  2011-01-16  2:48   ` gi1242+zsh
@ 2011-01-16 19:37     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2011-01-16 19:37 UTC (permalink / raw)
  To: gi1242+zsh, zsh-workers

On Sat, 15 Jan 2011 21:48:33 -0500
gi1242+zsh@gmail.com wrote:
> >>     _tex	New completion file
> > 
> > There's already one in Completion/Unix/Type/_tex, so I've ignored
> > this.
> 
> That only completes file types. I'd remove it and replace it with the
> version attached (in Completion/Unix/Command instead).

That's a better place since it handles commands.

Thanks for the changes.

Here's what I'm applying, shouldn't differ materially...

Index: Completion/Unix/Command/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/.distfiles,v
retrieving revision 1.111
diff -p -u -r1.111 .distfiles
--- Completion/Unix/Command/.distfiles	9 Jan 2011 16:57:01 -0000	1.111
+++ Completion/Unix/Command/.distfiles	16 Jan 2011 19:36:37 -0000
@@ -207,6 +207,7 @@ _tardy
 _tcpdump
 _tcptraceroute
 _telnet
+_tex
 _texinfo
 _tidy
 _tiff
@@ -240,7 +241,6 @@ _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.5
diff -p -u -r1.5 _lp
--- Completion/Unix/Command/_lp	9 Jan 2011 16:57:01 -0000	1.5
+++ Completion/Unix/Command/_lp	16 Jan 2011 19:36:37 -0000
@@ -1,7 +1,5 @@
 #compdef lp lpr lpq lprm lpoptions lpstat
 
-local expl ret=1 printer list disp strs shown
-
 _lp_get_printer()
 {
   # No reason to call _lp_get_printer when service == lpstat. Others matched
@@ -22,6 +20,7 @@ _lp_get_printer()
 
 _lp_job_options()
 {
+  local expl printer
   local -a lopts_with_args lopts_no_args
 
   # Generic options (from lp manual page)
@@ -84,6 +83,9 @@ _lp_job_options()
 
 _lp_list_jobs()
 {
+  local ret=1 printer shown
+  local -a list disp strs
+
   _lp_get_printer
   [[ -n "$printer" ]] && printer=(-P $printer)
 
@@ -125,95 +127,101 @@ _lp_list_jobs()
   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
+
+_lp()
+{
+  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
+}
+
+_lp "$@"
Index: Completion/Unix/Command/_tex
===================================================================
RCS file: Completion/Unix/Command/_tex
diff -N Completion/Unix/Command/_tex
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_tex	16 Jan 2011 19:36:37 -0000
@@ -0,0 +1,29 @@
+#compdef tex latex slitex pdftex pdflatex jadetex pdfjadetex xetex=tex xelatex=latex latexmk
+
+_arguments : \
+    '-enc[enable encTeX extensions]' \
+    '(-no-file-line-error -file-line-error)'{-no,}'-file-line-error[enable/disable file\:line\:error style messages]' \
+    '-fmt=-[use FMTNAME instead of program name or a %& line]:FMTNAME:' \
+    '-halt-on-error[stop processing at the first error]' \
+    '-ini[be initex, for dumping formats]' \
+    '-interaction[set interaction mode]:STRING:(batchmode nonstopmode  scrollmode errorstopmode)' \
+    '-ipc[send DVI output to a socket as well as the usual output file]' \
+    '-ipc-start[as -ipc, and also start the server at the other end]' \
+    '-jobname=-[set the job name]:STRING:' \
+    '-kpathsea-debug=-[set path searching debugging flags according to the bits of NUMBER]:NUMBER:' \
+    '(-no-mktex -mktex)'{-no,}'-mktex=-[enable/disable mktexFMT generation]:FMT:(tex tfm)' \
+    '-mltex[enable MLTeX extensions]' \
+    '-output-comment=-[DVI file comment]:STRING:' \
+    '-output-directory=-[directory to write files to]:DIR:' \
+    '(-no-parse-first-line -parse-first-line)'{-no,}'-parse-first-line[disable/enable parsing of the first line of the input file]' \
+    '-progname=-[set program (and fmt) name]:STRING:' \
+    '-recorder[enable filename recorder]' \
+    '(-no-shell-escape -shell-escape)'{-no,}-shell-escape'[enable/disable \\write18{SHELL COMMAND}]' \
+    '-shell-restricted[enable restricted \\write18]' \
+    '-src-specials[insert source specials into the DVI file]' \
+    '-src-specials=-[insert source specials in certain places of the DVI file]:WHERE:_values -s , WHERE cr display hbox math par parend vbox' \
+    '-translate-file=-[use the TCX file TCXNAME]:TCXNAME:' \
+    '-8bit[make all characters printable by default]' \
+    '-help[display this help and exit]' \
+    '-version[output version information and exit]' \
+    '*:TeX or LaTeX file:_files -g "*.(tex|TEX|texinfo|texi)(-.)"'
Index: Completion/Unix/Command/_xournal
===================================================================
RCS file: Completion/Unix/Command/_xournal
diff -N Completion/Unix/Command/_xournal
--- Completion/Unix/Command/_xournal	9 Jan 2011 16:57:01 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
-#compdef xournal
-
-local expl
-
-_description files expl 'PDF and Xournal files'
-_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'
Index: Completion/Unix/Type/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/.distfiles,v
retrieving revision 1.21
diff -p -u -r1.21 .distfiles
--- Completion/Unix/Type/.distfiles	13 Mar 2009 09:59:58 -0000	1.21
+++ Completion/Unix/Type/.distfiles	16 Jan 2011 19:36:37 -0000
@@ -41,7 +41,6 @@ _services
 _signals
 _tar_archive
 _terminals
-_tex
 _texi
 _tilde_files
 _time_zone
Index: Completion/Unix/Type/_tex
===================================================================
RCS file: Completion/Unix/Type/_tex
diff -N Completion/Unix/Type/_tex
--- Completion/Unix/Type/_tex	18 Jul 2009 18:21:35 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
-#compdef tex latex slitex pdflatex jadetex pdfjadetex xetex=tex xelatex=latex latexmk
-
-local expl
-
-_description files expl 'TeX or LaTeX file'
-_files "$@" "$expl[@]" -g '*.(tex|TEX|texinfo|texi)(-.)'
Index: Completion/X/Command/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/.distfiles,v
retrieving revision 1.18
diff -p -u -r1.18 .distfiles
--- Completion/X/Command/.distfiles	9 Jan 2011 16:57:01 -0000	1.18
+++ Completion/X/Command/.distfiles	16 Jan 2011 19:36:37 -0000
@@ -1,16 +1,34 @@
 DISTFILES_SRC='
 .distfiles
-_acroread       _dcop
-_gnome-gv       _gqview         _gv             _kfmclient
-_mozilla        _mplayer        _nautilus
-_nedit          _netscape
+_acroread
+_dcop
+_gnome-gv
+_gqview
+_gv
+_kfmclient
+_mozilla
+_mplayer
+_nautilus
+_nedit
+_netscape
 _okular
 _pdftk
 _qiv            
 _setxkbmap
-_urxvt          _vnc
-_x_utils        _xauth          _xdvi           _xfig           _xloadimage
-_xmodmap        _xpdf           _xscreensaver   _xset           _xterm
-_xv             _xwit
+_urxvtd
+_vnc
+_x_utils
+_xauth
+_xdvi
+_xfigd
+_xloadimage
+_xmodmap
+_xournal
+_xpdf
+_xscreensaver
+_xsetd
+_xterm
+_xv
+_xwit
 _xrandr
 '
Index: Completion/X/Command/_xournal
===================================================================
RCS file: Completion/X/Command/_xournal
diff -N Completion/X/Command/_xournal
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/X/Command/_xournal	16 Jan 2011 19:36:37 -0000
@@ -0,0 +1,6 @@
+#compdef xournal
+
+local expl
+
+_description files expl 'PDF and Xournal files'
+_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-16 20:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-08  1:42 Various completion contributions gi1242+zsh
2011-01-08 21:03 ` Peter Stephenson
2011-01-16  2:48   ` gi1242+zsh
2011-01-16 19:37     ` Peter Stephenson

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).