Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: zle_tricky.c (was: Re: Problem with setting both listpacked&listrowsfirst?)
- X-seq: zsh-workers 8205
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: zle_tricky.c (was: Re: Problem with setting both listpacked&listrowsfirst?)
- Date: Mon, 11 Oct 1999 14:05:08 +0200 (MET DST)
- In-reply-to: "Bart Schaefer"'s message of Sat, 25 Sep 1999 22:07:51 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> On Sep 23, 11:31pm, Felix Rosencrantz wrote:
> } Subject: Problem with setting both listpacked&listrowsfirst?
> }
> } I think I've applied all the completion patches to ZSH 3.1.6-pws-5.
> } (7959 7960 7974 7985 7998 8011 8021 8028)
> }
> } When I do a "setopt listpacked listrowsfirst" and attempt completion
> } with tab I don't get a listing for ambiguous matches.
>
> I can reproduce this, but ONLY if using the new-style completions, and
> then (so far) only for normal file completions (e.g. completion after
> "ls"). It's got something to do with lines 8880-8919 of zle_tricky.c,
> and how the value of `i' is computed (Sven, I know it's going to be two
> weeks until you read this, but: I thought you were going to start using
> more descriptive variable names?).
>
> I tried a few different tweaks, but although I got it to display the list
> I couldn't get it to position the cursor properly afterwards.
>
> I can't figure out how to get zsh to enter the branch at 8826-8856, so
> I don't know whether that has a problem as well.
>
> Even for completions that do work, the columns are ragged:
>
> zagzig<4> set<TAB>
> set setclock setconsole setenv setfdprm setfont
> setfx setkeycodes setleds setmetamode setopt setserial
> setsid setsysfont setterm setup setup_compinit setxkbmap
>
> I don't know of that's an intended side-effect of LISTPACKED or not, but
> it doesn't always happen.
I found this, too, while I was away, but I can't reproduce the
missing-list problem. Hm.
The patch contains some more fixes: gcc was complaining about some
uninitialised variables again (and in one place this was even
dangerous, oops), `compcall' without the `-D' option now doesn't add
matches for special contexts, too (this is a bug fix) and then there
was the typo in calclist() which caused the ragged list.
Does this also fix the missing-list problem? Since even Bart couldn't
reproduce it every time, this may have had to do with the
uninitialised variable stuff.
Bye
Sven
--- oos/Zle/zle_tricky.c Mon Oct 11 13:30:01 1999
+++ Src/Zle/zle_tricky.c Mon Oct 11 13:52:21 1999
@@ -3983,7 +3983,7 @@
char **aign = NULL, **dparr = NULL, oaq = autoq, *oppre = dat->ppre;
char *oqp = qipre, *oqs = qisuf, qc, **disp = NULL;
int lpl, lsl, pl, sl, bpl, bsl, bppl = -1, bssl = -1;
- int llpl = 0, llsl = 0, nm = mnum, gflags;
+ int llpl = 0, llsl = 0, nm = mnum, gflags = 0;
int oisalt = 0, isalt, isexact, doadd, ois = instring, oib = inbackt;
Cline lc = NULL;
Cmatch cm;
@@ -5779,7 +5779,7 @@
static int
makecomplistglobal(char *os, int incmd, int lst, int flags)
{
- Compctl cc;
+ Compctl cc = NULL;
char *s;
ccont = CC_CCCONT;
@@ -5787,38 +5787,46 @@
if (linwhat == IN_ENV) {
/* Default completion for parameter values. */
- cc = &cc_default;
- keypm = NULL;
- } else if (linwhat == IN_MATH) {
- if (insubscr >= 2) {
- /* Inside subscript of assoc array, complete keys. */
- cc_dummy.mask = 0;
- cc_dummy.suffix = (insubscr == 2 ? "]" : "");
- } else {
- /* Other math environment, complete paramete names. */
+ if (!(flags & CFN_DEFAULT)) {
+ cc = &cc_default;
keypm = NULL;
- cc_dummy.mask = CC_PARAMS;
}
- cc = &cc_dummy;
- cc_dummy.refc = 10000;
+ } else if (linwhat == IN_MATH) {
+ if (!(flags & CFN_DEFAULT)) {
+ if (insubscr >= 2) {
+ /* Inside subscript of assoc array, complete keys. */
+ cc_dummy.mask = 0;
+ cc_dummy.suffix = (insubscr == 2 ? "]" : "");
+ } else {
+ /* Other math environment, complete paramete names. */
+ keypm = NULL;
+ cc_dummy.mask = CC_PARAMS;
+ }
+ cc = &cc_dummy;
+ cc_dummy.refc = 10000;
+ }
} else if (linwhat == IN_COND) {
/* We try to be clever here: in conditions we complete option *
* names after a `-o', file names after `-nt', `-ot', and `-ef' *
* and file names and parameter names elsewhere. */
- s = clwpos ? clwords[clwpos - 1] : "";
- cc_dummy.mask = !strcmp("-o", s) ? CC_OPTIONS :
- ((*s == '-' && s[1] && !s[2]) ||
- !strcmp("-nt", s) ||
- !strcmp("-ot", s) ||
- !strcmp("-ef", s)) ? CC_FILES :
- (CC_FILES | CC_PARAMS);
- cc = &cc_dummy;
- cc_dummy.refc = 10000;
- keypm = NULL;
+ if (!(flags & CFN_DEFAULT)) {
+ s = clwpos ? clwords[clwpos - 1] : "";
+ cc_dummy.mask = !strcmp("-o", s) ? CC_OPTIONS :
+ ((*s == '-' && s[1] && !s[2]) ||
+ !strcmp("-nt", s) ||
+ !strcmp("-ot", s) ||
+ !strcmp("-ef", s)) ? CC_FILES :
+ (CC_FILES | CC_PARAMS);
+ cc = &cc_dummy;
+ cc_dummy.refc = 10000;
+ keypm = NULL;
+ }
} else if (linredir) {
- /* In redirections use default completion. */
- cc = &cc_default;
- keypm = NULL;
+ if (!(flags & CFN_DEFAULT)) {
+ /* In redirections use default completion. */
+ cc = &cc_default;
+ keypm = NULL;
+ }
} else {
/* Otherwise get the matches for the command. */
keypm = NULL;
@@ -6980,7 +6988,7 @@
if (!errflag && cc->ylist) {
/* generate the user-defined display list: if anything fails, *
* we silently allow the normal completion list to be used. */
- char **yaptr, *uv = NULL;
+ char **yaptr = NULL, *uv = NULL;
List list;
if (cc->ylist[0] == '$' || cc->ylist[0] == '(') {
@@ -8955,7 +8963,7 @@
}
for (g = amatches; g; g = g->next) {
if (g->widths) {
- int *p, a = (max - g->totl - add) / g->cols;
+ int *p, a = (max - g->totl + add) / g->cols;
for (i = g->cols, p = g->widths; i; i--, p++)
*p += a;
@@ -9024,7 +9032,7 @@
Cmatch *p, m;
Cexpl *e;
int pnl = 0, cl = (over ? listdat.nlines : -1);
- int mc, ml = 0, printed = 0;
+ int mc = 0, ml = 0, printed = 0;
if (cl < 2) {
cl = -1;
@@ -9135,7 +9143,7 @@
}
}
printed++;
- printm(g, p, mc, ml, 1, 0, NULL, NULL);
+ printm(g, p, 0, ml, 1, 0, NULL, NULL);
pnl = 1;
}
}
@@ -9183,7 +9191,7 @@
mc++;
}
while (i-- > 0)
- printm(g, NULL, mc, ml, (!i),
+ printm(g, NULL, mc++, ml, (!i),
(g->widths ? g->widths[mc] : g->width), NULL, NULL);
if (n) {
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author