diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Doc/Zsh/mod_zutil.yo | 16 | ||||
-rw-r--r-- | Src/Modules/zutil.c | 36 |
3 files changed, 52 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog index 446d5b722..1e44739ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-08-16 Peter Stephenson <pws@csr.com> + + * 22610: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c: + allow zstyle -L with arguments. + 2006-08-15 Peter Stephenson <p.w.stephenson@ntlworld.com> * 22611: Src/Zle/complist.c: bug when scrolling completion diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo index c7342fdba..659b4aff7 100644 --- a/Doc/Zsh/mod_zutil.yo +++ b/Doc/Zsh/mod_zutil.yo @@ -7,7 +7,7 @@ The tt(zsh/zutil) module only adds some builtins: startitem() findex(zstyle) -xitem(tt(zstyle) [ tt(-L) ]) +xitem(tt(zstyle) [ tt(-L) [ var(pattern) [ var(style) ] ] ]) xitem(tt(zstyle) [ tt(-e) | tt(-) | tt(-)tt(-) ] var(pattern) var(style) var(strings) ...) xitem(tt(zstyle -d) [ var(pattern) [ var(styles) ... ] ]) xitem(tt(zstyle -g) var(name) [ var(pattern) [ var(style) ] ]) @@ -31,8 +31,18 @@ complex patterns are considered to be more specific than the pattern `tt(*)'. The first form (without arguments) lists the definitions in the order -tt(zstyle) will test them. If the tt(-L) option is given, listing is -done in the form of calls to tt(zstyle). Forms with arguments: +tt(zstyle) will test them. + +If the tt(-L) option is given, listing is done in the form of calls to +tt(zstyle). The optional first argument is a pattern which will be matched +against the string supplied as the pattern for the context; note that +this means, for example, `tt(zstyle -L ":completion:*")' will +match any supplied pattern beginning `tt(:completion:)', not +just tt(":completion:*"): use tt(":completion:\*") to match that. +The optional second argument limits the output to a specific style (not a +pattern). tt(-L) is not compatible with any other options. + +The other forms are the following: startitem() item(tt(zstyle) [ tt(-) | tt(-)tt(-) | tt(-e) ] var(pattern) var(style) var(strings) ...)( diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index c2298a782..3ed1f9e16 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -268,9 +268,10 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) zwarnnam(nam, "invalid argument: %s", args[0]); return 1; } - if (oc == 'L') + if (oc == 'L') { list = 2; - else if (oc == 'e') { + args++; + } else if (oc == 'e') { eval = add = 1; args++; } @@ -305,13 +306,44 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) Style s; Stypat p; char **v; + char *context, *stylename; + Patprog contprog; + + switch (arrlen(args)) { + case 2: + context = args[0]; + stylename = args[1]; + break; + + case 1: + context = args[0]; + stylename = NULL; + break; + + case 0: + context = stylename = NULL; + break; + + default: + zwarnnam(nam, "too many arguments"); + return 1; + } + if (context) { + tokenize(context); + contprog = patcompile(context, PAT_STATIC, NULL); + } else + contprog = NULL; for (s = zstyles; s; s = s->next) { if (list == 1) { quotedzputs(s->name, stdout); putchar('\n'); } + if (stylename && strcmp(s->name, stylename) != 0) + continue; for (p = s->pats; p; p = p->next) { + if (contprog && !pattry(contprog, p->pat)) + continue; if (list == 1) printf("%s %s", (p->eval ? "(eval)" : " "), p->pat); else { |