From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: small new bit for _arguments
Date: Fri, 27 Aug 1999 11:54:23 +0200 (MET DST) [thread overview]
Message-ID: <199908270954.LAA17659@beta.informatik.hu-berlin.de> (raw)
This allows to give something like `((a\:bar b\:baz))' as the
action. The strings in the list should all have a colon in them and
the stuff before it will be completed. The strings after the colons
are used as descriptions and shown in the list.
Currently this is only used in `_find' and some of the pbmplus
functions.
Maybe we should make the format configurable?
Bye
Sven
P.S.: Note that I didn't change `_long_options' to accept the same --
I still hope to find the time to merge it with `_arguments'.
Maybe at the weekend.
diff -u od/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- od/Zsh/compsys.yo Fri Aug 27 10:14:08 1999
+++ Doc/Zsh/compsys.yo Fri Aug 27 11:37:24 1999
@@ -949,7 +949,11 @@
In each of the cases above, the var(action) says how the possible
completions should be generated. In cases where only one of a fixed
set of strings can be completed, these string can directly be given as
-a list in parentheses, as in `tt(:foo:(foo bar baz))'. A string in
+a list in parentheses, as in `tt(:foo:(foo bar baz))'. Such a list in
+doubled parentheses, as in `tt(:foo:((a\:bar b\:baz)))' should contain
+strings consisting of the string to complete followed by a colon
+(which needs to be preceded by a backslash) and a description. The
+matches will be listed together with their descriptions. A string in
braces will be evaluated to generate the matches and if the
var(action) does not begin with an opening parentheses or brace, it
will be split into separate words and executed. If the var(action)
diff -u -r oc/Base/_arguments Completion/Base/_arguments
--- oc/Base/_arguments Fri Aug 27 09:03:35 1999
+++ Completion/Base/_arguments Fri Aug 27 11:44:15 1999
@@ -533,8 +533,34 @@
if [[ -z "$action" ]]; then
# An empty action means that we should just display a message.
+
_message "$descr"
return ret
+
+ elif [[ "$action" = \(\(*\)\) ]]; then
+
+ # ((...)) contains literal strings with descriptions.
+
+ eval ws\=\( "${action[3,-3]}" \)
+
+ compadd -D ws - "${(@)ws%%:*}"
+
+ if (( $#ws )); then
+ beg=1
+ for nth in "$ws[@]"; do
+ tmp="${#nth%%:*}"
+ [[ tmp -gt beg ]] && beg="$tmp"
+ done
+ tmp=''
+ for nth in "$ws[@]"; do
+ tmp="$tmp
+${(r:beg:: :)nth%%:*} -- ${nth#*:}"
+ done
+ tmp="$tmp[2,-1]"
+ compadd "$expl[@]" -y tmp - "${(@)ws%%:*}"
+ else
+ _message "$descr"
+ fi
elif [[ "$action" = \(*\) ]]; then
# Anything inside `(...)' is added directly.
diff -u -r oc/Pbmplus/_pnmtotiff Completion/Pbmplus/_pnmtotiff
--- oc/Pbmplus/_pnmtotiff Thu Aug 26 15:55:06 1999
+++ Completion/Pbmplus/_pnmtotiff Fri Aug 27 11:30:01 1999
@@ -1,5 +1,5 @@
#compdef pnmtotiff
_arguments '-none' '-packbits' '-lzw' '-g3' '-g4' '-2d' '-fill' \
- '-predictor:LZW predictor:(1 2)' '-msb2lsb' '-lsb2msb' \
+ '-predictor:LZW predictor:((1\:without\ differencing 2\:with\ differencing))' '-msb2lsb' '-lsb2msb' \
'-rowsperstrip:number of rows per strip:' ':file: _pbm_file'
diff -u -r oc/Pbmplus/_ppmtomitsu Completion/Pbmplus/_ppmtomitsu
--- oc/Pbmplus/_ppmtomitsu Thu Aug 26 15:55:04 1999
+++ Completion/Pbmplus/_ppmtomitsu Fri Aug 27 11:30:55 1999
@@ -2,6 +2,6 @@
_arguments '-sharpness:sharpness:(1 2 3 4)' \
'-enlarge:enlargement factor:(1 2 3)' \
- '-media:output media:(A A4 AS A4S)' \
+ '-media:output media (default\: 1184x1350):((A\:1216x1350 A4\:1184x1452 AS\:1216x1650 A4S\:1184x1754))' \
'-copy:number of copies:(1 2 3 4 5 6 7 8 9)' \
'-dpi300' '-tiny' ':file: _pbm_file'
diff -u -r oc/User/_find Completion/User/_find
--- oc/User/_find Thu Aug 26 15:54:59 1999
+++ Completion/User/_find Fri Aug 27 11:21:43 1999
@@ -43,8 +43,8 @@
'*-perm:file permission bits:' \
'*-size:file size:' \
'*-true' \
- '*-type:file type:(b c d p f l s)' \
- '*-xtype:file type:(b c d p f l s)' \
+ '*-type:file type:((b\:block\ special\ file c\:character\ special\ file d\:directory p\:named\ pipe f\:normal\ file l\:symbolic\ link s\:socket))' \
+ '*-xtype:file type:((b\:block\ special\ file c\:character\ special\ file d\:directory p\:named\ pipe f\:normal\ file l\:symbolic\ link s\:socket))' \
'*-exec:program: _command_names -e:*\;::program arguments: _normal' \
'*-ok:program: _command_names -e:*\;::program arguments: _normal' \
'*-fls:output file:_files' \
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
reply other threads:[~1999-08-27 9:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199908270954.LAA17659@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).