From fd144877f502b79aa781b7fdddd0f7285783e123 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 25 Jul 2016 00:12:43 +0200 Subject: 38943: update texinfo options and improve completion of Info files, nodes and menu items --- Completion/Unix/Command/_texinfo | 243 +++++++++++++++++++++++++++++---------- 1 file changed, 182 insertions(+), 61 deletions(-) (limited to 'Completion/Unix/Command/_texinfo') diff --git a/Completion/Unix/Command/_texinfo b/Completion/Unix/Command/_texinfo index 12d964e3f..7b66d6304 100644 --- a/Completion/Unix/Command/_texinfo +++ b/Completion/Unix/Command/_texinfo @@ -1,29 +1,65 @@ -#compdef info tkinfo install-info makeinfo texi2dvi texindex +#compdef info tkinfo install-info makeinfo texi2any texi2dvi pdftexi2dvi texi2pdf texindex -local curcontext="$curcontext" state line ret=1 -local -A opt_args -local -a info +_info_nodes_caching_policy() { + local dir oldp + for dir in $^infopath/usr/share/info}/dir(.N); do + # rebuild if any dir file is newer than cache + [[ $dir -nt $1 ]] && return + done + # and if we didn't find a dir file, rebuild if cache older than a month + if [[ -z $dir ]]; then + oldp=( "$1"(mM+1) ) + (( $#oldp )) && return + fi + return 1 +} + +_info_retrieve_nodes() { + # expects $cmd, $hash and $infopath to be set + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy \ + _info_nodes_caching_policy + fi + + if _cache_invalid info-nodes-$hash || ! _retrieve_cache info-nodes-$hash; then + set -A _cache_info_nodes_$hash \ + ${${${${(f)"$(INFOPATH="${(j.:.)infopath}" _call_program info-nodes $cmd -k '')"}%%\" --*}#??}/\)/:} + _store_cache info-nodes-$hash _cache_info_nodes_$hash + fi +} + +local curcontext="$curcontext" state line cmd ret=1 +local -A opt_args infodirs case $service in info) - info=( _call_program info ${words[1]} ) + cmd=${words[1]} _arguments -C -s \ - '(: -)--apropos=[look up string in indices]:search string: ' \ - '(-f --file)'{\*-d,\*--directory=}'[add directory to infopath]:info dir:_files -/' \ + '(-a --all)'{-a,--all}'[use all matching manuals]' \ + '(: -)'{-k+,--apropos=}'[look up string in indices]:search string: ' \ + \*{-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)(-.)"' \ + '(-f --file 1)'{-f+,--file=}'[specify Info manual to visit]:info manual:->infofiles' \ '(: - -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]' \ + '(--index-search -o --output -O)'{-o+,--output=}'[dump selected nodes to filename]:filename:_files -g "*(-.)"' \ + '(-n --node)'{-n+,--node=}'[specify nodes in first visited Info file]:node:->nodes' \ + '--no-raw-escapes[output escapes as literal text]' \ '--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]' \ + '--strict-node-location[(for debugging) use Info file pointers as-is]' \ '--subnodes[recursively output menu items]' \ + \*{-v,--variable}'[assign to Info variable]:variable' \ '--vi-keys[use Vi-like key bindings]' \ '(: -)--version[display version information]' \ - '(--apropos -h --help -O --output --version)*::menu item:->item' && ret=0 + '(-w --where --location)'{-w,--where,--location}'[print physical location of Info file]' \ + '(-x --debug)'{-x+,--debug=}'[set debugging level]:number' \ + '1:menu item:->infomanuals' \ + '2:node:->nodes' && ret=0 - info=( $info {(kv)opt_args[(I)(-d|--directory|-f|--file)]} ) + infodirs=( "${(@Qkv)opt_args[(I)(-d|--directory)]}" ) ;; install-info) if _pick_variant debian=Debian gnu --version; then @@ -41,131 +77,216 @@ case $service in '--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]' \ + "--test[don't update dir file]" \ '--debug[enable debugging]' \ '*:info file:_files -g "*.info(-.)"' return else _arguments \ + '--add-once[add only to first matching section]' \ + '--align=[specify minimum indentation for description]:indentation' \ + '--calign=[specify minimum indentation for continuation lines of description]:indentation' \ + '--debug[report what is being done]' \ '(--delete --remove)'{--delete,--remove}'[delete existing entries]' \ + '--description=[specify description for menu entry]:description' \ '(2)--dir-file=[specify dir file]:dir file:_files -g "dir(-.)"' \ + '(--test --dry-run)'{--dry-run,--test}"[don't update dir file]" \ \*{--entry,--info}'[specify directory entry to add]:text' \ + '--defsection=[like --section, but only use text if no sections present in info file]:text' \ + {--maxwidth,--max-width}'=[specify maximum width of dir file]:width' \ '(- 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 -/' \ + '--keep-old=[inhibit replacement of existing entries/removal of empty sections]' \ + '(--name --menuentry)'{--name,--menuentry}'=[specify the menu entry for dir file]:menu entry' \ + "--no-indent[don't format new entries in the DIR file]" '--quiet[suppress warnings]' \ - '(--delete --remove)--section=[put new entries in specified section]' \ + '--regex=[specify sections for file entries using a regex]:regex' \ + '(--delete --remove)--section=[put new entries in specified section]:section' \ + '--silent[no output except errors]' \ '(- 1 2)--version[display version information]' \ '1:info file:_files -g "*.info(-.)"' \ '2:dir file:_files -g "dir(-.)"' return fi ;; - makeinfo) + makeinfo|texi2any) _arguments -s \ - '--error-limit=[specify number of errors to quit after]:number' \ + '--error-limit=[specify number of errors to quit after]:number [100]' \ + '--document-language=[specify locale to use in translating Texinfo keywords]:locale [C]:_locales' \ '--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' \ + '--conf-dir=[specify additional directory for configuration files]:directory:_directories' \ + '--init-file=[specify initialisation file]:file:_files' \ + \*{-c+,--set-customization-variable=}'[set customization variable]:variable' \ '(-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]' \ + '(--html --xml --plaintext)--docbook[output in DocBook XML format]' \ + '(--docbook --xml --plaintext)--html[output in HTML format]' \ '--no-headers[suppress node separators and menus]' \ - '(--docbook --html)--xml[output in XML (TexinfoML) format]' \ + '(--docbook --html --plaintext)--xml[output in XML (TexinfoML) format]' \ + '(--docbook --html --xml)--plaintext[output in plain text format]' \ + '--dvi[output in dvi format]' \ + '--dvipdf[output in pdf format]' \ + '--ps[output in ps format]' \ + '--pdf[output in pdf 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]' \ + '--no-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)--disable-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]' \ + '(--docbook --html --xml)--split-size=[split Info files at specified size]:size [300000]' \ + '(--docbook --xml --plaintext)--css-include=[specify file in include in HTML