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

PATCH: more uses of _arguments



In `_xsetroot', `_xfig', the new `_xv', and `_x_options'.

Also some fixes for the places where `_files -g pat' was used with
`_arguments' and making the `_x_*' utility functions use their
arguments (in a not very clean way).

Bye
 Sven

diff -u -r oc/Base/_arguments Completion/Base/_arguments
--- oc/Base/_arguments	Fri Aug 27 12:34:54 1999
+++ Completion/Base/_arguments	Fri Aug 27 14:32:34 1999
@@ -465,18 +465,19 @@
         _description expl option
 	if [[ -n "$sopts" && -n "$PREFIX" && "$PREFIX" = [-+]${~soptseq}[$sopts] ]]; then
 	  if [[ "$PREFIX" = [-+]${~soptseq1} ]]; then
-	    compadd "$expl[@]" -Q \
+	    compadd "$expl[@]" -Q -M 'r:|_=* r:|=*' \
                     -y "( ${(j: :)${(@M)${(@k)opts}:#[-+]?}} ${(j: :)${(@M)${(@k)dopts}:#[-+]?}} ${(j: :)${(@M)${(@k)odopts}:#[-+]?}} )" - \
                     "${PREFIX}${(@k)^opts[(I)${PREFIX[1]}?]#?}" \
 		    "${PREFIX}${(@k)^dopts[(I)${PREFIX[1]}?]#?}" \
 		    "${PREFIX}${(@k)^odopts[(I)${PREFIX[1]}?]#?}" && ret=0
 	  else
-	    # The last option takes an argument in next word.
-	    compadd "$expl[@]" -Q - "${PREFIX}" && ret=0
+	    # The last option takes an argument in the next word.
+	    compadd "$expl[@]" -Q  -M 'r:|_=* r:|=*' - "${PREFIX}" && ret=0
 	  fi
 	else
