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

Re: PATCH: _info completion

On 23 May, Andrej wrote:

> Commited as _texinfo. God knows I tried to simplify a pattern but could
> not. Oliver, if you will add to this file you probably could polish it a
> bit as well - thank you.

Below is an updated _texinfo with support for install-info, makeinfo,
texi2dvi and texindex added. I've not got around to look at polishing
the info stuff and in fact I still need to look over the rest of this 
more thoroughly. I also intended to add handling for tkinfo.

Being pedantic, info completion should also complete man pages because
the info reader will display man pages but I wouldn't worry unless
anyone claims to actually use it to read man pages.


#compdef info install-info makeinfo texi2dvi texindex

local curcontext="$curcontext" state line ret=1

case $service in
    local -A opt_args
    local -a info
    info=(_call_program info ${words[1]})

    _arguments -C -s \
      '(: -)--apropos=[look up string in indices]:search string: ' \
      '(-f --file)'{\*-d,\*--directory=}'[add directory to infopath]:info dir:_files -/' \
      '--dribble=[record keystrokes]:file with keystrokes:_files' \
      '(-f --file -d --directory)'{-f,--file=}'[info file to show]:info file:_files -g "*.info(|.gz|.bz2)"' \
      '(: - -h --help)'{-h,--help}'[display usage]' \
      '(-o --output -O)--index-search=[go directly to node if found]:search string: ' \
      '(--index-search -o --output -O)'{-o,--output=}'[dump selected nodes to filename]:filename:_files -g "*(^/)"' \
      '(-R --raw-escapes)'{-R,--raw-escapes}'[do not remove ANSI escapes from man pages]' \
      '--restore=[read keystrokes from file]:filename:_files -g "*(^/)"' \
      '(--index-search -o --output -O --show-options --usage)'{-O,--show-options,--usage}'[go to command-line options node]' \
      '--subnodes[recursively output menu items]' \
      '--vi-keys[use Vi-like key bindings]' \
      '(: -)--version[display version information]' \
      '(--apropos -h --help -O --output --version)*::menu items:->item' && ret=0
    if _pick_variant debian=Debian gnu --version; then
      _arguments -S \
        '(* -)--help[display help information]' \
        '(* -)--version[display version information]' \
        '(--maxwidth --align --calign)--remove[delete existing entries]' \
        '(--maxwidth --align --calign)--remove-exactly[delete existing entries taking exact entry name]' \
        '--section[specify section to add entry in]:regexp::title' \
        '--infodir=[specify directory containing dir file]:info directory:_files -/' \
        '--align=[specify minimum indentation for description]:indentation' \
        '--calign=[specify minimum indentation for continuation lines of description]:indentation' \
        '--maxwidth=[specify maximim width of dir file]:width' \
        '--quiet[suppress informational output]' \
        '--description=[specify description for menu entry]:description' \
        '--menuentry=[specify the menu entry for dir file]:menu entry' \
        '--keep-old=[inhibit replacement of existing entries/removal of empty sections]' \
        '--test[do not update dir file]' \
        '--debug[enable debugging]' \
        '*:info file:_files -g \*.info'
      _arguments \
        '(--delete --remove)'{--delete,--remove}'[delete existing entries]' \
        '(2)--dir-file=[specify dir file]:dir file:_files -g dir' \
        \*{--entry,--info}'[specify directory entry to add]:text' \
        '(- 1 2)--help[display help information]' \
        '(1)--info-file=[specify info file to install in the directory]:info file:_files -g *.info' \
        '(2)--info-dir=[specify directory containing dir file]:info directory:_files -/' \
        '--quiet[suppress warnings]' \
        '(--delete --remove)--section=[put new entries in specified section]' \
        '(- 1 2)--version[display version information]' \
        '1:info file:_files -g \*.info' \
        '2:dir file:_files -g dir'
    _arguments -s \
      '--error-limit=[specify number of errors to quit after]:number' \
      '--force[preserve output even if errors]' \
      '(* -)--help[display help]' \
      '--no-validate[suppress node cross-reference validation]' \
      '--no-warn[suppress warnings]' \
      '--reference-limit=[warn about at most specified number of references]:number' \
      '(-v --verbose)'{-v,--verbose}'[explain what is being done]' \
      '(* -)--version[display version info]' \
      '(--html --xml)--docbook[output in DocBook format]' \
      '(--docbook --xml)--html[output in HTML format]' \
      '--no-headers[suppress node separators and menus]' \
      '(--docbook --html)--xml[output in XML (TexinfoML) format]' \
      '(-E --macro-expand)'{-E,--macro-expand}'[output macro-expanded source to specified file]:file:_files' \
      '(--docbook --xml)--no-split[suppress splitting of output]' \
      '--number-sections[output chapter and section numbers]' \
      '(-o --output=)'{-o,--output}'[specify output file]:output file:_files' \
      '(--docbook --html --xml)--enable-encoding[output special characters]' \
      '(--docbook --html --xml)--fill-column=[specify width to break lines at]:width' \
      '(--docbook --html --xml)--footnote-style=[specify style for output of footnotes]:((separate\:in\ own\ node end\:at\ end\ of\ node))' \
      '(--docbook --html --xml)--paragraph-indent=[specify spaces to indent paragraphs by]' \
      '(--docbook --html --xml)--split-size=[split Info files at specified size]:size' \
      '--commands-in-node-names[allow @ commands in node names]' \
      '-D[define variable]:variable' \
      '-I[specify directory to append to @include search path]:directory:_files -/' \
      '-P[specify directory to prepend to @include search path]:directory:_files -/' \
      '-U[undefine variable]:variable' \
      '(--html --no-ifhtml)--ifhtml[process @ifhtml and @html when not generating HTML]' \
      '(--no-ifinfo)--ifinfo[process @ifinfo even when not generating Info]' \
      '(--no-iftex)--iftex[process @iftex and @tex text]' \
      '(--no-ifplaintext)--ifplaintext[process @ifplaintext even when not generating plain text]' \
      '(--ifhtml)--no-ifhtml[do not process @ifhtml and @html text]' \
      '(--ifinfo)--no-ifinfo[do not process @ifinfo text]' \
      '(--ifplaintext)--no-ifplaintext[do not process @ifplaintext text]' \
      '(--iftex)--no-iftex[do not process @iftex and @tex text]' \
      '*:texinfo file:_texi'
    _arguments -s \
      '(-b --batch)'{-b,--batch}'[no interaction]' \
      '(-c --clean)'{-c,--clean}'[remove all auxiliary files]' \
      '(-D --debug)'{-D,--debug}'[turn on shell debugging (set -x)]' \
      '(- *)'{-h,--help}'[display help information]' \
      '(-o --output)'{-o,--output=}'[specify output file]:output file:_files' \
      '(-q -s --quiet --silent -V --verbose)'{-q,-s,--silent,--quiet}'[no output except errors]' \
      '(-q -s --quiet --silent -V --verbose)'{-V,--verbose}'[report on what is done]' \
      '(- *)'{-v,--version}'[display version information]' \
      '-@[use @input instead of \input; for preloaded Texinfo]' \
      '(-e --expand)'{-e,--expand}'[force macro expansion using makeinfo]' \
      '-I[specify search dir for texinfo files]:directory:_files -/' \
      '(-l --language)'{-l,--language}'[specify language of input file]:language:(LaTeX Texinfo)' \
      '(-p --pdf)'{-p,--pdf}'[use pdftex or pdflatex for processing]' \
      \*{-t,--texinfo}'[specify command to insert after @setfilename]:command' \
    _arguments \
      '(* -)--help[display help]' \
      '(* -)--version[display version info]' \
      '(--no-keep)--keep[keep temporary files around after processing]' \
      '(--keep)--no-keep[do not keep temporary files (default)]' \
      '(-o --output)'{-o,--output=}'[specify output file]:file:_files' \
      '*:texinfo file:_texi'

case $state in
  item )
    local -a items

    info=($info ${(kv)opt_args[(I)(-d|--directory|-f|--file)]})

    items=(${${(M)${${(f)"$(${info} --output - ${words[1,CURRENT-1]} 2>/dev/null)"}[1,(r)[[:space:]]#--- The Detailed Node Listing ---[[:space:]]#]}:#\* *~\* Menu:*}:/(#b)\*[[:space:]]##([^:]##):(#B)( \(?##\)[^.]#.|(:|))[[:space:]]#(#b)(*)[[:space:]]#/$match[1]${match[2]:+:}$match[2]})

    _describe -t items "menu items" items && ret=0

return ret

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.

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