Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _info completion
- X-seq: zsh-workers 17125
- From: Borsenkow Andrej <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: PATCH: _info completion
- Date: 12 May 2002 11:11:44 +0400
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This is based on info-4.2 (the one I have); if you have earlier versions
please check if it works. It assumes that 'info -o - node1 ...' works;
without it completing (nested) menu items is more work than it's worth.
4 lines of parameter substitution is daunting but it tries to parse
three different line entry formats with on regexp and also account for
subtle differences in formatting I have encountered. Suggestions how to
simplify it are gratefully accepted :-)
I would be glad to here comments from our completion function gurus (I
am trying to learn how to write them properly). Specifcially how to use
tags with _describe (should it be _requested .. && _describe ...?).
-andrej
Index: Completion/Unix/Command/_info
===================================================================
RCS file: Completion/Unix/Command/_info
diff -N Completion/Unix/Command/_info
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_info 12 May 2002 07:03:52 -0000
@@ -0,0 +1,31 @@
+#compdef info
+
+local context state line expl ret=1
+typeset -A opt_args
+local info=${words[1]}
+
+_arguments -s \
+ '(: -)--apropos=[look up string in indices]:search string: ' \
+ '(-f --file -d --directory)'{-d,--directory=}'[add directory to infopath]:_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
+
+case $state in
+ item )
+ local -a items
+ items=(${${(M)${${(f)"$(${info} --output - ${(Q)words[1,CURRENT-1]} 2>/dev/null)"}[1,(r)[[:space:]]#--- The Detailed Node Listing ---[[:space:]]#]}:#\* *~\* Menu:*}:/(#b)\* ([^:]#):(#B)([[:space:]]##\(*\)[^.]#.[[:space:]]#|(|:)([[:space:]]##|(#e)))(#b)(*)/$match[1]:$match[2]})
+ _describe "menu item" items && ret=0
+ ;;
+esac
+
+return $ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author