about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-07-03 08:05:27 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-07-03 08:05:27 +0000
commit0ddb4fb835d685b5dc71dadc08d5758a28b99439 (patch)
tree466c89b29279f1d9459e1c663a68154830cb293b
parent4ed8c26c50dea84a01903e6d80b68701d9c4f3c0 (diff)
downloadzsh-0ddb4fb835d685b5dc71dadc08d5758a28b99439.tar.gz
zsh-0ddb4fb835d685b5dc71dadc08d5758a28b99439.tar.xz
zsh-0ddb4fb835d685b5dc71dadc08d5758a28b99439.zip
change format style with warnings tag, don't add descriptions as matches; make a-a-i-n-h in menu selection work even without matches (12134)
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Core/_main_complete26
-rw-r--r--Doc/Zsh/compsys.yo9
-rw-r--r--Doc/Zsh/mod_complist.yo6
-rw-r--r--Src/Zle/comp.h1
-rw-r--r--Src/Zle/compcore.c6
-rw-r--r--Src/Zle/complist.c33
7 files changed, 58 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 81a1d3a7d..96134245f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2000-07-03  Sven Wischnowsky  <wischnow@zsh.org>
+
+	* 12134: Completion/Core/_main_complete, Doc/Zsh/compsys.yo,
+ 	Doc/Zsh/mod_complist.yo, Src/Zle/comp.h, Src/Zle/compcore.c,
+ 	Src/Zle/complist.c: change format style with warnings tag, don't
+ 	add descriptions as matches; make a-a-i-n-h in menu selection work
+ 	even without matches
+	
 2000-07-02  Bart Schaefer  <schaefer@zsh.org>
 
 	* 12133: Completion/Core/_expand, Completion/Core/_path_files:
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 705208715..8d77bbd2e 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -25,7 +25,7 @@ setopt localtraps noerrexit ; trap - ZERR
 
 local func funcs ret=1 tmp _compskip format nm call match min max i num\
       _completers _completer _completer_num curtag _comp_force_list \
-      _matchers _matcher _matcher_num _comp_tags _comp_mesg \
+      _matchers _matcher _matcher_num _comp_tags _comp_mesg mesg str \
       context state line opt_args val_args curcontext="$curcontext" \
       _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \
       _saved_exact="${compstate[exact]}" \
@@ -266,23 +266,17 @@ elif [[ nm -eq 0 &&
   compstate[list]='list force'
   compstate[insert]=''
 
-  if [[ "$format" = *%d* ]]; then
-    local str mesg
+  tmp=( "\`${(@)^_lastdescr:#}'" )
 
-    _lastdescr=( "\`${(@)^_lastdescr:#}'" )
+  case $#tmp in
+  1) str="$tmp[1]";;
+  2) str="$tmp[1] or $tmp[2]";;
+  *) str="${(j:, :)tmp[1,-2]}, or $tmp[-1]";;
+  esac
 
