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

Re: command completion taking ages



Bart Schaefer wrote:

> On Mar 14,  4:27pm, Sven Wischnowsky wrote:
> } Subject: Re: command completion taking ages
> }
> }   zstyle ':completion:*:*:-command-:*' tag-order 'maybe()' -
> } 
> }   maybe() { [[ -n $PREFIX ]] && comptry "$@" }
> 
> I wondered about that, but it's not a general solution for cases where
> there are multiple tags and you DO want to order them when there IS a
> non-empty prefix/suffix.  Is there some way for the function to say
> "I didn't generate any matches, but don't try any more tags even so"?

We can easily make it use the return value for this...

So, with this patch one can simplify the above to:

  maybe() { [[ -n $PREFIX ]] }


Bye
 Sven

diff -ru ../z.old/Completion/Core/_sort_tags Completion/Core/_sort_tags
--- ../z.old/Completion/Core/_sort_tags	Wed Mar 15 10:33:12 2000
+++ Completion/Core/_sort_tags	Wed Mar 15 10:44:18 2000
@@ -26,3 +26,5 @@
 esac
 
 comptry "$@"
+
+return 0
diff -ru ../z.old/Completion/Core/_tags Completion/Core/_tags
--- ../z.old/Completion/Core/_tags	Wed Mar 15 10:33:12 2000
+++ Completion/Core/_tags	Wed Mar 15 10:40:35 2000
@@ -44,7 +44,11 @@
     for tag in $order; do
       case $tag in
       -)     nodef=yes;;
-      *\(\)) "${${tag%%[ 	]#\(\)}##[ 	]#}" "$@";;
+      *\(\)) if ! "${${tag%%[ 	]#\(\)}##[ 	]#}" "$@"; then
+               nodef=yes
+               break
+             fi
+             ;;
       \!*)   comptry "${(@)argv:#(${(j:|:)~${=tag[2,-1]}})}";;
       ?*)    comptry ${=tag};;
       esac
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo	Wed Mar 15 10:32:51 2000
+++ Doc/Zsh/compsys.yo	Wed Mar 15 10:44:08 2000
@@ -1435,7 +1435,10 @@
 this case the function var(func) will be called which can then define
 in which order tags are to be used based on additional context
 information. See the tt(_sort_tags) function below for a description
-of how such functions can be implemented.
+of how such functions can be implemented. The return value of the
+function is used to decide if the following values for the style
+should be used. If it is zero, they are used and if it is non-zero,
+they are not used.
 
 If no style has been defined for a context, the strings tt(arguments
 values), tt(options), tt(globbed-files), tt(directories) and

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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