Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: While we're on the subject of zcompile ...



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
 



Messages sorted by: Reverse Date, Date, Thread, Author