From 8066c8066520d734d22ab17992bd3787777d4130 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 28 Oct 1999 08:13:52 +0000 Subject: zsh-workers/8471 --- Completion/Base/_command_names | 8 +- Completion/Base/_equal | 2 +- Completion/Builtins/_aliases | 4 +- Completion/Builtins/_bindkey | 4 +- Completion/Builtins/_builtin | 2 +- Completion/Builtins/_disable | 8 +- Completion/Builtins/_enable | 8 +- Completion/Builtins/_functions | 2 +- Completion/Builtins/_unhash | 4 +- Completion/Builtins/_which | 8 +- Completion/Builtins/_zle | 4 +- Completion/Builtins/_zmodload | 2 +- Doc/Zsh/mod_parameter.yo | 42 +++-- Doc/Zsh/mod_zleparameter.yo | 8 +- Src/Modules/parameter.c | 363 +++++++++++++++++++++++++++-------------- Src/Modules/parameter.mdd | 2 +- Src/Zle/zleparameter.c | 4 +- Src/Zle/zleparameter.mdd | 2 +- 18 files changed, 309 insertions(+), 168 deletions(-) diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names index 79bd46e84..a640e196b 100644 --- a/Completion/Base/_command_names +++ b/Completion/Base/_command_names @@ -24,13 +24,13 @@ compadd "$expl[@]" "$@" - "${(k@)commands}" && ret=0 if [[ -z "$ext" ]]; then _description expl 'builtin command' - compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)builtins}" && ret=0 _description expl 'shell function' - compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)functions}" && ret=0 _description expl 'alias' - compadd "$expl[@]" "$@" - "${(k@)raliases[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)raliases}" && ret=0 _description expl 'reserved word' - compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)reswords}" && ret=0 fi if [[ nm -eq compstate[nmatches] ]]; then diff --git a/Completion/Base/_equal b/Completion/Base/_equal index 1ba92cdc6..c50741ed4 100644 --- a/Completion/Base/_equal +++ b/Completion/Base/_equal @@ -3,6 +3,6 @@ local expl _description expl alias -compadd "$@" "$expl[@]" - "${(@k)aliases[(R)^?disabled*]}" +compadd "$@" "$expl[@]" - "${(@k)aliases}" _description expl command compadd "$@" "$expl[@]" - "${(k@)commands}" diff --git a/Completion/Builtins/_aliases b/Completion/Builtins/_aliases index 0189d6cf3..5f2a8ec84 100644 --- a/Completion/Builtins/_aliases +++ b/Completion/Builtins/_aliases @@ -3,6 +3,6 @@ local expl _description expl 'regular alias' -compadd "$expl[@]" - "${(@k)raliases[(R)^?disabled*]}" +compadd "$expl[@]" - "${(@k)raliases}" _description expl 'global alias' -compadd "$expl[@]" - "${(@k)galiases[(R)^?disabled*]}" +compadd "$expl[@]" - "${(@k)galiases}" diff --git a/Completion/Builtins/_bindkey b/Completion/Builtins/_bindkey index 3f964e704..b60dafbb2 100644 --- a/Completion/Builtins/_bindkey +++ b/Completion/Builtins/_bindkey @@ -11,8 +11,8 @@ local expl if [[ "$words[2]" = -*[DAN]* || "$words[CURRENT-1]" = -*M ]]; then _description expl keymap - compadd "$expl[@]" - "$zlekeymaps[@]" + compadd "$expl[@]" - "$keymaps[@]" else _description expl widget - compadd "$expl[@]" -M 'r:|-=* r:|=*' - "${(@k)zlewidgets}" + compadd "$expl[@]" -M 'r:|-=* r:|=*' - "${(@k)widgets}" fi diff --git a/Completion/Builtins/_builtin b/Completion/Builtins/_builtin index 06ef1c246..cf02093bb 100644 --- a/Completion/Builtins/_builtin +++ b/Completion/Builtins/_builtin @@ -8,5 +8,5 @@ else local expl _description expl 'builtin command' - compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" + compadd "$expl[@]" "$@" - "${(k@)builtins}" fi diff --git a/Completion/Builtins/_disable b/Completion/Builtins/_disable index fe6b991b2..af4805c25 100644 --- a/Completion/Builtins/_disable +++ b/Completion/Builtins/_disable @@ -4,19 +4,19 @@ local prev="$words[CURRENT-1]" ret=1 expl if [[ "$prev" = -*a* ]]; then _description expl alias - compadd "$expl[@]" "$@" - "${(k@)aliases[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)aliases}" && ret=0 fi if [[ "$prev" = -*f* ]]; then _description expl 'shell function' - compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)functions}" && ret=0 fi if [[ "$prev" = -*r* ]]; then _description expl 'reserved word' - compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)reswords}" && ret=0 fi if [[ "$prev" != -* ]]; then _description expl 'builtin command' - compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)builtins}" && ret=0 fi return ret diff --git a/Completion/Builtins/_enable b/Completion/Builtins/_enable index b4f0356bc..07077abd6 100644 --- a/Completion/Builtins/_enable +++ b/Completion/Builtins/_enable @@ -4,19 +4,19 @@ local prev="$words[CURRENT-1]" ret=1 expl if [[ "$prev" = -*a* ]]; then _description expl alias - compadd "$expl[@]" "$@" - "${(k@)aliases[(R)?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)disaliases}" && ret=0 fi if [[ "$prev" = -*f* ]]; then _description expl 'shell function' - compadd "$expl[@]" "$@" - "${(k@)functions[(R)?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)disfunctions}" && ret=0 fi if [[ "$prev" = -*r* ]]; then _description expl 'reserved word' - compadd "$expl[@]" "$@" - "${(k@)reswords[(R)?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)disreswords}" && ret=0 fi if [[ "$prev" != -* ]]; then _description expl 'builtin command' - compadd "$expl[@]" "$@" - "${(k@)builtins[(R)?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)disbuiltins}" && ret=0 fi return ret diff --git a/Completion/Builtins/_functions b/Completion/Builtins/_functions index d5f32d2e3..81a56eb83 100644 --- a/Completion/Builtins/_functions +++ b/Completion/Builtins/_functions @@ -3,4 +3,4 @@ local expl _description expl 'shell function' -compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" +compadd "$expl[@]" "$@" - "${(k@)functions}" diff --git a/Completion/Builtins/_unhash b/Completion/Builtins/_unhash index dfebd5399..1209f68af 100644 --- a/Completion/Builtins/_unhash +++ b/Completion/Builtins/_unhash @@ -8,11 +8,11 @@ if [[ "$fl" = -*d* ]]; then fi if [[ "$fl" = -*a* ]]; then _description expl alias - compadd "$expl[@]" - "${(@k)aliases}" && ret=0 + compadd "$expl[@]" - "${(@k)aliases}" "${(@k)disaliases}" && ret=0 fi if [[ "$fl" = -*f* ]]; then _description expl 'shell function' - compadd "$expl[@]" - "${(@k)functions}" && ret=0 + compadd "$expl[@]" - "${(@k)functions}" "${(@k)disfunctions}" && ret=0 fi if [[ "$fl" != -* ]]; then _command_names -e && ret=0 diff --git a/Completion/Builtins/_which b/Completion/Builtins/_which index 30d20ab36..328f7730c 100644 --- a/Completion/Builtins/_which +++ b/Completion/Builtins/_which @@ -5,10 +5,10 @@ local expl _description expl 'external command' compadd "$expl[@]" "$@" - "${(k@)commands}" && ret=0 _description expl 'builtin command' -compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0 +compadd "$expl[@]" "$@" - "${(k@)builtins}" && ret=0 _description expl 'shell function' -compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0 +compadd "$expl[@]" "$@" - "${(k@)functions}" && ret=0 _description expl 'alias' -compadd "$expl[@]" "$@" - "${(k@)raliases[(R)^?disabled*]}" && ret=0 +compadd "$expl[@]" "$@" - "${(k@)raliases}" && ret=0 _description expl 'reserved word' -compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0 +compadd "$expl[@]" "$@" - "${(k@)reswords}" && ret=0 diff --git a/Completion/Builtins/_zle b/Completion/Builtins/_zle index 327d67c62..a153aabdd 100644 --- a/Completion/Builtins/_zle +++ b/Completion/Builtins/_zle @@ -4,8 +4,8 @@ local expl if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then _description expl 'widget shell function' - compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)functions}" && ret=0 else _description expl widget - compadd "$expl[@]" - "${(@k)zlewidgets}" + compadd "$expl[@]" - "${(@k)widgets}" fi diff --git a/Completion/Builtins/_zmodload b/Completion/Builtins/_zmodload index a0d5987c4..097911307 100644 --- a/Completion/Builtins/_zmodload +++ b/Completion/Builtins/_zmodload @@ -4,7 +4,7 @@ local fl="$words[2]" expl if [[ "$fl" = -*(a*u|u*a)* || "$fl" = -*a* && CURRENT -ge 4 ]]; then _description expl 'builtin command' - compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0 + compadd "$expl[@]" "$@" - "${(k@)builtins}" && ret=0 elif [[ "$fl" = -*u* ]]; then _description expl module compadd "$expl[@]" - "${(@k)modules}" diff --git a/Doc/Zsh/mod_parameter.yo b/Doc/Zsh/mod_parameter.yo index 0cf44d4b1..cb2706767 100644 --- a/Doc/Zsh/mod_parameter.yo +++ b/Doc/Zsh/mod_parameter.yo @@ -27,36 +27,52 @@ hash table. ) vindex(functions) item(tt(functions))( -This association maps function names to their definitions. Setting a -key in it is like defining a function with the name given by the key -and the body given by the value. Unsetting a key removes the -definition for the function named by the key. +This association maps names of enabled functions to their +definitions. Setting a key in it is like defining a function with the +name given by the key and the body given by the value. Unsetting a key +removes the definition for the function named by the key. +) +vindex(disfunctions) +item(tt(disfunctions))( +Like tt(functions) but for disabled functions. ) vindex(builtins) item(tt(builtins))( This association gives information about the builtin commands -currently known. The keys are the names of the builtin commands and +currently enabled. The keys are the names of the builtin commands and the values are either `tt(undefined)' for builtin commands that will automatically be loaded from a module if invoked or `tt(defined)' for -builtin commands that are already loaded. Also, the string -`tt( )' will be prepended to the value if the builtin -command is currently disabled. +builtin commands that are already loaded. +) +vindex(disbuiltins) +item(tt(disbuiltins))( +Like tt(builtins) but for disabled builtin commands. ) vindex(reswords) item(tt(reswords))( -This association maps the reserved words to one of `tt()' or -`tt()' for enabled and disabled reserved words, respectively. +This array contains the enabled reserved words. +) +vindex(disreswords) +item(tt(disreswords))( +Like tt(reswords) but for disabled reserved words. ) vindex(raliases) item(tt(raliases))( -This maps the names of the regular aliases currently defined to their -expansions. For disabled aliases the string `tt()' is -prepended to their value. +This maps the names of the regular aliases currently enabled to their +expansions. +) +vindex(disraliases) +item(tt(disraliases))( +Like tt(raliases) but for disabled regular aliases. ) vindex(galiases) item(tt(galiases))( Like tt(raliases), but for global aliases. ) +vindex(disgaliases) +item(tt(disgaliases))( +Like tt(galiases) but for disabled global aliases. +) vindex(parameters) item(tt(parameters))( The keys in this associative array are the names of the parameters diff --git a/Doc/Zsh/mod_zleparameter.yo b/Doc/Zsh/mod_zleparameter.yo index cf79668e4..2f5f96367 100644 --- a/Doc/Zsh/mod_zleparameter.yo +++ b/Doc/Zsh/mod_zleparameter.yo @@ -8,12 +8,12 @@ ifnzman(noderef(Zsh Line Editor))\ ). startitem() -vindex(zlekeymaps) -item(tt(zlekeymaps))( +vindex(keymaps) +item(tt(keymaps))( This array contains the names of the keymaps currently defined. ) -vindex(zlewidgets) -item(tt(zlewidgets))( +vindex(widgets) +item(tt(widgets))( This associative array contains one entry per widget defined. The name of the widget is the key and the value gives information about the widget. It is either the string `tt(builtin)' for builtin widgets, a diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index edad0e468..36b4dd10e 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -331,17 +331,13 @@ scanpmcommands(HashTable ht, ScanFunc func, int flags) /**/ static void -setfunction(char *name, char *val) +setfunction(char *name, char *val, int dis) { char *value = dupstring(val); Shfunc shf; List list; - int sn, dis = 0; + int sn; - if (strpfx(" ", val)) { - strcpy(val, val + 11); - dis = DISABLED; - } val = metafy(val, strlen(val), META_REALLOC); HEAPALLOC { @@ -377,7 +373,14 @@ setfunction(char *name, char *val) static void setpmfunction(Param pm, char *value) { - setfunction(pm->nam, value); + setfunction(pm->nam, value, 0); +} + +/**/ +static void +setpmdisfunction(Param pm, char *value) +{ + setfunction(pm->nam, value, DISABLED); } /**/ @@ -392,7 +395,7 @@ unsetpmfunction(Param pm, int exp) /**/ static void -setpmfunctions(Param pm, HashTable ht) +setfunctions(Param pm, HashTable ht, int dis) { int i; HashNode hn; @@ -409,14 +412,28 @@ setpmfunctions(Param pm, HashTable ht) v.arr = NULL; v.pm = (Param) hn; - setfunction(hn->nam, ztrdup(getstrvalue(&v))); + setfunction(hn->nam, ztrdup(getstrvalue(&v)), dis); } deleteparamtable(ht); } +/**/ +static void +setpmfunctions(Param pm, HashTable ht) +{ + setfunctions(pm, ht, 0); +} + +/**/ +static void +setpmdisfunctions(Param pm, HashTable ht) +{ + setfunctions(pm, ht, DISABLED); +} + /**/ static HashNode -getpmfunction(HashTable ht, char *name) +getfunction(HashTable ht, char *name, int dis) { Shfunc shf; Param pm = NULL; @@ -425,7 +442,7 @@ getpmfunction(HashTable ht, char *name) pm = (Param) zhalloc(sizeof(struct param)); pm->nam = dupstring(name); pm->flags = PM_SCALAR; - pm->sets.cfn = setpmfunction; + pm->sets.cfn = (dis ? setpmdisfunction : setpmfunction); pm->gets.cfn = strgetfn; pm->unsetfn = unsetpmfunction; pm->ct = 0; @@ -434,7 +451,8 @@ getpmfunction(HashTable ht, char *name) pm->old = NULL; pm->level = 0; - if ((shf = (Shfunc) shfunctab->getnode2(shfunctab, name))) { + if ((shf = (Shfunc) shfunctab->getnode2(shfunctab, name)) && + (dis ? (shf->flags & DISABLED) : !(shf->flags & DISABLED))) { if (shf->flags & PM_UNDEFINED) { pm->u.str = dyncat("builtin autoload -X", ((shf->flags & PM_UNALIASED) ? @@ -444,8 +462,7 @@ getpmfunction(HashTable ht, char *name) char *t = getpermtext((void *) dupstruct((void *) shf->funcdef)), *h; - h = ((shf->flags & DISABLED) ? - dyncat(" ", t) : dupstring(t)); + h = dupstring(t); zsfree(t); unmetafy(h, NULL); @@ -460,16 +477,30 @@ getpmfunction(HashTable ht, char *name) return (HashNode) pm; } +/**/ +static HashNode +getpmfunction(HashTable ht, char *name) +{ + return getfunction(ht, name, 0); +} + +/**/ +static HashNode +getpmdisfunction(HashTable ht, char *name) +{ + return getfunction(ht, name, DISABLED); +} + /**/ static void -scanpmfunctions(HashTable ht, ScanFunc func, int flags) +scanfunctions(HashTable ht, ScanFunc func, int flags, int dis) { struct param pm; int i; HashNode hn; pm.flags = PM_SCALAR; - pm.sets.cfn = setpmcommand; + pm.sets.cfn = (dis ? setpmdisfunction : setpmfunction); pm.gets.cfn = strgetfn; pm.unsetfn = unsetpmcommand; pm.ct = 0; @@ -480,7 +511,7 @@ scanpmfunctions(HashTable ht, ScanFunc func, int flags) for (i = 0; i < shfunctab->hsize; i++) for (hn = shfunctab->nodes[i]; hn; hn = hn->next) { - if (!(hn->flags & DISABLED)) { + if (dis ? (hn->flags & DISABLED) : !(hn->flags & DISABLED)) { pm.nam = hn->nam; if (func != scancountparams) { if (((Shfunc) hn)->flags & PM_UNDEFINED) { @@ -494,9 +525,7 @@ scanpmfunctions(HashTable ht, ScanFunc func, int flags) char *t = getpermtext((void *) dupstruct((void *) ((Shfunc) hn)->funcdef)); - pm.u.str = ((hn->flags & DISABLED) ? - dyncat(" ", t) : - dupstring(t)); + pm.u.str = dupstring(t); unmetafy(pm.u.str, NULL); zsfree(t); } @@ -506,11 +535,25 @@ scanpmfunctions(HashTable ht, ScanFunc func, int flags) } } +/**/ +static void +scanpmfunctions(HashTable ht, ScanFunc func, int flags) +{ + scanfunctions(ht, func, flags, 0); +} + +/**/ +static void +scanpmdisfunctions(HashTable ht, ScanFunc func, int flags) +{ + scanfunctions(ht, func, flags, DISABLED); +} + /* Functions for the builtins special parameter. */ /**/ static HashNode -getpmbuiltin(HashTable ht, char *name) +getbuiltin(HashTable ht, char *name, int dis) { Param pm = NULL; Builtin bn; @@ -527,12 +570,12 @@ getpmbuiltin(HashTable ht, char *name) pm->ename = NULL; pm->old = NULL; pm->level = 0; - if ((bn = (Builtin) builtintab->getnode2(builtintab, name))) { + if ((bn = (Builtin) builtintab->getnode2(builtintab, name)) && + (dis ? (bn->flags & DISABLED) : !(bn->flags & DISABLED))) { char *t = ((bn->handlerfunc || (bn->flags & BINF_PREFIX)) ? "defined" : "undefined"); - pm->u.str = ((bn->flags & DISABLED) ? - dyncat(" ", t) : dupstring(t)); + pm->u.str = dupstring(t); } else { pm->u.str = dupstring(""); pm->flags |= PM_UNSET; @@ -542,9 +585,23 @@ getpmbuiltin(HashTable ht, char *name) return (HashNode) pm; } +/**/ +static HashNode +getpmbuiltin(HashTable ht, char *name) +{ + return getbuiltin(ht, name, 0); +} + +/**/ +static HashNode +getpmdisbuiltin(HashTable ht, char *name) +{ + return getbuiltin(ht, name, DISABLED); +} + /**/ static void -scanpmbuiltins(HashTable ht, ScanFunc func, int flags) +scanbuiltins(HashTable ht, ScanFunc func, int flags, int dis) { struct param pm; int i; @@ -562,78 +619,67 @@ scanpmbuiltins(HashTable ht, ScanFunc func, int flags) for (i = 0; i < builtintab->hsize; i++) for (hn = builtintab->nodes[i]; hn; hn = hn->next) { - pm.nam = hn->nam; - if (func != scancountparams) { - char *t = ((((Builtin) hn)->handlerfunc || - (hn->flags & BINF_PREFIX)) ? - "defined" : "undefined"); + if (dis ? (hn->flags & DISABLED) : !(hn->flags & DISABLED)) { + pm.nam = hn->nam; + if (func != scancountparams) { + char *t = ((((Builtin) hn)->handlerfunc || + (hn->flags & BINF_PREFIX)) ? + "defined" : "undefined"); - pm.u.str = ((((Builtin) hn)->flags & DISABLED) ? - dyncat(" ", t) : dupstring(t)); + pm.u.str = dupstring(t); + } + func((HashNode) &pm, flags); } - func((HashNode) &pm, flags); } } -/* Functions for the reswords special parameter. */ - /**/ -static HashNode -getpmresword(HashTable ht, char *name) +static void +scanpmbuiltins(HashTable ht, ScanFunc func, int flags) { - Param pm = NULL; - HashNode hn; - - HEAPALLOC { - pm = (Param) zhalloc(sizeof(struct param)); - pm->nam = dupstring(name); - pm->flags = PM_SCALAR | PM_READONLY; - pm->sets.cfn = NULL; - pm->gets.cfn = strgetfn; - pm->unsetfn = NULL; - pm->ct = 0; - pm->env = NULL; - pm->ename = NULL; - pm->old = NULL; - pm->level = 0; - if ((hn = reswdtab->getnode2(reswdtab, name))) - pm->u.str = dupstring((hn->flags & DISABLED) ? - "" : ""); - else { - pm->u.str = dupstring(""); - pm->flags |= PM_UNSET; - } - } LASTALLOC; - - return (HashNode) pm; + scanbuiltins(ht, func, flags, 0); } /**/ static void -scanpmreswords(HashTable ht, ScanFunc func, int flags) +scanpmdisbuiltins(HashTable ht, ScanFunc func, int flags) +{ + scanbuiltins(ht, func, flags, DISABLED); +} + +/* Functions for the reswords special parameter. */ + +/**/ +static char ** +getreswords(int dis) { - struct param pm; int i; HashNode hn; + char **ret, **p; - pm.flags = PM_SCALAR | PM_READONLY; - pm.sets.cfn = NULL; - pm.gets.cfn = strgetfn; - pm.unsetfn = NULL; - pm.ct = 0; - pm.env = NULL; - pm.ename = NULL; - pm.old = NULL; - pm.level = 0; + p = ret = (char **) zhalloc((reswdtab->ct + 1) * sizeof(char *)); for (i = 0; i < reswdtab->hsize; i++) - for (hn = reswdtab->nodes[i]; hn; hn = hn->next) { - pm.nam = hn->nam; - if (func != scancountparams) - pm.u.str = dupstring((hn->flags & DISABLED) ? - "" : ""); - func((HashNode) &pm, flags); - } + for (hn = reswdtab->nodes[i]; hn; hn = hn->next) + if (dis ? (hn->flags & DISABLED) : !(hn->flags & DISABLED)) + *p++ = dupstring(hn->nam); + *p = NULL; + + return ret; +} + +/**/ +static char ** +reswordsgetfn(Param pm) +{ + return getreswords(0); +} + +/**/ +static char ** +disreswordsgetfn(Param pm) +{ + return getreswords(DISABLED); } /* Functions for the options special parameter. */ @@ -925,6 +971,7 @@ scanpmmodules(HashTable ht, ScanFunc func, int flags) /* Functions for the dirstack special parameter. */ +/**/ static void dirssetfn(Param pm, char **x) { @@ -940,6 +987,7 @@ dirssetfn(Param pm, char **x) freearray(x); } +/**/ static char ** dirsgetfn(Param pm) { @@ -1019,6 +1067,7 @@ scanpmhistory(HashTable ht, ScanFunc func, int flags) /* Function for the historywords special parameter. */ +/**/ static char ** histwgetfn(Param pm) { @@ -1050,6 +1099,7 @@ histwgetfn(Param pm) /* Functions for the jobtexts special parameter. */ +/**/ static char * pmjobtext(int job) { @@ -1137,6 +1187,7 @@ scanpmjobtexts(HashTable ht, ScanFunc func, int flags) /* Functions for the jobstates special parameter. */ +/**/ static char * pmjobstate(int job) { @@ -1437,31 +1488,47 @@ scanpmuserdirs(HashTable ht, ScanFunc func, int flags) /**/ static void -setpmralias(Param pm, char *value) +setralias(Param pm, char *value, int dis) { - int dis = 0; - - if (strpfx(" ", value)) { - strcpy(value, value + 11); - dis = DISABLED; - } aliastab->addnode(aliastab, ztrdup(pm->nam), createaliasnode(value, dis)); } /**/ static void -setpmgalias(Param pm, char *value) +setpmralias(Param pm, char *value) { - int dis = 0; + setralias(pm, value, 0); +} - if (strpfx(" ", value)) { - strcpy(value, value + 11); - dis = DISABLED; - } +/**/ +static void +setpmdisralias(Param pm, char *value) +{ + setralias(pm, value, DISABLED); +} + +/**/ +static void +setgalias(Param pm, char *value, int dis) +{ aliastab->addnode(aliastab, ztrdup(pm->nam), createaliasnode(value, dis | ALIAS_GLOBAL)); } +/**/ +static void +setpmgalias(Param pm, char *value) +{ + setgalias(pm, value, 0); +} + +/**/ +static void +setpmdisgalias(Param pm, char *value) +{ + setgalias(pm, value, DISABLED); +} + /**/ static void unsetpmalias(Param pm, int exp) @@ -1474,7 +1541,7 @@ unsetpmalias(Param pm, int exp) /**/ static void -setpmaliases(Param pm, HashTable ht, int global) +setaliases(Param pm, HashTable ht, int global, int dis) { int i; HashNode hn, next, hd; @@ -1504,7 +1571,8 @@ setpmaliases(Param pm, HashTable ht, int global) if ((val = getstrvalue(&v))) aliastab->addnode(aliastab, ztrdup(hn->nam), createaliasnode(ztrdup(val), - (global ? ALIAS_GLOBAL : 0))); + (global ? ALIAS_GLOBAL : 0) | + (dis ? DISABLED : 0))); } deleteparamtable(ht); } @@ -1513,19 +1581,33 @@ setpmaliases(Param pm, HashTable ht, int global) static void setpmraliases(Param pm, HashTable ht) { - setpmaliases(pm, ht, 0); + setaliases(pm, ht, 0, 0); +} + +/**/ +static void +setpmdisraliases(Param pm, HashTable ht) +{ + setaliases(pm, ht, 0, DISABLED); } /**/ static void setpmgaliases(Param pm, HashTable ht) { - setpmaliases(pm, ht, 1); + setaliases(pm, ht, 1, 0); +} + +/**/ +static void +setpmdisgaliases(Param pm, HashTable ht) +{ + setaliases(pm, ht, 1, DISABLED); } /**/ static HashNode -getpmalias(HashTable ht, char *name, int global) +getalias(HashTable ht, char *name, int global, int dis) { Param pm = NULL; Alias al; @@ -1534,7 +1616,8 @@ getpmalias(HashTable ht, char *name, int global) pm = (Param) zhalloc(sizeof(struct param)); pm->nam = dupstring(name); pm->flags = PM_SCALAR; - pm->sets.cfn = (global ? setpmgalias : setpmralias); + pm->sets.cfn = (global ? (dis ? setpmdisgalias : setpmgalias) : + (dis ? setpmdisralias : setpmralias)); pm->gets.cfn = strgetfn; pm->unsetfn = unsetpmalias; pm->ct = 0; @@ -1544,10 +1627,9 @@ getpmalias(HashTable ht, char *name, int global) pm->level = 0; if ((al = (Alias) aliastab->getnode2(aliastab, name)) && ((global && (al->flags & ALIAS_GLOBAL)) || - (!global && !(al->flags & ALIAS_GLOBAL)))) - pm->u.str = ((al->flags & DISABLED) ? - dyncat(" ", al->text) : - dupstring(al->text)); + (!global && !(al->flags & ALIAS_GLOBAL))) && + (dis ? (al->flags & DISABLED) : !(al->flags & DISABLED))) + pm->u.str = dupstring(al->text); else { pm->u.str = dupstring(""); pm->flags |= PM_UNSET; @@ -1561,19 +1643,33 @@ getpmalias(HashTable ht, char *name, int global) static HashNode getpmralias(HashTable ht, char *name) { - return getpmalias(ht, name, 0); + return getalias(ht, name, 0, 0); +} + +/**/ +static HashNode +getpmdisralias(HashTable ht, char *name) +{ + return getalias(ht, name, 0, 0); } /**/ static HashNode getpmgalias(HashTable ht, char *name) { - return getpmalias(ht, name, 1); + return getalias(ht, name, 1, 0); +} + +/**/ +static HashNode +getpmdisgalias(HashTable ht, char *name) +{ + return getalias(ht, name, 1, DISABLED); } /**/ static void -scanpmaliases(HashTable ht, ScanFunc func, int flags, int global) +scanaliases(HashTable ht, ScanFunc func, int flags, int global, int dis) { struct param pm; int i; @@ -1581,7 +1677,8 @@ scanpmaliases(HashTable ht, ScanFunc func, int flags, int global) Alias al; pm.flags = PM_SCALAR; - pm.sets.cfn = (global ? setpmgalias : setpmralias); + pm.sets.cfn = (global ? (dis ? setpmdisgalias : setpmgalias) : + (dis ? setpmdisralias : setpmralias)); pm.gets.cfn = strgetfn; pm.unsetfn = unsetpmalias; pm.ct = 0; @@ -1592,13 +1689,12 @@ scanpmaliases(HashTable ht, ScanFunc func, int flags, int global) for (i = 0; i < aliastab->hsize; i++) for (hn = aliastab->nodes[i]; hn; hn = hn->next) { - if ((global && ((al = (Alias) hn)->flags & ALIAS_GLOBAL)) || - (!global && !((al = (Alias) hn)->flags & ALIAS_GLOBAL))) { + if (((global && ((al = (Alias) hn)->flags & ALIAS_GLOBAL)) || + (!global && !((al = (Alias) hn)->flags & ALIAS_GLOBAL))) && + (dis ? (al->flags & DISABLED) : !(al->flags & DISABLED))) { pm.nam = hn->nam; if (func != scancountparams) - pm.u.str = ((hn->flags & DISABLED) ? - dyncat(" ", al->text) : - dupstring(al->text)); + pm.u.str = dupstring(al->text); func((HashNode) &pm, flags); } } @@ -1608,14 +1704,28 @@ scanpmaliases(HashTable ht, ScanFunc func, int flags, int global) static void scanpmraliases(HashTable ht, ScanFunc func, int flags) { - scanpmaliases(ht, func, flags, 0); + scanaliases(ht, func, flags, 0, 0); +} + +/**/ +static void +scanpmdisraliases(HashTable ht, ScanFunc func, int flags) +{ + scanaliases(ht, func, flags, 0, DISABLED); } /**/ static void scanpmgaliases(HashTable ht, ScanFunc func, int flags) { - scanpmaliases(ht, func, flags, 1); + scanaliases(ht, func, flags, 1, 0); +} + +/**/ +static void +scanpmdisgaliases(HashTable ht, ScanFunc func, int flags) +{ + scanpmaliases(ht, func, flags, 1, DISABLED); } /* Table for defined parameters. */ @@ -1642,25 +1752,34 @@ static struct pardef partab[] = { { "functions", 0, getpmfunction, scanpmfunctions, setpmfunctions, NULL, NULL, stdunsetfn, NULL }, + { "disfunctions", 0, + getpmdisfunction, scanpmdisfunctions, setpmdisfunctions, + NULL, NULL, stdunsetfn, NULL }, { "builtins", PM_READONLY, getpmbuiltin, scanpmbuiltins, hashsetfn, NULL, NULL, stdunsetfn, NULL }, - { "reswords", PM_READONLY, - getpmresword, scanpmreswords, hashsetfn, + { "disbuiltins", PM_READONLY, + getpmdisbuiltin, scanpmdisbuiltins, hashsetfn, NULL, NULL, stdunsetfn, NULL }, + { "reswords", PM_ARRAY|PM_SPECIAL|PM_READONLY, + NULL, NULL, NULL, + arrsetfn, reswordsgetfn, stdunsetfn, NULL }, + { "disreswords", PM_ARRAY|PM_SPECIAL|PM_READONLY, + NULL, NULL, NULL, + arrsetfn, disreswordsgetfn, stdunsetfn, NULL }, { "options", 0, getpmoption, scanpmoptions, setpmoptions, NULL, NULL, stdunsetfn, NULL }, { "modules", PM_READONLY, getpmmodule, scanpmmodules, hashsetfn, NULL, NULL, stdunsetfn, NULL }, - { "dirstack", PM_ARRAY|PM_HIDE|PM_SPECIAL|PM_REMOVABLE, + { "dirstack", PM_ARRAY|PM_SPECIAL|PM_REMOVABLE, NULL, NULL, NULL, dirssetfn, dirsgetfn, stdunsetfn, NULL }, { "history", PM_READONLY, getpmhistory, scanpmhistory, hashsetfn, NULL, NULL, stdunsetfn, NULL }, - { "historywords", PM_ARRAY|PM_HIDE|PM_SPECIAL|PM_READONLY, + { "historywords", PM_ARRAY|PM_SPECIAL|PM_READONLY, NULL, NULL, NULL, arrsetfn, histwgetfn, stdunsetfn, NULL }, { "jobtexts", PM_READONLY, @@ -1681,6 +1800,12 @@ static struct pardef partab[] = { { "galiases", 0, getpmgalias, scanpmgaliases, setpmgaliases, NULL, NULL, stdunsetfn, NULL }, + { "disraliases", 0, + getpmdisralias, scanpmdisraliases, setpmdisraliases, + NULL, NULL, stdunsetfn, NULL }, + { "disgaliases", 0, + getpmdisgalias, scanpmdisgaliases, setpmdisgaliases, + NULL, NULL, stdunsetfn, NULL }, { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL } }; @@ -1715,7 +1840,7 @@ boot_parameter(Module m) if (def->hsetfn) def->pm->sets.hfn = def->hsetfn; } else { - if (!(def->pm = createparam(def->name, def->flags))) + if (!(def->pm = createparam(def->name, def->flags | PM_HIDE))) return 1; def->pm->sets.afn = def->setfn; def->pm->gets.afn = def->getfn; diff --git a/Src/Modules/parameter.mdd b/Src/Modules/parameter.mdd index 715b1ab55..e26d8c70a 100644 --- a/Src/Modules/parameter.mdd +++ b/Src/Modules/parameter.mdd @@ -1,3 +1,3 @@ -autoparams="parameters commands functions builtins reswords options modules dirstack history historywords jobtexts jobstates nameddirs userdirs raliases galiases" +autoparams="parameters commands functions disfunctions builtins disbuiltins reswords disreswords options modules dirstack history historywords jobtexts jobstates nameddirs userdirs raliases disraliases galiases disgaliases" objects="parameter.o" diff --git a/Src/Zle/zleparameter.c b/Src/Zle/zleparameter.c index 8a5bc0bc2..dc778eb08 100644 --- a/Src/Zle/zleparameter.c +++ b/Src/Zle/zleparameter.c @@ -185,10 +185,10 @@ struct pardef { }; static struct pardef partab[] = { - { "zlewidgets", PM_READONLY, + { "widgets", PM_READONLY, getpmwidgets, scanpmwidgets, hashsetfn, NULL, NULL, stdunsetfn, NULL }, - { "zlekeymaps", PM_ARRAY|PM_HIDE|PM_SPECIAL|PM_READONLY, + { "keymaps", PM_ARRAY|PM_HIDE|PM_SPECIAL|PM_READONLY, NULL, NULL, NULL, arrsetfn, keymapsgetfn, stdunsetfn, NULL }, { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL } diff --git a/Src/Zle/zleparameter.mdd b/Src/Zle/zleparameter.mdd index f9d528661..d18b89662 100644 --- a/Src/Zle/zleparameter.mdd +++ b/Src/Zle/zleparameter.mdd @@ -1,5 +1,5 @@ moddeps="zle" -autoparams="zlewidgets zlekeymaps" +autoparams="widgets keymaps" objects="zleparameter.o" -- cgit 1.4.1