-          compadd "$expl[@]" -Q - "${(@k)opts}" "${(@k)odopts}" && ret=0
-	  compadd "$expl[@]" -QS '' - "${(@k)dopts}" && ret=0
+          compadd "$expl[@]" -Q -M 'r:|_=* r:|=*' - \
+                  "${(@k)opts}" "${(@k)odopts}" && ret=0
+	  compadd "$expl[@]" -QS '' -M 'r:|_=* r:|=*' - "${(@k)dopts}" && ret=0
         fi
       fi
       [[ $#long -ne 0 &&
@@ -530,7 +531,7 @@
 
     _description expl "$descr"
 
-    if [[ -z "$action" ]]; then
+    if [[ "$action" = \ # ]]; then
 
       # An empty action means that we should just display a message.
 
diff -u -r oc/Pbmplus/_pbmtext Completion/Pbmplus/_pbmtext
--- oc/Pbmplus/_pbmtext	Fri Aug 27 12:35:02 1999
+++ Completion/Pbmplus/_pbmtext	Fri Aug 27 14:18:08 1999
@@ -1,3 +1,3 @@
 #compdef pbmtext
 
-_arguments '-font:font file:_files -g *.(#i)pbm' '*:text:'
+_arguments '-font:font file:_files -g \*.\(\#i\)pbm' '*:text:'
diff -u -r oc/Pbmplus/_pbmtopk Completion/Pbmplus/_pbmtopk
--- oc/Pbmplus/_pbmtopk	Fri Aug 27 12:35:02 1999
+++ Completion/Pbmplus/_pbmtopk	Fri Aug 27 14:18:32 1999
@@ -7,5 +7,5 @@
            '-W:width:' '-H:height:' '-D:depth:' '-I:italic correction:' \
            '-h:horizontal escapement:' '-v:vertical escapement:' \
 	   '-x:x offset:' '-y:y offset:' \
-           ':pk file:_files -g *.(#i)pk' ':tfm file:_files -g *.(#i)tfm' \
+           ':pk file:_files -g \*.\(\#i\)pk' ':tfm file:_files -g \*.\(\#i\)tfm' \
 	   '*:file: _pbm_file'
diff -u -r oc/Pbmplus/_pktopbm Completion/Pbmplus/_pktopbm
--- oc/Pbmplus/_pktopbm	Fri Aug 27 12:35:02 1999
+++ Completion/Pbmplus/_pktopbm	Fri Aug 27 14:18:54 1999
@@ -1,4 +1,4 @@
 #compdef pktopbm
 
-_arguments ':pk file:_files -g *.(#i)pk' '-c:character number:' \
+_arguments ':pk file:_files -g \*.\(\#i\)pk' '-c:character number:' \
            '*:file: _pbm_file'
diff -u -r oc/Pbmplus/_pnmcomp Completion/Pbmplus/_pnmcomp
--- oc/Pbmplus/_pnmcomp	Fri Aug 27 12:35:05 1999
+++ Completion/Pbmplus/_pnmcomp	Fri Aug 27 14:19:16 1999
@@ -1,5 +1,5 @@
 #compdef pnmcomp
 
 _arguments '-invert' '-xoff:x offset:' '-yoff:y offset:' \
-           '-alpha:alpha mask file:_files -g *.(#i)pgm' \
+           '-alpha:alpha mask file:_files -g \*.\(\#i\)pgm' \
 	   ':overlay file:_pbm_file' '*:file: _pbm_file'
diff -u -r oc/Pbmplus/_pnmtoddif Completion/Pbmplus/_pnmtoddif
--- oc/Pbmplus/_pnmtoddif	Fri Aug 27 12:35:05 1999
+++ Completion/Pbmplus/_pnmtoddif	Fri Aug 27 14:19:32 1999
@@ -1,4 +1,4 @@
 #compdef pnmtoddif
 
 _arguments '-resolution:horizontal resolution::vertical resolution:' \
-           ':file: _pbm_file' ':ddif file:_files -g *.(#i)ddif'
+           ':file: _pbm_file' ':ddif file:_files -g \*.\(\#i\)ddif'
diff -u -r oc/Pbmplus/_psidtopgm Completion/Pbmplus/_psidtopgm
--- oc/Pbmplus/_psidtopgm	Fri Aug 27 12:35:06 1999
+++ Completion/Pbmplus/_psidtopgm	Fri Aug 27 14:19:57 1999
@@ -1,4 +1,4 @@
 #compdef psidtopgm
 
 _arguments ':width:' ':height:' ':bits per sample:' \
-           ':postscript file:_files -g *.(#i)(ps|eps)'
+           ':postscript file:_files -g \*.\(\#i\)\(ps\|eps\)'
diff -u -r oc/Pbmplus/_pstopnm Completion/Pbmplus/_pstopnm
--- oc/Pbmplus/_pstopnm	Fri Aug 27 12:35:06 1999
+++ Completion/Pbmplus/_pstopnm	Fri Aug 27 14:20:11 1999
@@ -7,4 +7,4 @@
 	   '-xborder:x border fraction:' '-yborder:y border fraction:' \
 	   '-xmax:maximum width:' '-ymax:maximum height' \
 	   '-xsize:width:' '-ysize:height:' \
-	   ':postscript file:_files -g *.(#i)(ps|eps)'
+	   ':postscript file:_files -g \*.\(\#i\)\(ps\|eps\)'
diff -u -r oc/User/_gdb Completion/User/_gdb
--- oc/User/_gdb	Fri Aug 27 12:35:07 1999
+++ Completion/User/_gdb	Fri Aug 27 14:36:34 1999
@@ -21,9 +21,10 @@
   _files
 elif [[ "$PREFIX" = -* ]]; then
   _description expl option
-  compadd "$expl[@]" -QS '' - symbols\= exec\= se\= core\= command\= \
-                              directory\= cd\= tty\=
-  compadd "$expl[@]" - help h s e c x d nx n quiet q batch fullname f b
+  compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \
+                              -directory\= -cd\= -tty\=
+  compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q -batch \
+                       -fullname -f -b
 else
   prev="$words[CURRENT-1]"
 
diff -u -r oc/User/_gprof Completion/User/_gprof
--- oc/User/_gprof	Fri Aug 27 12:35:09 1999
+++ Completion/User/_gprof	Fri Aug 27 14:36:59 1999
@@ -5,8 +5,8 @@
 	   '-I:directory:_dir_list' \
 	   '-d-:debug level:' '-k:function names: _exec_funcs -p' \
 	   '-m:minimum execution count:' \
-	   ':executable:_files -g *(*)' \
-	   ':profile file:_files -g gmon.*' \
+	   ':executable:_files -g \*\(\*\)' \
+	   ':profile file:_files -g gmon.\*' \
 	   -- -s '(#--[no-] --)' \
            '*=name*:function name: _exec_funcs' \
 	   '*=dirs*:directory:_dir_list'
diff -u -r oc/User/_x_options Completion/User/_x_options
--- oc/User/_x_options	Fri Aug 27 12:35:08 1999
+++ Completion/User/_x_options	Fri Aug 27 15:38:57 1999
@@ -1,12 +1,6 @@
 #compdef -P */X11/*
 
-local expl
-
-# A simple pattern completion, just as an example.
-
-if [ "$words[CURRENT-1]" = "-display" ]; then
-  _x_display
-else
-  _description expl option  
-  compadd "$expl[@]" - -display -name -xrm
-fi
+_arguments \
+  '-display:display:_x_display' \
+  '-geometry:geometry:_x_geometry' \
+  "$@"
diff -u -r oc/User/_xfig Completion/User/_xfig
--- oc/User/_xfig	Fri Aug 27 12:35:08 1999
+++ Completion/User/_xfig	Fri Aug 27 14:17:45 1999
@@ -1,6 +1,55 @@
 #compdef xfig
 
-local expl
-
-_description expl 'xfig file'
-_files "$expl[@]" -g '*.fig'
+_x_options \
+  '-help' \
+  '-Landscape' \
+  '-Portrait' \
+  '-bold:bold font:_x_font' \
+  '-button:button font:_x_font' \
+  '-but_per_row:number of buttons:' \
+  '-cbg:canvas background color:_colors' \
+  '-cfg:canvas foreground color:_colors' \
+  '-debug' \
+  '-depth:visual depth:_x_visdepth' \
+  '-dontswitchcmap' \
+  '-exportlanguage:export language:(box latex epic eepic eepicemu pictex ibmgl eps ps pstex textyl tpic pic mf acad pcx png gif jpeg tiff ppm xbm xpm)' \
+  '-flushleft' \
+  '-iconGeometry:icon geometry:_x_geometry' \
+  '-inches' \
+  '-internalBW:internal border width:' \
+  '-inverse' \
+  '-keyfile:compose key file:_files' \
+  '-latexfonts' \
+  '-left' \
+  '-magnification:magnification factor:' \
+  '-max_image_colors:maximum number of colors:' \
+  '-metric' \
+  '-monochrome' \
+  '-multiple' \
+  '-normal:normal font:_x_font' \
+  '-noscalablefonts' \
+  '-notrack' \
+  '-papersize:output paper size:((Letter\:8.5\"\ x\ 11\" Legal\:8.5\"\ x\ 14\" Ledger\:17\"\ x\ 11\" Tabloid\:11\"\ x\ 17\" A\:8.5\"\ x\ 11\" B\:11\"\ x\ 17\" C\:17\"\ x\ 22\" D\:22\"\ x\ 34\" E\:34\"\ x\ 44\" A4\:21\ cm\ x\ 29.7\ cm A3\:29.7\ cm\ x\ 42\ cm A2\:42\ cm\ x\ 59.4\ cm A1\:59.4\ cm\ x\ 84.1\ cm A0\:84.1\ cm\ x\ 118.9\ cm B%\:18.2\ cm\ x\ 25.7\ cm))' \
+  '-pheight:canvas height:' \
+  '-pwidth:canvas width:' \
+  '-right' \
+  '-scalablefonts' \
+  '-showallbuttons' \
+  '-single' \
+  '-specialtext' \
+  '-spellcheckcommand:program: _command_names -e' \
+  '-startfillstyle:fill style (-1 to 21):' \
+  '-startfontsize:font size (in points):' \
+  '-startgridmode:grid mode:((0\:no\ grid 1\:1/4\ inch\ or\ 5\ mm 2\:1/2\ inch\ or\ 1\ cm 3\:1\ inch\ or\ 2\ cm))' \
+  '-startlatexfont:latex font:' \
+  '-startlinewidth:line width:' \
+  '-startposnmode:positioning mode:((0\:any 1\:1/16\ inch\ or\ 1\ mm 2\:1/4\ inch\ or\ 5\ mm 3\:1/2\ inch\ or\ 1\ cm 4\:1\ inch\ or\ 2\ cm))' \
+  '-startpsfont:postscript font:' \
+  '-starttextstep:text step:' \
+  '-tablet' \
+  '-track' \
+  '-userscale:scale factor:' \
+  '-userunit:unit string:' \
+  '-visual:visual:(TrueColor StaticColor DirectColor StaticGray GrayScale PseudoColor)' \
+  '-zoom:zoom scale:' \
+  '*:xfig file:_files -g \*.\(\#i\)\(\|x\)fig'
diff -u -r oc/User/_xsetroot Completion/User/_xsetroot
--- oc/User/_xsetroot	Fri Aug 27 12:35:09 1999
+++ Completion/User/_xsetroot	Fri Aug 27 14:32:37 1999
@@ -1,22 +1,16 @@
 #compdef xsetroot
 
-local expl
-
-case "$words[CURRENT-1]" in
--cursor_name) _cursors; return;;
--([fb]g|solid)) _colors; return;;
--cursor) _description expl 'cursor file'
-         _files "$expl[@]" -/g '*.(#i)(xbm|curs(|or))'; return;;
--bitmap) _description expl 'bitmap file'
-         _files "$expl[@]" -/g '*.(#i)xbm'; return;;
-esac
-
-if [[ CURRENT -gt 2 && "$words[CURRENT-2]" = -cursor ]]; then
-  _description expl 'cursor mask file'
-  _files "$expl[@]" -/g '*.(#i)(xbm|curs(|or)|mask)'
-else
-  _description expl option
-  compadd "$expl[@]" -M 'm:-=_ r:|_=*' - \
-          -help -def -cursor -cursor_name -bitmap -mod -gray -grey \
-          -fg -bg -rv -solid -name
-fi
+_x_options \
+  '-help' \
+  '-def' \
+  '-cursor:cursor file:_files -g \*.\(\#i\)\(xbm\|curs\(\|or\)\):mask file:_files -g \*.\(\#i\)\(xbm\|curs\(\|or\)\|mask\)' \
+  '-cursor_name:cursor name:_cursors' \
+  '-bitmap:bitmap file:_files -g \*.\(\#i\)xbm' \
+  '-mod:x grid distance (1-16): :y grid distance (1-16):' \
+  '-gray' \
+  '-grey' \
+  '-fg:foreground color:_colors' \
+  '-bg:background color:_colors' \
+  '-rv' \
+  '-solid:screen solid color:_colors' \
+  '-name:root window name:'
diff -u -r oc/X/_x_borderwidth Completion/X/_x_borderwidth
--- oc/X/_x_borderwidth	Fri Aug 27 12:35:09 1999
+++ Completion/X/_x_borderwidth	Fri Aug 27 15:01:48 1999
@@ -1,3 +1,7 @@
 #autoload
 
