Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Re: TAB and PS2 and multiline buffers and vared
- X-seq: zsh-workers 11688
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: Re: TAB and PS2 and multiline buffers and vared
- Date: Wed, 31 May 2000 11:53:00 +0200 (MET DST)
- In-reply-to: Sven Wischnowsky's message of Thu, 25 May 2000 09:57:14 +0200 (MET DST)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I wrote:
> ...
>
> Hm, should we change the C-code to enforce showing the list when a
> `compadd -x' message was added (that *seems* sensible, but I think
> there may also be cases where one doesn't want that)? Alternatively,
> we could enhance $compstate[list]: if it contains `messages', only the
> messages are shown (like the `explanations' we have now).
I've decided to do the latter. I.e. one can now put `messages' in
$compstate[list] to make it show only the messages. This can be
combined with `explanations' to show both types (but not the matches
themselves).
The former (force listing if messages were added) can then be
implemented in shell code, see _complete_debug for an example.
Bye
Sven
Index: Completion/Commands/_complete_debug
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_complete_debug,v
retrieving revision 1.6
diff -u -r1.6 _complete_debug
--- Completion/Commands/_complete_debug 2000/05/30 03:57:39 1.6
+++ Completion/Commands/_complete_debug 2000/05/31 09:51:57
@@ -20,7 +20,8 @@
[[ -t 3 ]] && {
print -sR "${VISUAL:-${EDITOR:-${PAGER:-more}}} $tmp ;: $w"
_message -r "Trace output left in $tmp (up-history to view)"
- compstate[list]='list force'
+ [[ $compstate[nmatches] -le 1 && $compstate[list] != *force* ]] &&
+ compstate[list]='list force messages'
exec 2>&3 3>&-
}
Index: Completion/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v
retrieving revision 1.26
diff -u -r1.26 _main_complete
--- Completion/Core/_main_complete 2000/05/22 13:55:57 1.26
+++ Completion/Core/_main_complete 2000/05/31 09:51:58
@@ -220,9 +220,9 @@
fi
fi
fi
-elif [[ nm -eq 0 && -n "$_comp_mesg" ]]; then
+elif [[ nm -le 1 && -n "$_comp_mesg" ]]; then
compstate[insert]=''
- compstate[list]='list force'
+ compstate[list]='list force messages'
elif [[ nm -eq 0 &&
$#_lastdescr -ne 0 && $compstate[old_list] != keep ]] &&
zstyle -s ":completion:${curcontext}:warnings" format format; then
@@ -251,7 +251,7 @@
[[ "$_comp_force_list" = always ||
( "$_comp_force_list" = ?* && nm -ge _comp_force_list ) ]] &&
- compstate[list]="$compstate[list] force"
+ compstate[list]="${compstate[list]//messages} force"
[[ "$compstate[old_list]" = keep ]] && ZLS_COLORS="$_saved_colors"
Index: Completion/Core/_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_setup,v
retrieving revision 1.3
diff -u -r1.3 _setup
--- Completion/Core/_setup 2000/05/08 08:16:32 1.3
+++ Completion/Core/_setup 2000/05/31 09:51:58
@@ -64,5 +64,5 @@
zstyle -s ":completion:${curcontext}:$1" force-list val &&
[[ "$val" = always ||
( "$val" = [0-9]## &&
- ( -z "$_comp_force_list" || _comp_force_list -lt val ) ) ]] &&
+ ( -z "$_comp_force_list" || _comp_force_list -gt val ) ) ]] &&
_comp_force_list="$val"
Index: Doc/Zsh/compwid.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v
retrieving revision 1.16
diff -u -r1.16 compwid.yo
--- Doc/Zsh/compwid.yo 2000/05/23 14:23:27 1.16
+++ Doc/Zsh/compwid.yo 2000/05/31 09:52:00
@@ -259,9 +259,12 @@
done for the tt(LIST_ROWS_FIRST) option with the substring tt(rows).
Finally, if the value contains the string tt(explanations), only the
-explanation strings, if any, will be listed. It will be set
-appropriately on entry to a completion widget and may be changed
-there.
+explanation strings, if any, will be listed and if it contains
+tt(messages), only the messages (added with the tt(-x) option of
+tt(compadd)) will be listed. If it contains both tt(explanations) and
+tt(messages) both kinds of explanation strings will be listed. It
+will be set appropriately on entry to a completion widget and may be
+changed there.
)
vindex(list_max, compstate)
item(tt(list_max))(
Index: Functions/Zle/incremental-complete-word
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/incremental-complete-word,v
retrieving revision 1.4
diff -u -r1.4 incremental-complete-word
--- Functions/Zle/incremental-complete-word 2000/04/05 11:07:26 1.4
+++ Functions/Zle/incremental-complete-word 2000/05/31 09:52:00
@@ -118,7 +118,7 @@
# +1 for the status line we will add...
if [[ compstate[list_lines]+BUFFERLINES+1 -gt LINES ]]; then
- compstate[list]='list explanations'
+ compstate[list]='list explanations messages'
[[ compstate[list_lines]+BUFFERLINES+1 -gt LINES ]] && compstate[list]=''
toolong='...'
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.26
diff -u -r1.26 compcore.c
--- Src/Zle/compcore.c 2000/05/31 06:13:50 1.26
+++ Src/Zle/compcore.c 2000/05/31 09:52:01
@@ -440,7 +440,7 @@
if (!showinglist && validlist && usemenu != 2 &&
(nmatches != 1 || diffmatches) &&
useline >= 0 && useline != 2 && (!oldlist || !listshown)) {
- onlyexpl = 1;
+ onlyexpl = 3;
showinglist = -2;
}
compend:
@@ -802,7 +802,8 @@
else
uselist = 0;
forcelist = (complist && strstr(complist, "force"));
- onlyexpl = (complist && strstr(complist, "expl"));
+ onlyexpl = (complist ? ((strstr(complist, "expl") ? 1 : 0) |
+ (strstr(complist, "messages") ? 2 : 0)) : 0);
if (!compinsert)
useline = 0;
@@ -2449,7 +2450,7 @@
for (n = firstnode(expls); n; incnode(n)) {
e = (Cexpl) getdata(n);
- if (!strcmp(curexpl->str, e->str)) {
+ if (e->count >= 0 && !strcmp(curexpl->str, e->str)) {
e->count += curexpl->count;
e->fcount += curexpl->fcount;
@@ -2471,11 +2472,11 @@
for (n = firstnode(expls); n; incnode(n)) {
e = (Cexpl) getdata(n);
- if (!strcmp(mesg, e->str))
+ if (e->count < 0 && !strcmp(mesg, e->str))
return;
}
e = (Cexpl) zhalloc(sizeof(*e));
- e->count = e->fcount = 1;
+ e->count = e->fcount = -1;
e->str = dupstring(mesg);
addlinknode(expls, e);
newmatches = 1;
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.20
diff -u -r1.20 complist.c
--- Src/Zle/complist.c 2000/05/25 11:33:14 1.20
+++ Src/Zle/complist.c 2000/05/31 09:52:03
@@ -1026,7 +1026,9 @@
lastused = 1;
}
while (*e) {
- if ((*e)->count) {
+ if ((*e)->count &&
+ (!listdat.onlyexpl ||
+ (listdat.onlyexpl & ((*e)->count > 0 ? 1 : 2)))) {
if (pnl) {
if (dolistnl(ml) && compprintnl(ml))
goto end;
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.17
diff -u -r1.17 compresult.c
--- Src/Zle/compresult.c 2000/05/31 06:31:22 1.17
+++ Src/Zle/compresult.c 2000/05/31 09:52:04
@@ -1170,7 +1170,8 @@
zsfree(complist);
complist = ztrdup(v);
- onlyexpl = (v && strstr(v, "expl"));
+ onlyexpl = (v ? ((strstr(v, "expl") ? 1 : 0) |
+ (strstr(v, "messages") ? 2 : 0)) : 0);
}
/* This skips over matches that are not to be listed. */
@@ -1300,7 +1301,9 @@
}
if ((e = g->expls)) {
while (*e) {
- if ((*e)->count)
+ if ((*e)->count &&
+ (!onlyexpl ||
+ (onlyexpl & ((*e)->count > 0 ? 1 : 2))))
nlines += 1 + printfmt((*e)->str, (*e)->count, 0, 1);
e++;
}
@@ -1690,7 +1693,9 @@
int l;
while (*e) {
- if ((*e)->count) {
+ if ((*e)->count &&
+ (!listdat.onlyexpl ||
+ (listdat.onlyexpl & ((*e)->count > 0 ? 1 : 2)))) {
if (pnl) {
putc('\n', shout);
pnl = 0;
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author