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

PATCH: update enscript completion



This updates enscript completion for GNU enscript 1.6.6.

Options continue to lack descriptions but are updated. It also now makes
an attempt at completing fonts and formats.

Oliver

diff --git a/Completion/Unix/Command/_enscript b/Completion/Unix/Command/_enscript
index d10acb25f..3e09da5a4 100644
--- a/Completion/Unix/Command/_enscript
+++ b/Completion/Unix/Command/_enscript
@@ -1,9 +1,10 @@
 #compdef enscript
 
-local state context line curcontext="$curcontext" match
+local curcontext="$curcontext" state line match
 typeset -A opt_args
+local -a libpath
 
-_arguments -C -s \
+_arguments -C -s -S \
   '(   -2 --columns)-1' \
   '(-1    --columns)-2' \
   '(-1 -2          )--columns=:columns:' \
@@ -11,14 +12,11 @@ _arguments -C -s \
   '(-a)--pages=:pages:(even odd)' \
   '(--file-align)-A+:align:' \
   '(-A)--file-align=:align:' \
-  '(--header)-b+:page header:' \
-  '(-b)--header=:page header:' \
-  '(--no-header)-B' \
-  '(-B)--no-header' \
+  '(--header -b -B --no-header --lineprinter -l)'{-b+,--header=}':page header:->formats' \
+  '(--header -b -B --no-header --lineprinter -l)'{-B,--no-header} \
   '(--truncate-lines)-c' \
   '(-c)--truncate-lines' \
-  '(--line-numbers)-C-:start line:' \
-  '(-C)--line-numbers=-:start line:' \
+  '(--line-numbers -C)'{-C-,--line-numbers=-}'::start line [1]' \
   '(--printer -d   )-P+:printer name: _printers' \
   '(--printer    -P)-d+:printer name: _printers' \
   '(          -d -P)--printer=:printer name: _printers' \
@@ -26,34 +24,24 @@ _arguments -C -s \
   '*--setpagedevice=:key\:value:' \
   '(--escapes)-e-:escape character:' \
   '(-e)--escapes=-:escape character:' \
-  '(--pretty-print)-E-:input language:->inputlang' \
-  '(-E)--pretty-print=-:input language:->inputlang' \
-  '(--font)-f+:fontname:' \
-  '(-f)--font=:fontname:' \
-  '(--header-font)-F+:fontname:' \
-  '(-F)--header-font=:fontname:' \
+  '(-E --highlight)'{-E-,--highlight=-}':input language:->inputlang' \
+  '(--font -f)'{-f+,--font=}':fontname:->fonts' \
+  '(--header-font -F)'{-F+,--header-font=}':fontname:->fonts' \
   '(--print-anyway)-g' \
   '(-g)--print-anyway' \
   '(--fancy-header)-G' \
-  '(-G)--fancy-header=-:name:' \
+  '(-G)--fancy-header=:header:->headers' \
   '(--no-job-header)-h' \
   '(-h)--no-job-header' \
-  '(--highlight-bars)-H-:lines:' \
-  '(-H)--highlight-bars=-:lines:' \
-  '(--indent)-i+:indent length:' \
-  '(-i)--indent=:indent length:' \
-  '(--filter)-I+:input filter:->commandline' \
-  '(-I)--filter=:input filter:->commandline' \
+  '(--highlight-bars -H)'{-H-,--highlight-bars=-}'::height (lines) [2]' \
+  '(--indent -i)'{-i+,--indent=}':indent width' \
+  '(--filter -I)'{-I+,--filter=}':input filter:_cmdstring' \
   '(--borders)-j' \
   '(-j)--borders' \
-  '(--page-prefeed)-k' \
-  '(-k)--page-prefeed' \
-  '(--no-page-prefeed)-K' \
-  '(-K)--no-page-prefeed' \
-  '(--lineprinter)-l' \
-  '(-l)--lineprinter' \
-  '(--lines-per-page)-L+:lines per page:' \
-  '(-L)--lines-per-page=:lines per page:' \
+  '(-k --page-prefeed -K --no-page-prefeed)'{-k,--page-prefeed} \
+  '!(-k --page-prefeed -K --no-page-prefeed)'{-K,--no-page-prefeed} \
+  '(--lineprinter -l --lines-per-page -L --header -b -B --no-header)'{-l,--lineprinter} \
+  '(--lines-per-page -L --lineprinter -l)'{-L+,--lines-per-page=}':lines per page' \
   '(--mail)-m' \
   '(-m)--mail' \
   '(--media)-M+:media name:(A4)' \
