From 5a4253f42edc9258a9a5bad59b0fa2a7b4a46d50 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Wed, 31 May 2000 09:56:12 +0000 Subject: allow display of only messages via $compstate[list]=messages (11688) --- ChangeLog | 6 ++++++ Completion/Commands/_complete_debug | 3 ++- Completion/Core/_main_complete | 6 +++--- Completion/Core/_setup | 2 +- Doc/Zsh/compwid.yo | 9 ++++++--- Functions/Zle/incremental-complete-word | 2 +- Src/Zle/compcore.c | 11 ++++++----- Src/Zle/complist.c | 4 +++- Src/Zle/compresult.c | 11 ++++++++--- 9 files changed, 36 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7163043bd..5986061f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2000-05-31 Sven Wischnowsky + * 11688: Completion/Commands/_complete_debug, + Completion/Core/_main_complete, Completion/Core/_setup, + Doc/Zsh/compwid.yo, Functions/Zle/incremental-complete-word, + Src/Zle/compcore.c, Src/Zle/complist.c, Src/Zle/compresult.c: + allow display of only messages via $compstate[list]=messages + * 11549: Completion/Base/_combination, Completion/Base/_command_names, Completion/Base/_describe, Completion/Base/_equal, Completion/Base/_subscript, Completion/Base/_tilde, diff --git a/Completion/Commands/_complete_debug b/Completion/Commands/_complete_debug index a876839c0..4f0ce7f27 100644 --- a/Completion/Commands/_complete_debug +++ b/Completion/Commands/_complete_debug @@ -20,7 +20,8 @@ unsetopt xtrace [[ -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>&- } diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index a9a1d2a9a..39c8f0e5e 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -220,9 +220,9 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then 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 @@ fi [[ "$_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" diff --git a/Completion/Core/_setup b/Completion/Core/_setup index 6d5f09ab3..6bc36e3ef 100644 --- a/Completion/Core/_setup +++ b/Completion/Core/_setup @@ -64,5 +64,5 @@ fi 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" diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo index ee2f7f2bd..c54caea31 100644 --- a/Doc/Zsh/compwid.yo +++ b/Doc/Zsh/compwid.yo @@ -259,9 +259,12 @@ group, this group will show the tt(LIST_PACKED) behavior. The same is 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))( diff --git a/Functions/Zle/incremental-complete-word b/Functions/Zle/incremental-complete-word index 27d02f6c4..2ec892c77 100644 --- a/Functions/Zle/incremental-complete-word +++ b/Functions/Zle/incremental-complete-word @@ -118,7 +118,7 @@ icw-list-helper() { # +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='...' diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 1a18f14e3..ded5c3b31 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -440,7 +440,7 @@ do_completion(Hookdef dummy, Compldat dat) 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 @@ callcompfunc(char *s, char *fn) 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 @@ addexpl(void) 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 @@ addmesg(char *mesg) 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; diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index bbf2b8d4a..2f7873d63 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -1026,7 +1026,9 @@ compprintlist(int showall) 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; diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index 4ffd4d62a..1e807a93d 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -1170,7 +1170,8 @@ comp_list(char *v) 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 @@ calclist(int showall) } 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 @@ printlist(int over, CLPrintFunc printm, int showall) 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; -- cgit 1.4.1