From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: new and updated completions
Date: Wed, 8 Aug 2001 09:19:05 +0200 (MET DST) [thread overview]
Message-ID: <200108080719.JAA04358@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <3B6FCB2A.32DFAAEA@u.genie.co.uk>
Oliver Kiddle wrote:
> ...
>
> I'd have thought it should be in _values itself as _values should
> ideally be able to work with multiple words.
Yes, here is the patch. It adds the -w option to _values which means
that it will look at all words on the line.
> This "easiest fix" isn't
> going to handle explicit exclusion lists though. I'm not sure whether
> there shouldn't be exclusions between bs and ibs/obs for dd but as the
> exclusions don't work here, I didn't worry.
You can now start to worry ;-)
Bye
Sven
Index: Completion/Unix/Command/_dd
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_dd,v
retrieving revision 1.3
diff -u -r1.3 _dd
--- Completion/Unix/Command/_dd 2001/08/07 10:38:36 1.3
+++ Completion/Unix/Command/_dd 2001/08/08 07:19:00
@@ -2,21 +2,15 @@
local opts
-opts=(
- 'if[specify input file]:input file:_tilde_files'
- 'of[specify output file]:output file:_tilde_files'
- 'ibs[input block size]:block size (bytes)'
- 'obs[output block size]:block size (bytes)'
- 'bs[block size]:block size (bytes)'
- 'cbs[conversion buffer size]:buffer size (bytes)'
- 'skip[input blocks initially skipped]:blocks'
- 'seek[output blocks initially skipped]:blocks'
- 'files[specify number of input files to copy and concatenate]:number of files'
- 'count[number of input blocks to copy]:blocks'
+_values -w 'option' \
+ 'if[specify input file]:input file:_tilde_files' \
+ 'of[specify output file]:output file:_tilde_files' \
+ 'ibs[input block size]:block size (bytes)' \
+ 'obs[output block size]:block size (bytes)' \
+ 'bs[block size]:block size (bytes)' \
+ 'cbs[conversion buffer size]:buffer size (bytes)' \
+ 'skip[input blocks initially skipped]:blocks' \
+ 'seek[output blocks initially skipped]:blocks' \
+ 'files[specify number of input files to copy and concatenate]:number of files' \
+ 'count[number of input blocks to copy]:blocks' \
'conv[specify conversions to apply]:conversion:_values -s , "conversion" ascii ebcdic ibm block unblock lcase ucase swab noerror sync'
-)
-
-[[ "$PREFIX$SUFFIX" != *\=* ]] &&
- opts=( "${(@)opts:#(${(j:|:)~words[2,-1]%%\=*})\[*}" )
-
-_values -S '=' 'option' "$opts[@]"
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.132
diff -u -r1.132 compsys.yo
--- Doc/Zsh/compsys.yo 2001/08/06 15:56:23 1.132
+++ Doc/Zsh/compsys.yo 2001/08/08 07:19:03
@@ -3975,6 +3975,10 @@
Thus the values completed appear in the same word on the command line,
unlike completion using tt(_arguments).
+Normally, tt(_values) will only use the current word to determine
+which values are already present on the command line. If the tt(-w)
+option is given, the other arguments are used, too.
+
The first argument (after the options and separator character if they
are given) is used as a string to print as a description before
listing the values.
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.71
diff -u -r1.71 computil.c
--- Src/Zle/computil.c 2001/07/30 08:42:56 1.71
+++ Src/Zle/computil.c 2001/08/08 07:19:04
@@ -2499,6 +2499,7 @@
char **defs; /* original strings */
int ndefs; /* number of ... */
int lastt; /* last time used */
+ int words; /* if to look at other words */
};
/* One value definition. */
@@ -2556,18 +2557,23 @@
Cvval val, *valp;
Caarg arg;
char **oargs = args, sep = '\0', asep = '=', *name, *descr, *p, *q, **xor, c;
- int xnum, multi, vtype, hassep = 0;
+ int xnum, multi, vtype, hassep = 0, words = 0;
- while (args[0][0] == '-' && (args[0][1] == 's' || args[0][1] == 'S') &&
+ while (args[0][0] == '-' &&
+ (args[0][1] == 's' || args[0][1] == 'S' || args[0][1] == 'w') &&
!args[0][2]) {
if (args[0][1] == 's') {
hassep = 1;
sep = args[1][0];
- } else
+ args += 2;
+ } else if (args[0][1] == 'S') {
asep = args[1][0];
-
- args += 2;
+ args += 2;
+ } else {
+ words = 1;
+ args++;
+ }
}
if (!args[0] || !args[1]) {
zwarnnam(nam, "not enough arguments", NULL, 0);
@@ -2585,6 +2591,7 @@
ret->defs = zarrdup(oargs);
ret->ndefs = arrlen(oargs);
ret->lastt = time(0);
+ ret->words = words;
for (valp = &(ret->vals); *args; args++) {
int bs = 0;
@@ -2892,6 +2899,35 @@
cv_alloced = 1;
+ if (d->words && compwords[0]) {
+ int i;
+
+ for (i = 1; compwords[i]; i++)
+ if (i != compcurrent - 1)
+ for (str = compwords[i]; str && *str; ) {
+ if ((val = cv_next(d, &str, &arg))) {
+ zaddlinknode(state.vals, ztrdup(val->name));
+ if (arg) {
+ char sav = '\0';
+
+ if (str) {
+ sav = str[-1];
+ str[-1] = '\0';
+ }
+ zaddlinknode(state.vals, ztrdup(arg));
+ if (str)
+ str[-1] = sav;
+ } else
+ zaddlinknode(state.vals, ztrdup(""));
+
+ if (i + 1 < compcurrent)
+ cv_inactive(d, val->xor);
+ }
+ }
+
+ val = NULL;
+ arg = NULL;
+ }
for (str = compprefix; str && *str; ) {
if ((val = cv_next(d, &str, &arg))) {
zaddlinknode(state.vals, ztrdup(val->name));
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next prev parent reply other threads:[~2001-08-08 7:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-06 14:28 Oliver Kiddle
2001-08-06 14:30 ` Chmouel Boudjnah
2001-08-06 17:43 ` Borsenkow Andrej
2001-08-06 17:47 ` Chmouel Boudjnah
2001-08-08 11:37 ` Oliver Kiddle
2001-08-08 12:06 ` Chmouel Boudjnah
2001-08-08 15:52 ` Bart Schaefer
2001-08-08 17:17 ` Oliver Kiddle
2001-08-09 15:58 ` Bart Schaefer
2001-08-11 14:20 ` Peter Stephenson
2001-08-07 10:36 ` Sven Wischnowsky
2001-08-07 11:04 ` Oliver Kiddle
2001-08-08 7:19 ` Sven Wischnowsky [this message]
2001-08-08 17:23 ` Oliver Kiddle
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=200108080719.JAA04358@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.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).