Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: _message sometimes doesn't
- X-seq: zsh-workers 11058
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: _message sometimes doesn't
- Date: Tue, 2 May 2000 11:56:35 +0200 (MET DST)
- In-reply-to: "Bart Schaefer"'s message of Sun, 30 Apr 2000 17:18:19 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> Using the new _complete_debug widget from 11024:
>
> zagzig[44] find <C-x?>
> Trace output left in /tmp/zsh322find1
> Completing directory
> StartupFiles/ Config/ Test/ Src/
> Util/ Etc/ Functions/ CVS/
> Misc/ Doc/ Completion/
> zagzig[44] find -<C-x?>
> Completing option
> -amin -false -ilname -mmin -perm -used
> -anewer -fls -iname -mount -print -user
> -atime -follow -inum -mtime -print0 -version
> -cmin -fprint -ipath -name -printf -xdev
> -cnewer -fprint0 -iregex -newer -prune -xtype
> -ctime -fprintf -links -nogroup -regex
> -daystart -fstype -lname -noleaf -size
> -depth -gid -ls -nouser -true
> -empty -group -maxdepth -ok -type
> -exec -help -mindepth -path -uid
>
> Where did the "Trace output left in ..." message go, in the second case?
> Am I just misunderstanding _message?
No, you aren't.
It's that dratted %&$*#&@ old behaviour of -X messages: they are only
shown when there are matches in the group and _message doesn't say
which group to add the message to and...
I finally got too annoyed and added the -x option to compadd which can
be used to give a message that should always be shown. And we don't
have to add any dummy-matches for it either.
Bye
Sven
Index: Completion/Core/_message
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_message,v
retrieving revision 1.1.1.12
diff -u -r1.1.1.12 _message
--- Completion/Core/_message 2000/02/18 10:11:05 1.1.1.12
+++ Completion/Core/_message 2000/05/02 09:53:33
@@ -15,11 +15,9 @@
if [[ -n "$format$raw" ]]; then
[[ -z "$raw" ]] && zformat -f format "$format" "d:$1" "${(@)argv[2,-1]}"
+ compadd -x "$format"
if [[ $compstate[nmatches] -eq 0 ]]; then
compstate[list]='list force'
compstate[insert]=''
- compadd -UX "${format}" -n ''
- else
- compadd -X "${format}" -n '' && compstate[list]='list force'
fi
fi
Index: Doc/Zsh/compwid.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v
retrieving revision 1.8
diff -u -r1.8 compwid.yo
--- Doc/Zsh/compwid.yo 2000/05/02 08:14:29 1.8
+++ Doc/Zsh/compwid.yo 2000/05/02 09:53:34
@@ -395,7 +395,7 @@
xitem([ tt(-p) var(hidden-prefix) ] [ tt(-s) var(hidden-suffix) ])
xitem([ tt(-i) var(ignored-prefix) ] [ tt(-I) var(ignored-suffix) ])
xitem([ tt(-W) var(file-prefix) ] [ tt(-d) var(array) ])
-xitem([ tt(-J) var(name) ] [ tt(-V) var(name) ] [ tt(-X) var(explanation) ])
+xitem([ tt(-J) var(name) ] [ tt(-V) var(name) ] [ tt(-X) var(explanation) ] [ tt(-x) var(message) ])
xitem([ tt(-r) var(remove-chars) ] [ tt(-R) var(remove-func) ])
xitem([ tt(-D) var(array) ] [ tt(-O) var(array) ] [ tt(-A) var(array) ])
item([ tt(-M) var(match-spec) ] [ tt(--) ] [ var(words) ... ])(
@@ -490,7 +490,12 @@
different name spaces.
)
item(tt(-X) var(explanation))(
-The var(explanation) string will be printed with the list of matches.
+The var(explanation) string will be printed with the list of matches,
+above the group currently selected.
+)
+item(tt(-x) var(message))(
+Like tt(-X), but the var(message) will be printed even if there are no
+matches in the group.
)
item(tt(-q))(
The suffix given with tt(-S) will be automatically removed if
Index: Src/Zle/comp.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/comp.h,v
retrieving revision 1.2
diff -u -r1.2 comp.h
--- Src/Zle/comp.h 2000/04/01 20:49:48 1.2
+++ Src/Zle/comp.h 2000/05/02 09:53:34
@@ -257,6 +257,7 @@
char *opar; /* array to store originals in (-O) */
char *dpar; /* array to delete non-matches in (-D) */
char *disp; /* array with display lists (-d) */
+ char *mesg; /* message to show unconditionally (-x) */
};
/* List data. */
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.12
diff -u -r1.12 compcore.c
--- Src/Zle/compcore.c 2000/04/30 17:58:36 1.12
+++ Src/Zle/compcore.c 2000/05/02 09:53:34
@@ -1538,6 +1538,8 @@
endcmgroup(NULL);
begcmgroup("default", 0);
}
+ if (dat->mesg)
+ addmesg(dat->mesg);
} SWITCHBACKHEAPS;
return 1;
@@ -1785,6 +1787,8 @@
endcmgroup(NULL);
begcmgroup("default", 0);
}
+ if (dat->mesg)
+ addmesg(dat->mesg);
if (*argv) {
if (dat->pre)
dat->pre = dupstring(dat->pre);
@@ -2364,6 +2368,28 @@
}
addlinknode(expls, curexpl);
newmatches = 1;
+}
+
+/* Add a message to the current group. Make sure it is shown. */
+
+/**/
+mod_export void
+addmesg(char *mesg)
+{
+ LinkNode n;
+ Cexpl e;
+
+ for (n = firstnode(expls); n; incnode(n)) {
+ e = (Cexpl) getdata(n);
+ if (!strcmp(mesg, e->str))
+ return;
+ }
+ e = (Cexpl) zhalloc(sizeof(*e));
+ e->count = e->fcount = 1;
+ e->str = dupstring(mesg);
+ addlinknode(expls, e);
+ newmatches = 1;
+ mgroup->new = 1;
}
/* The comparison function for matches (used for sorting). */
Index: Src/Zle/complete.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complete.c,v
retrieving revision 1.6
diff -u -r1.6 complete.c
--- Src/Zle/complete.c 2000/04/27 09:04:32 1.6
+++ Src/Zle/complete.c 2000/05/02 09:53:35
@@ -413,7 +413,7 @@
zwarnnam(name, "can only be called from completion function", NULL, 0);
return 1;
}
- dat.ipre = dat.isuf = dat.ppre = dat.psuf = dat.prpre =
+ dat.ipre = dat.isuf = dat.ppre = dat.psuf = dat.prpre = dat.mesg =
dat.pre = dat.suf = dat.group = dat.rems = dat.remf = dat.disp =
dat.ign = dat.exp = dat.apar = dat.opar = dat.dpar = NULL;
dat.match = NULL;
@@ -507,6 +507,10 @@
sp = &(dat.exp);
e = "string expected after -%c";
break;
+ case 'x':
+ sp = &(dat.mesg);
+ e = "string expected after -%c";
+ break;
case 'r':
dat.flags |= CMF_REMOVE;
sp = &(dat.rems);
@@ -575,7 +579,7 @@
ca_args:
- if (!*argv && !dat.group &&
+ if (!*argv && !dat.group && !dat.mesg &&
!(dat.aflags & (CAF_NOSORT|CAF_UNIQALL|CAF_UNIQCON)))
return 1;
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author