* Compsys and KSH_AUTOLOAD @ 2004-04-10 17:44 Bart Schaefer 2004-04-12 14:00 ` Oliver Kiddle 2004-04-14 19:55 ` Peter Stephenson 0 siblings, 2 replies; 20+ messages in thread From: Bart Schaefer @ 2004-04-10 17:44 UTC (permalink / raw) To: zsh-workers I've been having an off-list discussion with Matthias Kopfermann about trouble he's had using the completion system with KSH_AUTOLOAD set. He tried the "zcompile -z" stuff (actually the zrecompile loop) suggested in the manual, but it didn't work for him (I haven't investigated that yet). In glancing through compinit I noted that NO_kshautoload is conspicuously absent from _comp_options. So I tried this: #--- 8< --- snip --- autoload +X -z compinit _main_complete _complete_help _complete_debug \ _expand_alias _bash_completions _history_complete_word _next_tags compinit # Append your usual options _comp_options+=(NO_kshautoload) # Need 4.2.x for += to work #--- 8< --- snip --- The list of functions after compinit in the autoload line are all those that eval $_comp_setup -- that is, all the "entry points" to compsys, or at least all the correctly-implemented entry points. (_complete_debug doesn't do the eval, but it's just a wrapper around _main_complete.) This seems to work out just fine in my tests (I haven't heard back from Matthias yet). Which brings me to my questions: (1) Does this deserve a FAQ entry, or perhaps even a change to the compsys documentation? I guess ksh_autoload isn't a very "frequently" used option, but even the existing paragraph in the manual about it not working is pretty deeply buried. (2) Should we change _comp_options to always include NO_kshautoload? (3) Should we change compinit to run the autoload +X -z of the entry points iff kshautoload is set? (4) If the answer to (3) is "yes," should we have some sort of flag to identify such entry points so we don't need to maintain an accurate list in compinit? For those like _main_complete that have an #autoload line, we could just append "-z" to that, but e.g. _expand_alias is a widget and has a #compdef line instead. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Compsys and KSH_AUTOLOAD 2004-04-10 17:44 Compsys and KSH_AUTOLOAD Bart Schaefer @ 2004-04-12 14:00 ` Oliver Kiddle 2004-04-12 15:59 ` Bart Schaefer 2004-04-14 19:55 ` Peter Stephenson 1 sibling, 1 reply; 20+ messages in thread From: Oliver Kiddle @ 2004-04-12 14:00 UTC (permalink / raw) To: zsh-workers Bart wrote: > I've been having an off-list discussion with Matthias Kopfermann about > trouble he's had using the completion system with KSH_AUTOLOAD set. He > tried the "zcompile -z" stuff (actually the zrecompile loop) suggested > in the manual, but it didn't work for him (I haven't investigated that It is only for compinit itself that I can get problems with that to occur. It seems to be a little sensitive about the contents of $fpath but the following works for me: zcompile -z -U comp /usr/local/share/zsh/4.2.0/functions/Completion/**/*(.) zsh -f fpath=( ~/comp.zwc $fpath ) setopt kshautoload autoload compinit compinit compinit ought to be able to look inside the .zwc file so you don't even need the functions to be there. > So I tried this: > > #--- 8< --- snip --- > autoload +X -z compinit _main_complete _complete_help _complete_debug \ > _expand_alias _bash_completions _history_complete_word _next_tags > compinit # Append your usual options > _comp_options+=(NO_kshautoload) # Need 4.2.x for += to work > #--- 8< --- snip --- > (1) Does this deserve a FAQ entry, or perhaps even a change to the > compsys documentation? I guess ksh_autoload isn't a very "frequently" It'd be better if we can get it to just work. > (2) Should we change _comp_options to always include NO_kshautoload? I'd prefer if we can avoid adding to _comp_options. > (3) Should we change compinit to run the autoload +X -z of the entry > points iff kshautoload is set? This is one option and if we took it, we'd want to go with (4) so user's can add their own entry point functions. It is just adding more complexity though. Also, looking at the list of entry points, there are functions I never use, making autoload +X a waste of time and memory. Is there any reason why the -z and -k options to autoload can only be used with +X. It would seem to me that the best would be if compinit could use `autoload -U -z' with functions being setup to look like this: _autoload () { # undefined builtin autoload -XUz } Would that be a possibilty? Oliver ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Compsys and KSH_AUTOLOAD 2004-04-12 14:00 ` Oliver Kiddle @ 2004-04-12 15:59 ` Bart Schaefer 2004-04-12 21:43 ` Oliver Kiddle 0 siblings, 1 reply; 20+ messages in thread From: Bart Schaefer @ 2004-04-12 15:59 UTC (permalink / raw) To: zsh-workers On Apr 12, 4:00pm, Oliver Kiddle wrote: > > Bart wrote: > > tried the "zcompile -z" stuff (actually the zrecompile loop) suggested > > in the manual, but it didn't work for him (I haven't investigated that > > It is only for compinit itself that I can get problems with that to > occur. It seems to be a little sensitive about the contents of $fpath Matthias has since written back to me again and says he's having all sorts of problems with zcompile'd functions even after starting from scratch and with ksh_autoload turned off. So the issue of documenting the "correct" way to use compsys with kshautoload is separate. > > autoload +X -z compinit _main_complete _complete_help _complete_debug \ > > _expand_alias _bash_completions _history_complete_word _next_tags > > > (1) Does this deserve a FAQ entry, or perhaps even a change to the > > compsys documentation? I guess ksh_autoload isn't a very "frequently" > > It'd be better if we can get it to just work. I don't specifically mean "does the above workaround deserve a FAQ entry" but rather "does using compsys with kshautoload deserve a FAQ entry", whatever the best A to the Q turns out to be. > Is there any reason why the -z and -k options to autoload can only be > used with +X The autoload method used isn't stored anywhere in the function structure. Only the fact that the function is not yet defined is stored, and then zsh applies whatever autoload setting is in effect globally at the time that the function is loaded. I suppose we could modify the storage and the code that does autoloading [as opposed to modifying only bin_autoload()]; I forget why I didn't do so at the time -- probably because it was a significantly larger change. > It would seem to me that the best would be if compinit could use > `autoload -U -z' with functions being setup to look like this: > > _autoload () { > # undefined > builtin autoload -XUz > } Please note that undefined functions don't actually have any function body at all. The "functions" command creates a dummy body when it outputs a function that has no definition. So it's not just a matter of changing the dummy body. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Compsys and KSH_AUTOLOAD 2004-04-12 15:59 ` Bart Schaefer @ 2004-04-12 21:43 ` Oliver Kiddle 2004-04-13 5:32 ` While we're on the subject of zcompile Bart Schaefer 2004-04-13 5:38 ` Compsys and KSH_AUTOLOAD Bart Schaefer 0 siblings, 2 replies; 20+ messages in thread From: Oliver Kiddle @ 2004-04-12 21:43 UTC (permalink / raw) To: zsh-workers Bart wrote: > Matthias has since written back to me again and says he's having all sorts > of problems with zcompile'd functions even after starting from scratch and I've had problems with it in the past so it probably needs more investigation. > I don't specifically mean "does the above workaround deserve a FAQ entry" > but rather "does using compsys with kshautoload deserve a FAQ entry", > whatever the best A to the Q turns out to be. It probably does deserve an FAQ entry. The minimum possible A to the Q will be to use -z when using autoload for compinit. With that we either need an FAQ or to suggest the -z everywhere we show the autoload -U compinit. > The autoload method used isn't stored anywhere in the function structure. > Only the fact that the function is not yet defined is stored, and then zsh > applies whatever autoload setting is in effect globally at the time that > the function is loaded. Presumably it also stores whether the function was autoloaded with the -U option. Looks like there is a PM_UNALIASED flag. Maybe we can just add PM_ZSHSTORED and PM_KSHSTORED flags. > I suppose we could modify the storage and the code that does autoloading > [as opposed to modifying only bin_autoload()]; I forget why I didn't do > so at the time -- probably because it was a significantly larger change. It just needs a bit of investigation then to see if there was a more fundamental reason. I was wondering if there was some clash with typeset options (autoload being a variant of it). Hopefully not. Oliver ^ permalink raw reply [flat|nested] 20+ messages in thread
* While we're on the subject of zcompile ... 2004-04-12 21:43 ` Oliver Kiddle @ 2004-04-13 5:32 ` Bart Schaefer 2004-04-17 21:08 ` Oliver Kiddle 2004-04-13 5:38 ` Compsys and KSH_AUTOLOAD Bart Schaefer 1 sibling, 1 reply; 20+ messages in thread From: Bart Schaefer @ 2004-04-13 5:32 UTC (permalink / raw) To: zsh-workers On Apr 12, 11:43pm, Oliver Kiddle wrote: } } Bart wrote: } } > Matthias has since written back to me again and says he's having all } > sorts of problems with zcompile'd functions } } I've had problems with it in the past so it probably needs more } investigation. I find the behavior of "zcompile -a" (with no arguments) to be extremely annoying. There should be a way to say "dump all the functions you can, and ignore the ones that are already loaded or can't be loaded" rather than having it die entirely (blowing away the dump done so far) the first time it encounters an un-dumpable function. For one thing, if I've said "zcompile -a" with no arguments, then the chances are pretty good that I didn't intend for it to even try to dump already-loaded functions; if I wanted both, I'd have used "-c -a". For another, there's no way to tell in advance whether a function is going to fail to autoload, so it's practically impossible to create a list of names to pass as arguments. The questions are whether it's cur_add_func() that should be taught to ignore the error, or build_cur_dump(), and whether it should happen any time there are no arguments, or there should be a flag to cause errors to be ignored. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: While we're on the subject of zcompile ... 2004-04-13 5:32 ` While we're on the subject of zcompile Bart Schaefer @ 2004-04-17 21:08 ` Oliver Kiddle 0 siblings, 0 replies; 20+ messages in thread From: Oliver Kiddle @ 2004-04-17 21:08 UTC (permalink / raw) To: zsh-workers On 13 Apr, Bart wrote: > > I find the behavior of "zcompile -a" (with no arguments) to be extremely > annoying. There should be a way to say "dump all the functions you can, > and ignore the ones that are already loaded or can't be loaded" rather > than having it die entirely (blowing away the dump done so far) the first > time it encounters an un-dumpable function. It is annoying. I'd have thought it would make sense if `zcompile -c' alone only attempted to dump loaded functions and `zcompile -a' only attempted to dump not-loaded functions. Errors for functions which fail to load are more reasonable, though. > The questions are whether it's cur_add_func() that should be taught to > ignore the error, or build_cur_dump(), and whether it should happen any > time there are no arguments, or there should be a flag to cause errors > to be ignored. I'd vote for it happening any time. The zcompile completion was not completing functions after -a and is missing the fact that -k and -z options can be used more than once between listed functions so below is an update. This also avoids the irritating double filename completion. Oliver --- Completion/Zsh/Command/_zcompile 2001-04-02 13:32:47.000000000 +0200 +++ Completion/Zsh/Command/_zcompile 2004-04-17 23:03:57.000000000 +0200 @@ -3,23 +3,26 @@ local state line expl curcontext="$curcontext" ret=1 typeset -A opt_args -_arguments -C -s -A "-*" -S \ - '(-t -c -m -a)-U[don'\''t expand aliases]' \ +_arguments -C -s \ + "(-t -c -m -a)-U[don't expand aliases]" \ '(-t -M)-R[mark as read]' \ '(-t -R)-M[mark as mapped]' \ - '(-t -c -z -m -a)-k[ksh-style autoloading]' \ - '(-t -c -k -m -a)-z[zsh-style autoloading]' \ + '(-t -c -m -a)*-k[ksh-style autoloading]' \ + '(-t -c -m -a)*-z[zsh-style autoloading]' \ '(-t -U -z -k)-c[currently defined functions]' \ '(-t -U -z -k)-m[use names as patterns]' \ '(-t -U -z -k)-a[write autoload functions]' \ '(-M -R -U -z -k -a -c -m)-t[show table of contents]' \ - ':zwc file:_files' \ + '(-M -R -U -a -c -m -t):file:->file' \ '*:function:->function' && ret=0 -if (( $+opt_args[-c] )); then +if [[ $state = function && -n $opt_args[(i)-[ac]] ]]; then _wanted functions expl 'function to write' compadd -k functions && ret=0 +elif [[ -n $opt_args[(i)-[tca]] ]]; then + _description files expl 'zwc file' + _files -g '*.zwc(-.)' "$expl[@]" && ret=0 else - _description files expl 'zsh source file' + _description files expl 'file' _files "$expl[@]" && ret=0 fi ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Compsys and KSH_AUTOLOAD 2004-04-12 21:43 ` Oliver Kiddle 2004-04-13 5:32 ` While we're on the subject of zcompile Bart Schaefer @ 2004-04-13 5:38 ` Bart Schaefer 2004-04-13 15:29 ` PATCH: " Oliver Kiddle 1 sibling, 1 reply; 20+ messages in thread From: Bart Schaefer @ 2004-04-13 5:38 UTC (permalink / raw) To: zsh-workers On Apr 12, 11:43pm, Oliver Kiddle wrote: } } Bart wrote: } } > The autoload method used isn't stored anywhere in the function structure. } } Presumably it also stores whether the function was autoloaded with the } -U option. Looks like there is a PM_UNALIASED flag. Maybe we can just } add PM_ZSHSTORED and PM_KSHSTORED flags. Yes, that would probably work. Here's a possibly-silly idea: Those flags could be made to apply to arrays as well as functions, so one could have both zero-based and one- based indexing independent of the ksharrays option. (-k and -z are not currently used by typeset except in its autoload incarnation.) ^ permalink raw reply [flat|nested] 20+ messages in thread
* PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-13 5:38 ` Compsys and KSH_AUTOLOAD Bart Schaefer @ 2004-04-13 15:29 ` Oliver Kiddle 2004-04-13 17:51 ` Bart Schaefer 2004-04-14 5:04 ` Bart Schaefer 0 siblings, 2 replies; 20+ messages in thread From: Oliver Kiddle @ 2004-04-13 15:29 UTC (permalink / raw) To: zsh-workers Bart wrote: > } Presumably it also stores whether the function was autoloaded with the > } -U option. Looks like there is a PM_UNALIASED flag. Maybe we can just > } add PM_ZSHSTORED and PM_KSHSTORED flags. > > Yes, that would probably work. It seems to. Try the patch below. If autoload -X/+X is used with -k/-z options, those take precedence over any set in the flags. It's not in the patch but I've tried replacing `autoload -U' with `autoload -Uz' in compinit/compdump and new completion seems to then work with kshautoload set. Should I make that change? In addition to documentation changes, I also need to make the new options work for functions and typeset -f. Shouldn't running just `functions -U' restrict the listed options to those with PM_UNALIASED set? At the moment, it isn't entirely consistent with typeset. What should `functions +U' do? > Here's a possibly-silly idea: Those flags could be made to apply to > arrays as well as functions, so one could have both zero-based and one- > based indexing independent of the ksharrays option. (-k and -z are not > currently used by typeset except in its autoload incarnation.) It's not a bad idea, if it isn't hard to implement. Can you think of cases where you would want a zero-based array? Oliver Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.114 diff -u -r1.114 builtin.c --- Src/builtin.c 6 Apr 2004 09:25:18 -0000 1.114 +++ Src/builtin.c 13 Apr 2004 15:07:16 -0000 @@ -2406,9 +2406,16 @@ on |= PM_TAGGED; else if (OPT_PLUS(ops,'t')) off |= PM_TAGGED; + if (OPT_MINUS(ops,'z')) + on |= PM_ZSHSTORED; + else if (OPT_PLUS(ops,'z')) + off |= PM_ZSHSTORED; + if (OPT_MINUS(ops,'k')) + on |= PM_KSHSTORED; + else if (OPT_PLUS(ops,'k')) + off |= PM_KSHSTORED; if ((off & PM_UNDEFINED) || (OPT_ISSET(ops,'k') && OPT_ISSET(ops,'z')) || - (!OPT_PLUS(ops,'X') && (OPT_ISSET(ops,'k') || OPT_ISSET(ops,'z'))) || (OPT_MINUS(ops,'X') && (OPT_ISSET(ops,'m') || *argv || !scriptname))) { zwarnnam(name, "invalid option(s)", NULL, 0); return 1; Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.59 diff -u -r1.59 exec.c --- Src/exec.c 6 Apr 2004 09:25:18 -0000 1.59 +++ Src/exec.c 13 Apr 2004 15:07:16 -0000 @@ -3398,8 +3398,12 @@ prog = getfpfunc(shf->nam, &ksh); noaliases = noalias; - if (ksh == 1) + if (ksh == 1) { ksh = fksh; + if (ksh == 1) + ksh = (shf->flags & PM_KSHSTORED) ? 2 : + (shf->flags & PM_ZSHSTORED) ? 0 : 1; + } if (prog == &dummy_eprog) { /* We're not actually in the function; decrement locallevel */ Index: Src/hashtable.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v retrieving revision 1.17 diff -u -r1.17 hashtable.c --- Src/hashtable.c 11 Mar 2004 14:25:12 -0000 1.17 +++ Src/hashtable.c 13 Apr 2004 15:07:16 -0000 @@ -863,7 +863,7 @@ printshfuncnode(HashNode hn, int printflags) { Shfunc f = (Shfunc) hn; - char *t; + char *t = 0; if ((printflags & PRINT_NAMEONLY) || ((printflags & PRINT_WHENCE_SIMPLE) && @@ -881,32 +881,35 @@ return; } - if (f->flags & PM_UNDEFINED) - t = tricat("builtin autoload -X", - ((f->flags & PM_UNALIASED)? "U" : ""), - ((f->flags & PM_TAGGED)? "t" : "")); - else { - if (!f->funcdef) - t = 0; - else - t = getpermtext(f->funcdef, NULL); - } - quotedzputs(f->nam, stdout); - if (t) { + if (f->funcdef || f->flags & PM_UNDEFINED) { printf(" () {\n\t"); if (f->flags & PM_UNDEFINED) printf("%c undefined\n\t", hashchar); + else + t = getpermtext(f->funcdef, NULL); if (f->flags & PM_TAGGED) printf("%c traced\n\t", hashchar); - zputs(t, stdout); - if (f->funcdef && (f->funcdef->flags & EF_RUN)) { - printf("\n\t"); - quotedzputs(f->nam, stdout); - printf(" \"$@\""); - } + if (!t) { + char *fopt = "Utkz"; + int flgs[] = { + PM_UNALIASED, PM_TAGGED, PM_KSHSTORED, PM_ZSHSTORED, 0 + }; + int fl;; + + zputs("builtin autoload -X", stdout); + for (fl=0;fopt[fl];fl++) + if (f->flags & flgs[fl]) putchar(fopt[fl]); + } else { + zputs(t, stdout); + zsfree(t); + if (f->funcdef->flags & EF_RUN) { + printf("\n\t"); + quotedzputs(f->nam, stdout); + printf(" \"$@\""); + } + } printf("\n}\n"); - zsfree(t); } else { printf(" () { }\n"); } Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.54 diff -u -r1.54 zsh.h --- Src/zsh.h 11 Mar 2004 14:25:12 -0000 1.54 +++ Src/zsh.h 13 Apr 2004 15:07:16 -0000 @@ -1197,6 +1197,9 @@ #define PM_HIDEVAL (1<<15) /* Value not shown in `typeset' commands */ #define PM_TIED (1<<16) /* array tied to colon-path or v.v. */ +#define PM_KSHSTORED (1<<17) /* function stored in ksh form */ +#define PM_ZSHSTORED (1<<18) /* function stored in zsh form */ + /* Remaining flags do not correspond directly to command line arguments */ #define PM_LOCAL (1<<21) /* this parameter will be made local */ #define PM_SPECIAL (1<<22) /* special builtin parameter */ @@ -1210,7 +1213,7 @@ #define PM_NAMEDDIR (1<<30) /* has a corresponding nameddirtab entry */ /* The option string corresponds to the first of the variables above */ -#define TYPESET_OPTSTR "aiEFALRZlurtxUhHT" +#define TYPESET_OPTSTR "aiEFALRZlurtxUhHTkz" /* These typeset options take an optional numeric argument */ #define TYPESET_OPTNUM "LRZiEF" ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-13 15:29 ` PATCH: " Oliver Kiddle @ 2004-04-13 17:51 ` Bart Schaefer 2004-04-16 16:49 ` Oliver Kiddle 2004-04-14 5:04 ` Bart Schaefer 1 sibling, 1 reply; 20+ messages in thread From: Bart Schaefer @ 2004-04-13 17:51 UTC (permalink / raw) To: zsh-workers On Apr 13, 5:29pm, Oliver Kiddle wrote: } } It's not in the patch but I've tried replacing `autoload -U' with } `autoload -Uz' in compinit/compdump and new completion seems to then } work with kshautoload set. Should I make that change? I think so. } In addition to documentation changes, I also need to make the new } options work for functions and typeset -f. Shouldn't running just } `functions -U' restrict the listed options to those with PM_UNALIASED } set? That'd be nice. } At the moment, it isn't entirely consistent with typeset. What } should `functions +U' do? List only the names of the functions with PM_UNALIASED set, whereas -U lists the entire definition (such as it is). } > Here's a possibly-silly idea: Those flags could be made to apply to } > arrays as well as functions } } It's not a bad idea, if it isn't hard to implement. Can you think of } cases where you would want a zero-based array? Well, if you have ksh_autoload set, then chances are you're loading some ksh functions, which means you probably also have ksh_arrays set. So the real question is whether there are cases where one would want one-based arrays; the opposite is just for logical symmetry. ^ permalink raw reply [flat|nested] 20+ messages in thread
* PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-13 17:51 ` Bart Schaefer @ 2004-04-16 16:49 ` Oliver Kiddle 2004-04-16 17:25 ` Bart Schaefer 2004-04-16 17:30 ` Bart Schaefer 0 siblings, 2 replies; 20+ messages in thread From: Oliver Kiddle @ 2004-04-16 16:49 UTC (permalink / raw) To: zsh-workers This is part 2 for the patch I sent in 19767 and should be applied on top of it. This changes the documentation and completion functions along with allowing -k and -z to be used with typeset -f or functions. The completion system also now uses the -z option to autoload though kshautoload using users will need to specify it when autoloading compinit. Why do export and readonly accept -f arguments? Is that just to avoid errors on bash scripts? Any reason why we shouldn't implement readonly functions. On 13 Apr, Bart wrote: > > } In addition to documentation changes, I also need to make the new > } options work for functions and typeset -f. Shouldn't running just > } `functions -U' restrict the listed options to those with PM_UNALIASED > } set? Seems I was wrong: it does already. (I probably got confused because my test function got autoloaded with -U from my .zshrc. Sorry for the noise.) > } At the moment, it isn't entirely consistent with typeset. What > } should `functions +U' do? > > List only the names of the functions with PM_UNALIASED set, whereas -U > lists the entire definition (such as it is). I've left this alone for now. To list only names, you can use `functions +' or `typeset +f'. I'm inclined to think it would be better if +U caused it to restrict listed functions to those where PM_UNALIASED is unset. Same goes for all typeset options. Any views? > } > Here's a possibly-silly idea: Those flags could be made to apply to > } > arrays as well as functions > Well, if you have ksh_autoload set, then chances are you're loading some > ksh functions, which means you probably also have ksh_arrays set. So the > real question is whether there are cases where one would want one-based > arrays; the opposite is just for logical symmetry. But someone with ksh_autoload unset might want a zero-based array. If the math modulo operator is being used on an index variable, zero based arrays are more useful. Having `-z' mean not zero-based might be confusing though. On 14 Apr, Bart wrote: > One question that occurred to me ... given: > > zcompile -k foo > autoload -z foo > > I presume zcompile wins the argument. That should be documented ... Yes, zcompile does win. That was applicable before with +X. I've documented this under zcompile. Oliver diff -ur zsh.p1/Completion/Base/Widget/_next_tags zsh/Completion/Base/Widget/_next_tags --- zsh.p1/Completion/Base/Widget/_next_tags 2003-03-11 18:33:05.000000000 +0100 +++ zsh/Completion/Base/Widget/_next_tags 2004-04-16 18:35:00.000000000 +0200 @@ -37,7 +37,7 @@ (( $#funcstack > _tags_level )) && _comp_tags="${_comp_tags% * }" _tags_level=$#funcstack [[ "$_next_tags_not" = *\ ${__spec}\ * ]] && continue - _comp_tags="$_comp_tags $__spec " + _comp_tags+=" $__spec " if [[ "$curtag" = *[^\\]:* ]]; then zformat -f __descr "${curtag#*:}" "d:$3" _description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr" @@ -64,7 +64,7 @@ (( $#funcstack > _tags_level )) && _comp_tags="${_comp_tags% * }" _tags_level=$#funcstack [[ "$_next_tags_not" = *\ ${__spec}\ * ]] && continue - _comp_tags="$_comp_tags $__spec " + _comp_tags+=" $__spec " if [[ "$curtag" = *[^\\]:* ]]; then zformat -f __descr "${curtag#*:}" "d:$3" _description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr" @@ -92,7 +92,7 @@ fi fi - _next_tags_not="$_next_tags_not $_lastcomp[tags]" + _next_tags_not+=" $_lastcomp[tags]" _next_tags_pfx="$PREFIX" _next_tags_sfx="$SUFFIX" @@ -107,7 +107,7 @@ compstate[insert]="$ins" compstate[list]='list force' - compprefuncs=( "$compprefuncs[@]" _next_tags_pre ) + compprefuncs+=( _next_tags_pre ) } # Completer, for wrap-around. @@ -132,9 +132,9 @@ return 0 elif [[ ${LBUFFER%${PREFIX}} != ${_next_tags_pre}* ]]; then unfunction _all_labels _next_label - autoload -U _all_labels _next_label + autoload -Uz _all_labels _next_label else - compprefuncs=( "$compprefuncs[@]" _next_tags_pre ) + compprefuncs+=( _next_tags_pre ) fi } diff -ur zsh.p1/Completion/bashcompinit zsh/Completion/bashcompinit --- zsh.p1/Completion/bashcompinit 2003-01-29 15:26:01.000000000 +0100 +++ zsh/Completion/bashcompinit 2004-04-14 16:11:35.000000000 +0200 @@ -168,5 +168,5 @@ } unfunction bashcompinit -autoload -U bashcompinit +autoload -Uz bashcompinit return 0 diff -ur zsh.p1/Completion/compdump zsh/Completion/compdump --- zsh.p1/Completion/compdump 2002-06-23 06:52:39.000000000 +0200 +++ zsh/Completion/compdump 2004-04-14 16:11:26.000000000 +0200 @@ -108,7 +108,7 @@ # print them out: about five to a line looks neat _i=5 -print -n autoload -U >> $_d_file +print -n autoload -Uz >> $_d_file while (( $#_d_als )); do if (( ! $+_compautos[$_d_als[1]] )); then print -n " $_d_als[1]" @@ -123,7 +123,7 @@ print >> $_d_file for _i in "${(ok@)_compautos}"; do - print "autoload -U $_compautos[$_i] $_i" >> $_d_file + print "autoload -Uz $_compautos[$_i] $_i" >> $_d_file done print >> $_d_file @@ -134,4 +134,4 @@ mv $_d_file ${_d_file%.$HOST.$$} unfunction compdump -autoload -U compdump +autoload -Uz compdump diff -ur zsh.p1/Completion/compinit zsh/Completion/compinit --- zsh.p1/Completion/compinit 2004-04-14 16:11:04.000000000 +0200 +++ zsh/Completion/compinit 2004-04-14 16:11:17.000000000 +0200 @@ -46,7 +46,7 @@ # generate matches, but should automatically be loaded # when they are called. The <options> will be given to the # autoload builtin when making the function autoloaded. Note -# that this need not include `-U'. +# that this need not include `-U' and `-z'. # # Note that no white space is allowed between the `#' and the rest of # the string. @@ -292,7 +292,7 @@ # and probably do autoloading. func="$1" - [[ -n "$autol" ]] && autoload -U "$func" + [[ -n "$autol" ]] && autoload -Uz "$func" shift case "$type" in @@ -406,7 +406,7 @@ _i_wdirs=() _i_wfiles=() -autoload -U compaudit +autoload -Uz compaudit if [[ -n "$_i_check" ]]; then typeset _i_q if ! eval compaudit; then @@ -433,7 +433,7 @@ fi # Make sure compdump is available, even if we aren't going to use it. -autoload -U compdump compinstall +autoload -Uz compdump compinstall # If we have a dump file, load it. @@ -473,7 +473,7 @@ fi ;; (\#autoload) - autoload -U "$_i_line[@]" ${_i_name} + autoload -Uz "$_i_line[@]" ${_i_name} [[ "$_i_line" != \ # ]] && _compautos[${_i_name}]="$_i_line" ;; esac @@ -505,6 +505,6 @@ fi unfunction compinit compaudit -autoload -U compinit compaudit +autoload -Uz compinit compaudit return 0 diff -ur zsh.p1/Completion/compinstall zsh/Completion/compinstall --- zsh.p1/Completion/compinstall 2003-03-07 16:19:47.000000000 +0100 +++ zsh/Completion/compinstall 2004-04-14 16:12:02.000000000 +0200 @@ -7,7 +7,7 @@ __ci_tidyup() { unfunction -m __ci_\* 2>/dev/null unfunction compinstall - autoload -U compinstall + autoload -Uz compinstall } __ci_newline() { @@ -119,7 +119,7 @@ then compinit_args=$match[1] elif [[ $line != [[:blank:]]# && - $line != [[:blank:]]#'autoload -U compinit' && + $line != [[:blank:]]#'autoload -Uz compinit' && $line != [[:blank:]]#compinit && $line != [[:blank:]]#zstyle[[:blank:]]#:compinstall* ]]; then warn_unknown="${warn_unknown:+$warn_unknown @@ -1886,7 +1886,7 @@ [[ -n $fpath_line ]] && print -r "$fpath_line" print -r " -autoload -U compinit +autoload -Uz compinit compinit${compinit_args:+ $compinit_args}" print -r "$endline" diff -ur zsh.p1/Completion/Zsh/Command/_typeset zsh/Completion/Zsh/Command/_typeset --- zsh.p1/Completion/Zsh/Command/_typeset 2002-09-16 20:10:54.000000000 +0200 +++ zsh/Completion/Zsh/Command/_typeset 2004-04-16 18:45:32.000000000 +0200 @@ -1,27 +1,31 @@ -#compdef declare export integer float local readonly typeset +#compdef autoload declare export functions integer float local readonly typeset local expl state line func i use curcontext="$curcontext" -local -A allargs +local fopts="-f -k -z" +local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -r -x" +local -A allargs opt_args local -a args allargs=( - A '(-E -F -L -R -T -U -Z -a -f -i -m)-A[specify that arguments refer to associative arrays]' - E '(-A -F -L -R -T -U -Z -a -f -i -m)-E[floating point, use engineering notation on output]' - F '(-A -E -L -R -T -U -Z -a -f -i -m)-F[floating point, use fixed point decimal on output]' - L '(-A -E -F -f -i)-L+[left justify and remove leading blanks from value]:width' - R '(-A -E -F -f -i)-R+[right justify and fill with leading blanks]:width' - T '(-A -E -F -a -f -g -h -i -l -m -t)-T[tie scalar to array]' + A "($fopts -E -F -L -R -T -U -Z -a -i -m)-A[specify that arguments refer to associative arrays]" + E "($fopts -A -F -L -R -T -U -Z -a -i -m)-E[floating point, use engineering notation on output]" + F "($fopts -A -E -L -R -T -U -Z -a -i -m)-F[floating point, use fixed point decimal on output]" + L "($fopts -A -E -F -i)-L+[left justify and remove leading blanks from value]:width" + R "($fopts -A -E -F -i)-R+[right justify and fill with leading blanks]:width" + T "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array]" U '(-A -E -F -i)-U[keep array values unique and suppress alias expansion for functions]' - Uf '(-E -F -i)-U[suppress alias expansion for functions]' - Up '(-E -F -i)-U[keep array values unique]' - Z '(-A -E -F -f -i)-Z+[right justify and fill with leading zeros]:width' - a '(-A -E -F -T -f -i)-a[specify that arguments refer to arrays]' - f '(-A -E -F -L -R -T -Z -a -g -h -i -l -r -x)-f[specify that arguments refer to functions]' - g '(-T -f)-+g[do not restrict parameter to local scope]' - h '(-T -f)-+h[hide specialness of parameter]' - H '(-T -f)-+H[hide value of parameter in listings]' - i '(-A -E -F -T -f)-+i[represent internally as an integer]' - l '(-T -f)-l[convert the value to lowercase]' + Uf '-U[suppress alias expansion for functions]' + Up '(-E -F -i)-+U[keep array values unique]' + X '+X[immediately autoload function]' + Z "($fopts -A -E -F -i)-Z+[right justify and fill with leading zeros]:width" + a "($fopts -A -E -F -T -i)-a[specify that arguments refer to arrays]" + f "($popts)-f[specify that arguments refer to functions]" + g "($fopts -T)-+g[do not restrict parameter to local scope]" + h "($fopts -T)-+h[hide specialness of parameter]" + H "($fopts -T)-+H[hide value of parameter in listings]" + i "($fopts -A -E -F -T)-+i[represent internally as an integer]" + k "($popts -w -z)-+k[mark function for ksh-style autoloading]" + l "($popts -T)-l[convert the value to lowercase]" m '(-A -E -F -T -i)-m[treat arguments as patterns]' p '-p[output parameters in form of calls to typeset]' r '(-f)-+r[mark parameters as readonly]' @@ -31,15 +35,21 @@ u '-u[convert the value to uppercase or mark function for autoloading]' uf '-u[mark function for autoloadling]' up '-u[convert the value to uppercase]' - x '(-f)-+x[export parameter]' + w '(-k -z)-w[specify that arguments refer to files compiled with zcompile]' + x "($fopts)-+x[export parameter]" + z "($popts -k -w)-+z[mark function for zsh-style autoloading]" ) -use="AEFHLRTUZafghilmprtux" +use="AEFHLRTUZafghiklmprtuxz" case ${service} in + autoload) + use="UXktwz" + func=f + ;; float) use="EFHghlprtux";; functions) - use="Umtu" + use="Ukmtuz" func=f ;; integer) @@ -47,28 +57,37 @@ allargs[i]='-i[specify arithmetic base for output]' \ ;; readonly) use="${use/r/}" ;; - local) use="${use/f/}" ;& - export) use="${${use/g/}/x/}" ;; + local) use="${use/[fkz]/}" ;& + export) use="${${use//[gkz]/}/x/}" ;; esac -[[ -z "${words[(r)-*f*]}" ]] || func=f [[ -z "${words[(r)-*[aA]*]}" ]] || func=p +[[ -z "${words[(r)-*f*]}" ]] || func=f for ((i=1;i<=$#use;++i)); do args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[Uut]]:+$func}]} ) done -_arguments -C -s -A "-*" -S "${args[@]}" '*:vars:->vars_eq' +_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq' if [[ "$state" = vars_eq ]]; then if [[ $func = f ]]; then - _functions + if (( $+opt_args[-w] ));then + _wanted files expl 'zwc file' _files -g '*.zwc(-.)' + else + _functions + fi elif [[ "$PREFIX" = *\=* ]]; then compstate[parameter]="${PREFIX%%\=*}" compset -P 1 '*=' _value elif (( $+opt_args[-a] || $+opt_args[-A] )); then _parameters -q + elif (( $+opt_args[-T] )); then + _arguments \ + ':scalar parameter:_parameters -g "*scalar*" -q -S "="' \ + ':array parameter:_parameters -g "*array*"' \ + ':separator character' else _parameters -q -S '=' fi diff -ur zsh.p1/Completion/Zsh/Type/_functions zsh/Completion/Zsh/Type/_functions --- zsh.p1/Completion/Zsh/Type/_functions 2001-04-02 13:18:39.000000000 +0200 +++ zsh/Completion/Zsh/Type/_functions 2004-04-16 15:58:27.000000000 +0200 @@ -1,4 +1,4 @@ -#compdef functions unfunction +#compdef unfunction local expl diff -ur zsh.p1/Doc/Zsh/builtins.yo zsh/Doc/Zsh/builtins.yo --- zsh.p1/Doc/Zsh/builtins.yo 2004-03-29 10:49:39.000000000 +0200 +++ zsh/Doc/Zsh/builtins.yo 2004-04-16 16:42:05.000000000 +0200 @@ -103,9 +103,9 @@ findex(autoload) cindex(functions, autoloading) cindex(autoloading functions) -item(tt(autoload) [ {tt(PLUS())|tt(-)}tt(UXmt) ] [ tt(-wkz) ] [ var(name) ... ])( -Equivalent to tt(functions -u), with the exception of tt(-X)/tt(+X), -tt(-w), tt(-k) and tt(-z). +item(tt(autoload) [ {tt(PLUS())|tt(-)}tt(UXktz) ] [ tt(-w) ] [ var(name) ... ])( +Equivalent to tt(functions -u), with the exception of tt(-X)/tt(+X) and +tt(-w). The flag tt(-X) may be used only inside a shell function, and may not be followed by a var(name). It causes the calling function to be marked for @@ -120,16 +120,10 @@ This does em(not) replace any existing definition of the function. The exit status is nonzero (failure) if the function was already defined or when no definition was found. In the latter case the function remains -undefined and marked for autoloading. - -The flag tt(+X) may be combined with either tt(-k) or tt(-z) to make -the function be loaded using ksh-style or zsh-style autoloading, -respectively. If neither is given, the current setting of the -tt(KSH_AUTOLOAD) options determines how the function is loaded. With -ksh-style autoloading, the contents of the file will not be executed -immediately. Instead, the function created will contain the contents of -the file plus a call to the function itself appended to it, thus given -normal ksh autoloading behaviour on the first call to the function. +undefined and marked for autoloading. If ksh-style autoloading is +enabled, the function created will contain the contents of the file +plus a call to the function itself appended to it, thus giving normal +ksh autoloading behaviour on the first call to the function. With the tt(-w) flag, the var(name)s are taken as names of files compiled with the tt(zcompile) builtin, and all functions defined in them are @@ -461,7 +455,7 @@ point numbers are not permitted. ) findex(functions) -item(tt(functions) [ {tt(PLUS())|tt(-)}tt(UXmtu) ] [ var(name) ... ])( +item(tt(functions) [ {tt(PLUS())|tt(-)}tt(UXkmtuz) ] [ var(name) ... ])( Equivalent to tt(typeset -f). ) module(getcap)(zsh/cap) @@ -1159,7 +1153,7 @@ findex(typeset) cindex(parameters, setting) cindex(parameters, declaring) -xitem(tt(typeset) [ {tt(PLUS())|tt(-)}tt(AEFHLRUZafghilprtuxm) [var(n)]] [ \ +xitem(tt(typeset) [ {tt(PLUS())|tt(-)}tt(AEFHLRUZafghiklprtuxmz) [var(n)]] [ \ var(name)[tt(=)var(value)] ... ]) item(tt(typeset) -T [ {tt(PLUS()|tt(-))}tt(LRUZrux) ] \ var(SCALAR)[tt(=)var(value)] var(array) tt([) var(sep) tt(]))( @@ -1290,13 +1284,16 @@ ) item(tt(-f))( The names refer to functions rather than parameters. No assignments -can be made, and the only other valid flags are tt(-t), tt(-u) and -tt(-U). The flag tt(-t) turns on execution tracing for this +can be made, and the only other valid flags are tt(-t), tt(-k), tt(-u), +tt(-U) and tt(-z). The flag tt(-t) turns on execution tracing for this function. The tt(-u) and tt(-U) flags cause the function to be marked for autoloading; tt(-U) also causes alias expansion to be suppressed when the function is loaded. The tt(fpath) parameter will be searched to find the function definition when the function -is first referenced; see noderef(Functions). +is first referenced; see noderef(Functions). The tt(-k) and tt(-z) flags +make the function be loaded using ksh-style or zsh-style autoloading +respectively. If neither is given, the setting of the KSH_AUTOLOAD option +determines how the function is loaded. ) item(tt(-h))( Hide: only useful for special parameters (those marked `<S>' in the table in @@ -1634,9 +1631,11 @@ function will be autoloaded as if the tt(KSH_AUTOLOAD) option is em(not) set, even if it is set at the time the compiled file is read, while if the tt(-k) is given, the function will be loaded as if -tt(KSH_AUTOLOAD) em(is) set. If neither of these options is given, the -function will be loaded as determined by the setting of the -tt(KSH_AUTOLOAD) option at the time the compiled file is read. +tt(KSH_AUTOLOAD) em(is) set. These options also take precedence over +any tt(-k) or tt(-z) options specified to the tt(autoload) builtin. If +neither of these options is given, the function will be loaded as +determined by the setting of the tt(KSH_AUTOLOAD) option at the time +the compiled file is read. ifzman( ) These options may also appear as many times as necessary between the listed var(name)s to specify the loading style of all following functions, up to diff -ur zsh.p1/Doc/Zsh/compsys.yo zsh/Doc/Zsh/compsys.yo --- zsh.p1/Doc/Zsh/compsys.yo 2004-03-01 12:36:05.000000000 +0100 +++ zsh/Doc/Zsh/compsys.yo 2004-04-16 10:59:30.000000000 +0200 @@ -225,8 +225,8 @@ are not otherwise treated specially. Typically they are to be called from within one of the completion functions. Any var(options) supplied will be passed to the tt(autoload) builtin; a typical use is tt(+X) to -force the function to be loaded immediately. Note that the tt(-U) flag is -always added implicitly. +force the function to be loaded immediately. Note that the tt(-U) and +tt(-z) flags are always added implicitly. ) enditem() @@ -234,16 +234,6 @@ The tt(#compdef) tags use the tt(compdef) function described below; the main difference is that the name of the function is supplied implicitly. -Note also that the functions for the completion system assume that the -tt(KSH_AUTOLOAD) option is not set. They cannot be loaded if it is -set. To avoid having to unset tt(KSH_AUTOLOAD), you can instead use one or -more tt(zwc) file(s) that have been created with the command tt(zcompile --z) to load the functions for the completion system; see -ifzman(zmanref(zshbuiltins))\ -ifnzman(noderef(Shell Builtin Commands))\ -. This forces the functions to be autoloaded the way zsh normally -loads functions. - The special contexts for which completion functions can be defined are: startitem() diff -ur zsh.p1/Src/builtin.c zsh/Src/builtin.c --- zsh.p1/Src/builtin.c 2004-04-13 15:08:44.000000000 +0200 +++ zsh/Src/builtin.c 2004-04-16 17:27:28.000000000 +0200 @@ -53,7 +53,7 @@ BUILTIN("cd", BINF_SKIPINVALID | BINF_SKIPDASH | BINF_DASHDASHVALID, bin_cd, 0, 2, BIN_CD, "sPL", NULL), BUILTIN("chdir", BINF_SKIPINVALID | BINF_SKIPDASH | BINF_DASHDASHVALID, bin_cd, 0, 2, BIN_CD, "sPL", NULL), BUILTIN("continue", BINF_PSPECIAL, bin_break, 0, 1, BIN_CONTINUE, NULL, NULL), - BUILTIN("declare", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%afghi:%lprtux", NULL), + BUILTIN("declare", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%afghi:%klmprtuxz", NULL), BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "clpv", NULL), BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmrs", NULL), BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL), @@ -73,7 +73,7 @@ NULL), BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL), BUILTIN("float", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "E:%F:%Hghlprtux", "E"), - BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "mtuU", NULL), + BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "kmtuUz", NULL), BUILTIN("getln", 0, bin_read, 0, -1, 0, "ecnAlE", "zr"), BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, NULL, NULL), BUILTIN("hash", BINF_MAGICEQUALS, bin_hash, 0, -1, 0, "Ldfmrv", NULL), @@ -121,7 +121,7 @@ BUILTIN("trap", BINF_PSPECIAL, bin_trap, 0, -1, 0, NULL, NULL), BUILTIN("true", 0, bin_true, 0, -1, 0, NULL, NULL), BUILTIN("type", 0, bin_whence, 0, -1, 0, "ampfsw", "v"), - BUILTIN("typeset", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%afghi:%lprtuxm", NULL), + BUILTIN("typeset", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%afghi:%klprtuxmz", NULL), BUILTIN("umask", 0, bin_umask, 0, 1, 0, "S", NULL), BUILTIN("unalias", 0, bin_unhash, 1, -1, 0, "ms", "a"), BUILTIN("unfunction", 0, bin_unhash, 1, -1, 0, "m", "f"), @@ -2406,13 +2406,15 @@ on |= PM_TAGGED; else if (OPT_PLUS(ops,'t')) off |= PM_TAGGED; - if (OPT_MINUS(ops,'z')) + if (OPT_MINUS(ops,'z')) { on |= PM_ZSHSTORED; - else if (OPT_PLUS(ops,'z')) + off |= PM_KSHSTORED; + } else if (OPT_PLUS(ops,'z')) off |= PM_ZSHSTORED; - if (OPT_MINUS(ops,'k')) + if (OPT_MINUS(ops,'k')) { on |= PM_KSHSTORED; - else if (OPT_PLUS(ops,'k')) + off |= PM_ZSHSTORED; + } else if (OPT_PLUS(ops,'k')) off |= PM_KSHSTORED; if ((off & PM_UNDEFINED) || (OPT_ISSET(ops,'k') && OPT_ISSET(ops,'z')) || ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-16 16:49 ` Oliver Kiddle @ 2004-04-16 17:25 ` Bart Schaefer 2004-04-18 13:46 ` Oliver Kiddle 2004-04-16 17:30 ` Bart Schaefer 1 sibling, 1 reply; 20+ messages in thread From: Bart Schaefer @ 2004-04-16 17:25 UTC (permalink / raw) To: zsh-workers On Apr 16, 6:49pm, Oliver Kiddle wrote: } } Why do export and readonly accept -f arguments? Is that just to avoid } errors on bash scripts? Any reason why we shouldn't implement readonly } functions. It could get pretty tricky to have a readonly autoloaded function. Does the function become readonly only after the autoload occurs? What *can* one change about a readonly function -- can one `typeset -t' it? If it hasn't been loaded yet, can the new ksh/zsh autoload flags be changed? BTW, independent of readonly, what do +z and +k mean? Revert the function to using the current global ksh_autoload setting? What happens if you use +k on a function that has -z ? } On 13 Apr, Bart wrote: } > } > } > Here's a possibly-silly idea: Those flags could be made to apply } > } > to arrays as well as functions } } [If] the math modulo operator is being used on an index variable, zero } based arrays are more useful. Having `-z' mean not zero-based might be } confusing though. Yes, that's true. Having -z mean something different for arrays and functions might be confusing, too, unless -k is invalid for arrays, but that might be more confusing than having -k mean zero-based and -z not valid. Argh, my head hurts. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-16 17:25 ` Bart Schaefer @ 2004-04-18 13:46 ` Oliver Kiddle 0 siblings, 0 replies; 20+ messages in thread From: Oliver Kiddle @ 2004-04-18 13:46 UTC (permalink / raw) To: zsh-workers Bart wrote: > On Apr 16, 6:49pm, Oliver Kiddle wrote: > } > } Why do export and readonly accept -f arguments? Is that just to avoid > } errors on bash scripts? Any reason why we shouldn't implement readonly > } functions. > > It could get pretty tricky to have a readonly autoloaded function. Does > the function become readonly only after the autoload occurs? What *can* > one change about a readonly function -- can one `typeset -t' it? If it > hasn't been loaded yet, can the new ksh/zsh autoload flags be changed? We seem to be generous in allowing various typeset flags to be changed for readonly variables so I see little reason to prevent typeset -t. Bash doesn't have autoloadable functions so we can't just look at how it works. We could prevent changing the definition of the function but allow it to be autoloaded if it was already declared autoloadable. And you can't make an existing function autoloadable without first using unfunction anyway. By the way, in a restricted shell, ksh restricts FPATH (zsh doesn't). > BTW, independent of readonly, what do +z and +k mean? Revert the > function to using the current global ksh_autoload setting? What happens > if you use +k on a function that has -z ? They remove the PM_ZSHSTORED or PM_KSHSTORED flag respectively. So if PM_ZSHSTORED is set, +k will do nothing. You need `+k +z' to be sure of returning it to the global ksh_autoload setting. In contrast -z or -k alone will remove a contradictory flag. This is consistent with how the -E and -F flags work: you need `+E +F' to convert a float to scalar. Oliver ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-16 16:49 ` Oliver Kiddle 2004-04-16 17:25 ` Bart Schaefer @ 2004-04-16 17:30 ` Bart Schaefer 2004-04-17 19:51 ` Oliver Kiddle 1 sibling, 1 reply; 20+ messages in thread From: Bart Schaefer @ 2004-04-16 17:30 UTC (permalink / raw) To: zsh-workers On Apr 16, 6:49pm, Oliver Kiddle wrote: } Subject: PATCH: Re: Compsys and KSH_AUTOLOAD } } This is part 2 for the patch I sent in 19767 and should be applied on } top of it. This changes the documentation and completion functions } along with allowing -k and -z to be used with typeset -f or functions. I get a new "make check" failure after applying this patch: Test/B02typeset.ztst: starting. Test Test/B02typeset.ztst failed: bad status 0, expected 1 from: declare +m ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-16 17:30 ` Bart Schaefer @ 2004-04-17 19:51 ` Oliver Kiddle 2004-04-19 0:14 ` Bart Schaefer 0 siblings, 1 reply; 20+ messages in thread From: Oliver Kiddle @ 2004-04-17 19:51 UTC (permalink / raw) To: zsh-workers Bart wrote: > > I get a new "make check" failure after applying this patch: > > Test/B02typeset.ztst: starting. > Test Test/B02typeset.ztst failed: bad status 0, expected 1 from: declare +m That's this test: declare +m 1:Differences of declare and typeset ?(eval):1: bad option: -m I noticed the missing `m' in the list of declare options when checking the completion function was consistent with the code. I assumed that was an oversight. I was probably unwise in getting side tracked into changing that sort of thing but why does declare have that difference to typeset? I can't see that it serves any useful purpose. But given that someone bothered testing it, maybe there is. Bash has no conflicting -m option. Or can I just remove the test? Oliver ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-17 19:51 ` Oliver Kiddle @ 2004-04-19 0:14 ` Bart Schaefer 2004-04-19 10:18 ` Oliver Kiddle 0 siblings, 1 reply; 20+ messages in thread From: Bart Schaefer @ 2004-04-19 0:14 UTC (permalink / raw) To: zsh-workers On Apr 17, 9:51pm, Oliver Kiddle wrote: } Subject: Re: PATCH: Re: Compsys and KSH_AUTOLOAD } } > Test Test/B02typeset.ztst failed: bad status 0, expected 1 from: declare +m } } That's this test: } } declare +m } 1:Differences of declare and typeset } ?(eval):1: bad option: -m } } I noticed the missing `m' in the list of declare options when checking } the completion function was consistent with the code. I assumed that } was an oversight. At the very top of that Test/B02typeset.ztst there is: # Equivalences: # declare typeset but declare does not accept -m (etc.) "cvs annotate" says I committed the firet-ever revision of this, which included that test, but I'm afraid I don't remember why "declare" does not support -m unless it's "just in case" bash's declare later starts taking a -m option and we wanted to reserve it for future compatibility. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-19 0:14 ` Bart Schaefer @ 2004-04-19 10:18 ` Oliver Kiddle 2004-04-20 4:11 ` Bart Schaefer 0 siblings, 1 reply; 20+ messages in thread From: Oliver Kiddle @ 2004-04-19 10:18 UTC (permalink / raw) To: zsh-workers Bart wrote: > > "cvs annotate" says I committed the firet-ever revision of this, which > included that test, but I'm afraid I don't remember why "declare" does > not support -m unless it's "just in case" bash's declare later starts > taking a -m option and we wanted to reserve it for future compatibility. declare not accepting -m goes back to before the mailing list archives so unless you have older archives, it won't be easy to find out. My suspicion is that it was an oversight when -m was added but it may have been bash compatibility. The oldest list of declare options I see in the mailing list is "LRUZfilrtux" (workers/1966). -U is the one non-ksh[1] option in there (bash has fewer but ksh options may have been considered safe). We've added a good few more since. -F is even incompatible with bash and that's ksh93 too. So I really don't see much harm in adding -m to declare's options. Or do you disagree? Oliver [1] ksh88 or 93. -U is unsigned integer in pdksh ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-19 10:18 ` Oliver Kiddle @ 2004-04-20 4:11 ` Bart Schaefer 2004-04-20 10:08 ` Oliver Kiddle 0 siblings, 1 reply; 20+ messages in thread From: Bart Schaefer @ 2004-04-20 4:11 UTC (permalink / raw) To: zsh-workers On Apr 19, 12:18pm, Oliver Kiddle wrote: } } declare not accepting -m goes back to before the mailing list archives } so unless you have older archives, it won't be easy to find out. I have zsh source dating back to 1993, before I even knew there *was* a "declare" command, but it's there, and doesn't have -m. {"declare", bin_typeset, 0, -1, BINF_TYPEOPTS, 0, "LRZfilrtux", NULL}, } My suspicion is that it was an oversight when -m was added but it may } have been bash compatibility. I suspect the latter: For source that old, it's almost all Paul's code, and I suspect he implemented it as nearly as possible the way bash does. } So I really don't see much harm in adding -m to declare's options. } Or do you disagree? No, I don't see any harm. I think that means you should reverse the sense of the test rather than remove the test, though. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-20 4:11 ` Bart Schaefer @ 2004-04-20 10:08 ` Oliver Kiddle 0 siblings, 0 replies; 20+ messages in thread From: Oliver Kiddle @ 2004-04-20 10:08 UTC (permalink / raw) To: zsh-workers Bart wrote: > > } So I really don't see much harm in adding -m to declare's options. > } Or do you disagree? > > No, I don't see any harm. I think that means you should reverse the > sense of the test rather than remove the test, though. Okay, this patch reverses the sense of the test. Index: Test/B02typeset.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/B02typeset.ztst,v retrieving revision 1.5 diff -u -r1.5 B02typeset.ztst --- Test/B02typeset.ztst 25 Sep 2003 09:50:25 -0000 1.5 +++ Test/B02typeset.ztst 20 Apr 2004 09:57:03 -0000 @@ -3,7 +3,7 @@ # everything that follows is processed by an "eval" within a function. # Equivalences: -# declare typeset but declare does not accept -m +# declare typeset # export typeset -x and typeset -x implies -g # float typeset -E # functions typeset -f @@ -100,9 +100,9 @@ >local l o c a l >scalar a r r a y - declare +m -1:Differences of declare and typeset -?(eval):1: bad option: -m + declare +m scalar +0:declare previously lacked -m/+m options +>scalar scope10 print $outer ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: Compsys and KSH_AUTOLOAD 2004-04-13 15:29 ` PATCH: " Oliver Kiddle 2004-04-13 17:51 ` Bart Schaefer @ 2004-04-14 5:04 ` Bart Schaefer 1 sibling, 0 replies; 20+ messages in thread From: Bart Schaefer @ 2004-04-14 5:04 UTC (permalink / raw) To: zsh-workers One question that occurred to me ... given: zcompile -k foo autoload -z foo I presume zcompile wins the argument. That should be documented ... ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Compsys and KSH_AUTOLOAD 2004-04-10 17:44 Compsys and KSH_AUTOLOAD Bart Schaefer 2004-04-12 14:00 ` Oliver Kiddle @ 2004-04-14 19:55 ` Peter Stephenson 1 sibling, 0 replies; 20+ messages in thread From: Peter Stephenson @ 2004-04-14 19:55 UTC (permalink / raw) To: zsh-workers [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1038 bytes --] Bart Schaefer wrote: > (1) Does this deserve a FAQ entry, or perhaps even a change to the > compsys documentation? I guess ksh_autoload isn't a very "frequently" > used option, but even the existing paragraph in the manual about it not > working is pretty deeply buried. It's already documented, fairly well down the manual page. Note also that the functions for the completion system assume that the KSH_AUTOLOAD option is not set. They cannot be loaded if it is set. To avoid having to unset KSH_AUTOLOAD, you can instead use one or more zwc file(s) that have been created with the command zcompile −z to load the functions for the completion system; see zshbuiltins(1). This forces the functions to be autoloaded the way zsh normally loads func‐tions. > (2) Should we change _comp_options to always include NO_kshautoload? Seems sensible, in view of the above. -- Peter Stephenson <pws@pwstephenson.fsnet.co.uk> Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2004-04-20 10:10 UTC | newest] Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-04-10 17:44 Compsys and KSH_AUTOLOAD Bart Schaefer 2004-04-12 14:00 ` Oliver Kiddle 2004-04-12 15:59 ` Bart Schaefer 2004-04-12 21:43 ` Oliver Kiddle 2004-04-13 5:32 ` While we're on the subject of zcompile Bart Schaefer 2004-04-17 21:08 ` Oliver Kiddle 2004-04-13 5:38 ` Compsys and KSH_AUTOLOAD Bart Schaefer 2004-04-13 15:29 ` PATCH: " Oliver Kiddle 2004-04-13 17:51 ` Bart Schaefer 2004-04-16 16:49 ` Oliver Kiddle 2004-04-16 17:25 ` Bart Schaefer 2004-04-18 13:46 ` Oliver Kiddle 2004-04-16 17:30 ` Bart Schaefer 2004-04-17 19:51 ` Oliver Kiddle 2004-04-19 0:14 ` Bart Schaefer 2004-04-19 10:18 ` Oliver Kiddle 2004-04-20 4:11 ` Bart Schaefer 2004-04-20 10:08 ` Oliver Kiddle 2004-04-14 5:04 ` Bart Schaefer 2004-04-14 19:55 ` Peter Stephenson
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).