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

Re: PATCH: completion



Tanaka Akira wrote:

> In article <199908241043.MAA09262@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
>   Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> writes:
> 
> > Hey, that's good, I didn't think about adding such files -- we could
> > use that to replace `_x_options', too (with `_x_arguments', which
> > could probably still be a pattern function).
> 
> Hm. I prefer _xt_arguments instead of _x_arguments because it depends
> Xt and there is another popular library --- GTK --- that replace it.

Sorry, I wasn't clear. I meant that we should replace the existing
`_x_options' with a new `_x_arguments' which adds only a few simple
standard X options (like `-display') and then uses "$@" like your
_xt_arguments' does (it was that trick that got me excited).

> > Now that I've added `Pbmplus', I'd vote for `Completion/X' (and later
> > `Completion/Gnu', etc.). We'll have to move some things around when we 
> > come to the next open release anyway...
> 
> OK.  I use Completion/X.  However existing files such as _xterm are
> not moved now. They should be moved in next interim release.

Of course, yes. (And `_colors' and `_cursors' should be renamed to
`_x_*' and moved there, too.)

Then I tried to make a first step towards a better `_x_font' and found 
a bug in the completion matching code...

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Tue Aug 24 11:13:20 1999
+++ Src/Zle/zle_tricky.c	Wed Aug 25 14:25:59 1999
@@ -2297,7 +2297,9 @@
 	    for (mp = ms->matcher; mp; mp = mp->next) {
 		t = 1;
 		if ((lm && lm == mp) ||
-		    ((oll == ll || olw == lw) && test && mp->wlen < 0))
+		    ((oll == ll || olw == lw) &&
+		     (test == 1 || (!mp->left && !mp->right)) &&
+		     mp->wlen < 0))
 		    /* If we were called recursively, don't use `*' patterns
 		     * at the beginning (avoiding infinite recursion). */
 		    continue;
@@ -2359,7 +2361,7 @@
 				savw = tp[-zoff];
 				tp[-zoff] = '\0';
 				t = match_str(l - ll, w - lw,
-					      NULL, NULL, 1, 1);
+					      NULL, NULL, 1, 2);
 				tp[-zoff] = savw;
 			    } else
 				t = match_str(l + llen + moff, tp + moff,
@@ -2410,6 +2412,12 @@
 			    add_match_sub(NULL, NULL, ol, op, ol);
 			    add_match_sub(NULL, NULL, llen + alen,
 					  lp, llen + alen);
+			} else if (sfx) {
+			    add_match_str(NULL, NULL,
+					  map, ct + ol + alen, sfx);
+			    add_match_part(mp, l + aoff, wap, alen,
+					   l + loff, llen, op, ol, ol, sfx);
+			    add_match_sub(NULL, NULL, 0, wmp, ct);
 			} else {
 			    add_match_str(NULL, NULL,
 					  map, ct + ol + alen, sfx);
@@ -2590,10 +2598,10 @@
 	}
 	for (t = matchparts; (tn = t->next); t = tn) {
 	    s = (tn->prefix ? tn->prefix : tn->suffix);
-	    if (t->prefix)
-		t->prefix = s;
-	    else
+	    if (t->suffix)
 		t->suffix = s;
+	    else
+		t->prefix = s;
 	}
 	t->prefix = t->suffix = NULL;
     }
@@ -4924,13 +4932,15 @@
 	int n;
 
 	for (n = 0; m; m = m->next, n++) {
-	    *mp = (Cmlist) zhalloc(sizeof(struct cmlist));
-	    (*mp)->matcher = m->matcher;
-	    (*mp)->next = NULL;
-	    (*mp)->str = dupstring(m->str);
-	    mp = &((*mp)->next);
-	    addlinknode(matchers, m->matcher);
-	    m->matcher->refc++;
+	    if (m->matcher) {
+		*mp = (Cmlist) zhalloc(sizeof(struct cmlist));
+		(*mp)->matcher = m->matcher;
+		(*mp)->next = NULL;
+		(*mp)->str = dupstring(m->str);
+		mp = &((*mp)->next);
+		addlinknode(matchers, m->matcher);
+		m->matcher->refc++;
+	    }
 	}
 	m = mm;
 	compmatcher = 1;
diff -u -r oc/Core/_multi_parts Completion/Core/_multi_parts
--- oc/Core/_multi_parts	Wed Aug 25 10:26:40 1999
+++ Completion/Core/_multi_parts	Wed Aug 25 14:50:48 1999
@@ -84,6 +84,8 @@
     # No exact match, see how many strings match what's on the line.
 
     compadd -O tmp1 - "${(@)matches%%${sep}*}"
+    tmp2=( "$tmp1[@]" )
+    tmp1=( "$tmp2[@]" )
 
     if [[ $#tmp1 -eq 1 ]]; then
 
diff -u -r oc/User/_xterm Completion/User/_xterm
--- oc/User/_xterm	Wed Aug 25 10:26:49 1999
+++ Completion/User/_xterm	Wed Aug 25 10:37:10 1999
@@ -20,8 +20,8 @@
   '-cu' '+cu' \
   '-dc' '+dc' \
   '-e:program: _command_names -e:*::program arguments: _normal' \
-  '-fb:bold font:' \
-  '-fi:icon font:' \
+  '-fb:bold font:_x_font' \
+  '-fi:icon font:_x_font' \
   '-hc:background color for highlighted text:_colors' \
   '-hf' '+hf' \
   '-ie' '+ie' \
diff -u -r oc/X/_x_font Completion/X/_x_font
--- oc/X/_x_font	Wed Aug 25 10:26:50 1999
+++ Completion/X/_x_font	Wed Aug 25 14:51:56 1999
@@ -1,3 +1,14 @@
 #autoload
 
-_message 'font'
+local expl
+
+# This *has* to be improved some day...
+
+if (( ! $+_font_cache )); then
+  typeset -U _font_cache
+
+ _font_cache=( "${(@)^${(@f)$(xlsfonts)}%%--*}--" )
+fi
+
+_description expl font
+compgen -M 'r:|-=* r:|=*' "$expl[@]" "$@" -S '' -k _font_cache
diff -u -r oc/X/_xt_arguments Completion/X/_xt_arguments
--- oc/X/_xt_arguments	Wed Aug 25 10:26:51 1999
+++ Completion/X/_xt_arguments	Wed Aug 25 10:30:31 1999
@@ -24,7 +24,6 @@
   '+rv' '-rv' '-reverse' \
   '+synchronous' '-synchronous' \
   '-background:background color:_colors' \
-  '-background:background color:_colors' \
   '-bd:border color:_colors' \
   '-bg:background color:_colors' \
   '-bordercolor:border color:_colors' \

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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