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

Re: About menu selection (again)



Bart Schaefer wrote:

> ...
> 
> Could we do something along the lines of shuffling the hookdefs so that
> the completion hooks are not defined until `zle -C' runs the first time,
> even if the zsh/complete module has been loaded?  And then test for the
> presence of the hook rather than the presence of the module, and load
> compctl if the hook doesn't exist?

Sorry for the delay, we had problems with our router...

We should actually be able to get by with just a tiny flag, that's set
when a completion widget is defined. Or am I wrong.

Ideally, this should really check, if any completion widgets are bound
to keys, shouldn't it?


Bye
  Sven

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.26
diff -u -r1.26 zle_main.c
--- Src/Zle/zle_main.c	4 Jul 2002 10:13:38 -0000	1.26
+++ Src/Zle/zle_main.c	20 Aug 2002 11:52:58 -0000
@@ -1355,6 +1355,7 @@
     varedarg = NULL;
 
     incompfunc = incompctlfunc = hascompmod = 0;
+    hascompwidgets = 0;
 
     clwords = (char **) zcalloc((clwsize = 16) * sizeof(char *));
 
Index: Src/Zle/zle_thingy.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_thingy.c,v
retrieving revision 1.8
diff -u -r1.8 zle_thingy.c
--- Src/Zle/zle_thingy.c	7 Jun 2002 18:04:14 -0000	1.8
+++ Src/Zle/zle_thingy.c	20 Aug 2002 11:52:58 -0000
@@ -601,6 +601,8 @@
 	zwarnnam(name, "widget name `%s' is protected", args[0], 0);
 	return 1;
     }
+    hascompwidgets++;
+
     return 0;
 }
 
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.39
diff -u -r1.39 zle_tricky.c
--- Src/Zle/zle_tricky.c	8 Jul 2002 09:03:05 -0000	1.39
+++ Src/Zle/zle_tricky.c	20 Aug 2002 11:52:58 -0000
@@ -146,6 +146,11 @@
 /**/
 mod_export int comprecursive;
 
+/* != 0 if there are any defined completion widgets. */
+
+/**/
+int hascompwidgets;
+
 /* Find out if we have to insert a tab (instead of trying to complete). */
 
 /**/
@@ -557,7 +562,11 @@
     if (undoing)
 	setlastline();
 
-    if (!module_loaded("zsh/complete"))
+    /* We the C-code's point of view, we can only use compctl as a default
+     * type of completion. Load it if it hasn't been loaded already and
+     * no completion widgets are defined. */
+
+    if (!module_loaded("zsh/compctl") && !hascompwidgets)
 	load_module("zsh/compctl");
 
     if (runhookdef(BEFORECOMPLETEHOOK, (void *) &lst)) {


-- 
Sven Wischnowsky                          wischnow@xxxxxxxxx



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