-    case $#_lastdescr in
-    1) str="$_lastdescr[1]";;
-    2) str="$_lastdescr[1] or $_lastdescr[2]";;
-    *) str="${(j:, :)_lastdescr[1,-2]}, or $_lastdescr[-1]";;
-    esac
-
-    zformat -f mesg "$format" "d:$str"
-    compadd -UX "$mesg" -n - ''
-  else
-    _setup warnings
-    compadd -UQX "$format" -V warnings - "${(@)_lastdescr:#}"
-  fi
+  _setup warnings
+  zformat -f mesg "$format" "d:$str" "D:${(F)${(@)_lastdescr:#}}"
+  compadd -x "$mesg"
 fi
 
 [[ "$_comp_force_list" = always ||
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 5e36c2e3d..73060c038 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1143,12 +1143,9 @@ replaced with the message given by the completion function.
 
 Finally, when set with the tt(warnings) tag, the format string is printed
 when no matches could be generated at all.  In this case the `tt(%d)' is
-replaced with the descriptions for the matches that were expected.  If the
-value does not contain a `tt(%d)', then those descriptions are added in the
-same way as matches are added, i.e. they appear below the value for the
-tt(format) style laid out in columns.  The descriptions are added as if for
-the tag tt(warnings) so that you can use the tt(list-colors) style for that
-tag to highlight them.
+replaced with the descriptions for the matches that were expected
+separated by spaces and the sequence `tt(%D)' is replaced with those
+descriptions separated by newlines.
 
 The `tt(%)' for the sequences that are replaced by strings provided by 
 the completion functions like the `tt(%d)' may be followed by field
diff --git a/Doc/Zsh/mod_complist.yo b/Doc/Zsh/mod_complist.yo
index bc62b58ca..3a73b5284 100644
--- a/Doc/Zsh/mod_complist.yo
+++ b/Doc/Zsh/mod_complist.yo
@@ -267,7 +267,11 @@ select the next match to insert into the line
 item(tt(accept-and-infer-next-history))(
 accepts the current match and then tries completion with
 menu-selection again;  in the case of files this allows one to select
-a directory and immediately attempt to complete files in it
+a directory and immediately attempt to complete files in it;  if there 
+are no matches, a message is shown and one can use tt(undo) to go back 
+to completion on the previous level, every other key leaves menu
+selection (including the other zle functions which are otherwise
+special during menu selection)
 )
 item(tt(undo))(
 removes matches inserted during the menu selection by one of the three 
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index 506d85135..57091c744 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -388,6 +388,7 @@ typedef struct chdata *Chdata;
 struct chdata {
     Cmgroup matches;		/* the matches generated */
     int num;			/* the number of matches */
+    int nmesg;			/* the number of messages */
     Cmatch cur;			/* current match or NULL */
 };
 
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 895267535..1a1241853 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -350,8 +350,9 @@ do_completion(Hookdef dummy, Compldat dat)
     if (comppatmatch && *comppatmatch && comppatmatch != opm)
 	haspattern = 1;
     if (iforcemenu) {
-	do_ambig_menu();
-	ret = 0;
+	if (nmatches)
+	    do_ambig_menu();
+	ret = !nmatches;
     } else if (useline < 0)
 	ret = selfinsert(zlenoargs);
     else if (!useline && uselist) {
@@ -511,6 +512,7 @@ after_complete(Hookdef dummy, int *dat)
 
 	cdat.matches = amatches;
 	cdat.num = nmatches;
+	cdat.nmesg = nmessages;
 	cdat.cur = NULL;
 	if ((ret = runhookdef(MENUSTARTHOOK, (void *) &cdat))) {
 	    dat[1] = 0;
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 30bc17f88..7c2fdfe57 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1632,6 +1632,7 @@ domenuselect(Hookdef dummy, Chdata dat)
     Menustack u = NULL;
     int i = 0, acc = 0, wishcol = 0, setwish = 0, oe = onlyexpl, wasnext = 0;
     int space, lbeg = 0, step = 1, wrap, pl = nlnct, broken = 0, first = 1;
+    int nolist = 0;
     char *s;
 
     if (fdat || (dummy && (!(s = getsparam("MENUSELECT")) ||
@@ -1639,6 +1640,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 	if (fdat) {
 	    fdat->matches = dat->matches;
 	    fdat->num = dat->num;
+	    fdat->nmesg = dat->nmesg;
 	}
 	return 0;
     }
@@ -1753,9 +1755,14 @@ domenuselect(Hookdef dummy, Chdata dat)
 	}
 	setwish = wasnext = 0;
 
+    getk:
+
 	if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) {
 	    zbeep();
 	    break;
+	} else if (nolist && cmd != Th(z_undo)) {
+	    ungetkeycmd();
+	    break;
 	} else if (cmd == Th(z_acceptline)) {
 	    acc = 1;
 	    break;
@@ -1794,10 +1801,24 @@ domenuselect(Hookdef dummy, Chdata dat)
 	    iforcemenu = 0;
 
 	    if (dat->num < 1 || !minfo.cur || !*(minfo.cur)) {
-		noselect = clearlist = listshown = 1;
-		onlyexpl = 0;
-		zrefresh();
-		break;
+		nolist = 1;
+		if (dat->nmesg || nmessages) {
+		    showinglist = -2;
+		    zrefresh();
+		} else {
+		    trashzle();
+		    zsetterm();
+		    if (tccan(TCCLEAREOD))
+			tcout(TCCLEAREOD);
+		    fputs("no matches\r", shout);
+		    fflush(shout);
+		    tcmultout(TCUP, TCMULTUP, nlnct);
+		    showinglist = clearlist = 0;
+		    clearflag = 1;
+		    zrefresh();
+		    showinglist = clearlist = 0;
+		}
+		goto getk;
 	    }
 	    clearlist = listshown = 1;
 	    mselect = (*(minfo.cur))->gnum;
@@ -1861,7 +1882,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 		break;
 
 	    handleundo();
-	    cs = 0;
+	    cs = nolist = 0;
 	    foredel(ll);
 	    spaceinline(l = strlen(u->line));
 	    strncpy((char *) line, u->line, l);
@@ -1879,7 +1900,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 		lastmatches = u->lastmatches;
 		lastlmatches = u->lastlmatches;
 		nmatches = u->nmatches;
-		hasoldlist = 1;
+		hasoldlist = validlist = 1;
 	    }
 	    freebrinfo(brbeg);
 	    freebrinfo(brend);