-_message 'border width'
+if (( $# )); then
+  _message "$2"
+else
+  _message 'border width'
+fi
diff -u -r oc/X/_x_geometry Completion/X/_x_geometry
--- oc/X/_x_geometry	Fri Aug 27 12:35:09 1999
+++ Completion/X/_x_geometry	Fri Aug 27 15:00:47 1999
@@ -1,3 +1,7 @@
 #autoload
 
-_message 'geometry'
+if (( $# )); then
+  _message "$2"
+else
+  _message 'geometry'
+fi
diff -u -r oc/X/_x_locale Completion/X/_x_locale
--- oc/X/_x_locale	Fri Aug 27 12:35:09 1999
+++ Completion/X/_x_locale	Fri Aug 27 15:02:03 1999
@@ -1,3 +1,7 @@
 #autoload
 
-_message 'locale'
+if (( $# )); then
+  _message "$2"
+else
+  _message 'locale'
+fi
diff -u -r oc/X/_x_name Completion/X/_x_name
--- oc/X/_x_name	Fri Aug 27 12:35:09 1999
+++ Completion/X/_x_name	Fri Aug 27 15:02:09 1999
@@ -1,3 +1,7 @@
 #autoload
 
-_message 'name'
+if (( $# )); then
+  _message "$2"
+else
+  _message 'name'
+fi
diff -u -r oc/X/_x_resource Completion/X/_x_resource
--- oc/X/_x_resource	Fri Aug 27 12:35:09 1999
+++ Completion/X/_x_resource	Fri Aug 27 15:02:15 1999
@@ -1,3 +1,7 @@
 #autoload
 
-_message 'resource'
+if (( $# )); then
+  _message "$2"
+else
+  _message 'resource'
+fi
diff -u -r oc/X/_x_selection_timeout Completion/X/_x_selection_timeout
--- oc/X/_x_selection_timeout	Fri Aug 27 12:35:09 1999
+++ Completion/X/_x_selection_timeout	Fri Aug 27 15:02:24 1999
@@ -1,3 +1,7 @@
 #autoload
 
-_message 'selection timeout'
+if (( $# )); then
+  _message "$2"
+else
+  _message 'selection timeout'
+fi
diff -u -r oc/X/_x_title Completion/X/_x_title
--- oc/X/_x_title	Fri Aug 27 12:35:09 1999
+++ Completion/X/_x_title	Fri Aug 27 15:02:30 1999
@@ -1,3 +1,7 @@
 #autoload
 
-_message 'title'
+if (( $# )); then
+  _message "$2"
+else
+  _message 'title'
+fi
diff -u -r oc/X/_xv Completion/X/_xv
--- oc/X/_xv	Fri Aug 27 15:33:54 1999
+++ Completion/X/_xv	Fri Aug 27 15:32:17 1999
@@ -0,0 +1,99 @@
+#compdef xv
+
+_x_options \
+  '-help' \
+  '-fg:foreground color:_colors' \
+  '-bg:background color:_colors' \
+  '-hi:top left shadow color:_colors' \
+  '-lo:bottom right shadow color:_colors' \
+  '-bw:border width:' \
+  '-geometry:geometry:_x_geometry' \
+  '-fixed' '+fixed' \
+  '-expand:expansion factor:' \
+  '-aspect:aspect ratio (e.g. 4:3):' \
+  '-ncols:maximum number of colors used:' \
+  '-rw' '+rw' \
+  '-perfect' '+perfect' \
+  '-owncmap' '+owncmap' \
+  '-stdcmap' '+stdcmap' \
+  '-cecmap' '+cecmap' \
+  '-ninstall' '+ninstall' \
+  '-8' '+8' \
+  '-24' '+24' \
+  '-quick24' \
+  '-slow24' \
+  '-best24' \
+  '-noqcheck' \
+  '-root' '+root' \
+  '-rmode:root display mode:((0\:tiling 1\:integer\ tiling 2\:mirrored\ tiling 3\:integer\ mirrored\ tiling 4\:centered\ tiling 5\:centered\ tiling\ on\ solid\ background 6\:centered\ tiling\ on\ '"'"'warp'"'"'\ background 7\:centered\ tiling\ on\ '"'"'brick'"'"'\ background 8\:symmetrical\ tiling 9\:symmetrical\ mirrored\ tiling))' \
+  '-noresetroot' '+noresetroot' \
+  '-rfg:root foreground color:_colors' \
+  '-rbg:root background color:_colors' \
+  '-max' '+max' \
+  '-maxpect' '+maxpect' \
+  '-quit' '+quit' \
+  '-clear' '+clear' \
+  '-cmap' '+cmap' \
+  '-cgeom:control window geometry:_x_geometry' \
+  '-imap' '+imap' \
+  '-igeom:info window geometry:_x_geometry' \
+  '-cemap' '+cemap' \
+  '-cegeom:color editor window geometry:_x_geometry' \
+  '-cmtmap' '+cmtmap' \
+  '-cmtgeometry:comments window geometry:_x_geometry' \
+  '-tgeometry:text view window geometry:_x_geometry' \
+  '-vsmap' '+vsmap' \
+  '-vsgeometry:visual schauzer geometry:_x_geometry' \
+  '-nopos' '+nopos' \
+  '-dither' '+dither' \
+  '-smooth' '+smooth' \
+  '-raw' '+raw' \
+  '-crop:left border: :top border: :width: :height:' \
+  '-acrop' '+acrop' \
+  '-4x3' '+4x3' \
+  '-hflip' '+hflip' \
+  '-vflip' '+vflip' \
+  '-rotate:rotation angle:(0 90 -90 +90 180 -180 +180 270 -270 +270)' \
+  '-norm' '+norm' \
+  '-hist' '+hist' \
+  '-gamma:gamma value:' \
+  '-cgamma:red gamma value: :green gamma value: :blue gamma value:' \
+  '-preset:default preset (1-4):(1 2 3 4)' \
+  '-mono' '+mono' \
+  '-rv' '+rv' \
+  '-white:'"'"'white'"'"' color:_colors' \
+  '-black:'"'"'black'"'"' color:_colors' \
+  '-wait:seconds to wait:' \
+  '-wloop' '+wloop' \
+  '-random' '+random' \
+  '-loadclear' '+loadclear' \
+  '-nofreecols' '+nofreecols' \
+  '-rgb' '+rgb' \
+  '-hsv' '+hsv' \
+  '-lbrowse' '+lbrowse' \
+  '-nostat' '+nostat' \
+   '-visual:visual:(TrueColor StaticColor DirectColor StaticGray GrayScale PseudoColor)' \
+  '-cursor:cursor character number:' \
+  '-2xlimit' '+2xlimit' \
+  '-nolimits' '+nolimits' \
+  '-close' '+close' \
+  '-iconic' '+iconic' \
+  '-icgeometry:icon geometry:_x_geometry' \
+  '-dir:directory:_files -/' \
+  '-flist:file list file:_files' \
+  '-drift:x movement correction: :y movement correction:' \
+  '-pkludge' \
+  '-mfn:mono spaced font:_x_font' \
+  '-name:window name:_x_name' \
+  '-viewonly' '+viewonly' \
+  '-grabdelay:grab delay (seconds):' '+grabdelay:grab delay (seconds):' \
+  '-poll' '+poll' \
+  '-vsperfect' '+vsperfect' \
+  '-vsdisable' '+vsdisable' \
+  '-gsdev:ghostscript device:' \
+  '-gsres:ghostscript resolution:' \
+  '-gsgeom:ghostscript page size:' \
+  '-nodecor' '+nodecor' \
+  '-RM' \
+  '-DEBUG:debug level:' \
+  '*:picture file:_files -g \*.\(\#i\)\(gif\|jpeg\|tiff\|pbm\|pgm\|ppm\|xbm\|xpm\|ras\(\|t\)\|tga\|rle\|rgb\|bmp\|pcx\|fits\|pm\)'

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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