@@ -63,37 +51,30 @@ _arguments -C -s \
   '(         -n -#)--copies=:number of copies:' \
   '(--newline)-N+:newline type:((n\:unix r\:mac))' \
   '(-N)--newline=:newline type:((n\:unix r\:mac))' \
-  '(--output -p   )-o+:output file:' \
-  '(--output    -o)-p+:output file:_files' \
-  '(         -p -o)--output=:output file:_files' \
+  '(-o -p --output -p)'{-o+,-p+,--output=}':output file:_files' \
   '(--missing-characters)-O' \
   '(-O)--missing-characters' \
   '(--quiet --silent)-q' \
   '(-q --silent)--quiet' \
   '(-q --quiet)--silent' \
-  '(--landscape)-r' \
-  '(-r)--landscape' \
-  '(--portrait)-R' \
-  '(-R)--portrait' \
-  '(--baselineskip)-s+:baseline skip:' \
-  '(-s)--baselineskip=:baseline skip:' \
+  '(-r --landscape -R --portrait)'{-r,--landscape} \
+  '(-r --landscape -R --portrait)'{-R,--portrait} \
+  '(--baselineskip -s)'{-s+,--baselineskip=}':baseline skip (PostScript points) [1]' \
   '*-S+:key\:value:' \
   '*--statusdict=:key\:value:' \
   '(--title -t   )-J+:banner title:' \
   '(--title    -J)-t+:banner title:' \
   '(        -t -J)--title=:banner title:' \
-  '(--tabsize)-T+:tabsize:(8)' \
-  '(-T)--tabsize=:tabsize:(8)' \
+  '(--tabsize -T)'{-T+,--tabsize=}':tabsize [8]' \
   '(--underlay)-u-:underlay text:' \
   '(-u)--underlay=-:underlay text:' \
   '(--nup)-U+:pages:(4)' \
   '(-U)--nup=:pages:(4)' \
   '(--verbose)-v' \
   '(-v)--verbose=-:level:' \
-  '(--version)-V' \
-  '(-V)--version' \
-  '(--language)-W+:output language:(PostScript html overstrike rtf)' \
-  '(-W)--language=:output language:(PostScript html overstrike rtf)' \
+  '(- *)'{-V,--version} \
+  '(-w --language)'{-w-,--language=}':output language:(PostScript html overstrike rtf)' \
+  '(-W --option)'{-W-,--option=}':helper option' \
   '(--encoding)-X+:character encoding:(88591 latin1 88592 latin2 88593 latin3 88594 latin4 88595 cyrillic 88597 greek 88599 latin5 885910 latin6 ascii asciifise asciifi asciise asciidkno asciidk asciino ibmpc pc dos mac vms hp8 koi8 ps PS pslatin1 ISOLatin1Encoding)' \
   '(-X)--encoding=:character encoding:(88591 latin1 88592 latin2 88593 latin3 88594 latin4 88595 cyrillic 88597 greek 88599 latin5 885910 latin6 ascii asciifise asciifi asciise asciidkno asciidk asciino ibmpc pc dos mac vms hp8 koi8 ps PS pslatin1 ISOLatin1Encoding)' \
   '(--no-formfeed)-z' \
@@ -101,47 +82,111 @@ _arguments -C -s \
   '(--pass-through)-Z' \
   '(-Z)--pass-through' \
   '--color=-:use color:(false true)' \
+  '--continuous-page-numbers' \
   '--download-font=:fontname:' \
+  '--extended-return-values' \
   '--filter-stdin=:stdin name:(-)' \
+  '--footer=:page footer:->formats' \
   '--h-column-height=:horizontal column height:' \
-  '--help' \
-  '--help-pretty-print' \
-  '--highlight-bar-gray=:gray level:' \
+  '(- *)--help' \
+  '(- *)--help-highlight' \
+  '--highlight-bar-gray=:gray level (0-1):' \
   '--list-media' \
-  '--list-options' \
   '--margins=:left\:right\:top\:bottom:' \
-  '--mark-wrapped-lines=-:wrapped line style:(none plus box arrow)' \
-  '--non-printable-format=:format to visualze non printable characters:(caret octal questionmark space)' \
-  '--nup-xpad=:x-padding:(10)' \
-  '--nup-ypad=:y-padding:(10)' \
+  '--mark-wrapped-lines=-:wrapped line style [none]:(none plus box arrow)' \
+  '--non-printable-format=:rendering of non-printable characters:(caret octal questionmark space)' \
+  '--nup-columnwise' \
+  '--nup-xpad=:x-padding [10]' \
+  '--nup-ypad=:y-padding [10]' \
   '--page-label-format=:page label format:(short long)' \
   '--ps-level=:PostScript language level:(1 2)' \
   '--printer-options=:extra options:' \
   '--rotate-even-pages' \
-  '--slice=:virtical slice number:' \
-  '--style=:highlighting style:' \
+  '--slice=:vertical slice number' \
+  '--style=:highlighting style:(a2ps emacs emacs_verbose ifh msvc)' \
+  '--swap-even-page-margins' \
   '--toc' \
   '--word-wrap' \
-  '--ul-angle=:underlay text'\''s angle:(45)' \
-  '--ul-font=:underlay text'\''s fontname:(Times-Roman200)' \
-  '--ul-gray=:underlay text'\''s gray level:(.8)' \
-  '--ul-position=:underlay text'\''s position:(+0+0 -0-0)' \
-  '--ul-style=:underlay text'\''s style:(outline filled)' \
+  '--ul-angle=:angle' \
+  '--ul-font=:fontname [Times-Roman200]:->fonts' \
+  '--ul-gray=:gray level (0..1) [.8]' \
+  '--ul-position=:position [+0+0 -0-0]' \
+  '--ul-style=:style [outline]:(outline filled)' \
   '*:filename:_files' && return 0
 
 case "$state" in
-commandline)
-  compset -q
-  _normal
+  fonts)
+    if compset -P 1 '*@'; then
+      _message -e size 'pointsize, optionally width/height'
+    else
+      libpath=( {${commands[enscript]:h:h},/usr}/share/enscript/afm/font.map(N) )
+      _wanted fonts expl font compadd -qS @ - ${${(f)"$(<$libpath[1])"}%% *}
+    fi
   ;;
-
-inputlang)
-  if (( ! $+_enscript_input_languages )); then
-    _enscript_input_languages=(${${(f)${(F)${(M)${(f)"$(enscript --help-pretty-print)"}:#(Name|Description):*}}//(#b)Name: ([^
+  formats)
+    local -a specs
+    local suf='{'
+    compquote suf
+    if [[ ${PREFIX} = *[%$]D${suf}[^}]# ]]; then
+      _strftime
+    elif [[ ${(Q)PREFIX} = *\$\([^\)]# ]]; then
+      compset -P '*\('
+      _parameters -g '*export*' -S '\)'
+    elif [[ ${(Q)PREFIX} = *\$ ]]; then
+      specs=(
+	'$:a dollar symbol'
+	'%:current page number'
+	'=:number of pages in the current file'
+	'p:number of pages processed so far'
+	{C,\*}':file modification time (hh:mm:ss)'
+	'n:basename of the input file name'
+	'N:full input file name'
+	'E:file modification date (yy/mm/dd)'
+	'F:file modification date (dd.mm.yyyy)'
+	't:file modification time (12-hour)'
+	'T:file modification time (24-hour)'
+	'v:sequence number of current input file'
+	'V:sequence number of current input file in table of contents format'
+	'W:file modification date (mm/dd/yy)'
+	'\(:environment variable'
+      )
+      compset -P "*"
+      _describe -t format-specifiers 'format specifier' specs -S '' -- '( D:modification\ date )' -qS $suf
+    elif [[ ${(Q)PREFIX} = *% ]]; then
+      specs=(
+	'c:trailing component of the current working directory'
+	{C,\*}':current time (hh:mm:ss)'
+	'E:current date (yy/mm/dd)'
+	'F:current date (dd.mm.yyyy)'
+	'H:document title'
+	'L:lines in the input file'
+	'm:hostname in short form'
+        'M:hostname in fully qualified form'
+	'n:user login name'
+	'N:user gecos field first component'
+	't:current time (12-hour)'
+	'T:current time (24-hour)'
+	'W:current date (mm/dd/yy)'
+      )
+      compset -P "*"
+      _describe -t format-specifiers 'format specifier' specs -S '' -- '( D:current\ time )' -qS $suf
+    else
+      compset -P "*"
+      _wanted format-specifiers expl 'format specifier' compadd -S '' % \$
+    fi
+  ;;
+  headers)
+    libpath=( {${commands[enscript]:h:h},/usr}/share/enscript(N/) ~/.enscript(N/) )
+    _wanted headers expl header compadd $^libpath/*.hdr(N:r:t)
+  ;;
+  inputlang)
+    if (( ! $+_cache_enscript_languages )); then
+      typeset -ga _cache_enscript_languages
+      _cache_enscript_languages=(${${(f)${(F)${(M)${(f)"$(_call_program languages enscript --help-pretty-print)"}:#(Name|Description):*}}//(#b)Name: ([^
 ]##)(
 Description: ([^
 ]##)|)/$match[1]:$match[3]}%:})
-  fi
-  _describe 'input language' _enscript_input_languages -- 
+    fi
+    _describe -t languages 'input language' _cache_enscript_languages
   ;;
 esac



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