about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Core/_message26
-rw-r--r--Doc/Zsh/compwid.yo9
-rw-r--r--Src/Zle/comp.h1
-rw-r--r--Src/Zle/compcore.c26
-rw-r--r--Src/Zle/complete.c8
6 files changed, 59 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 58806c1db..c87e934d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@
 
 2000-05-02  Sven Wischnowsky  <wischnow@informatik.hu-berlin.de>
 
+	* 11058: Completion/Core/_message, Doc/Zsh/compwid.yo, Src/Zle/comp.h,
+ 	Src/Zle/compcore.c, Src/Zle/complete.c: add -x option to compadd
+ 	to display message unconditionally
+	
 	* 11053: Completion/Commands/_complete_help: always use empty
  	matcher-list style in _complete_help
 	
diff --git a/Completion/Core/_message b/Completion/Core/_message
index 0837cdf2f..8e1d23679 100644
--- a/Completion/Core/_message
+++ b/Completion/Core/_message
@@ -1,19 +1,23 @@
 #autoload
 
-local format
+local format raw
 
-format="$compconfig[message_format]"
-[[ -z "$format" ]] && "$compconfig[description_format]"
+_tags messages || return 1
 
-if [[ -n "$format" ]]; then
+if [[ "$1" = -r ]]; then
+  raw=yes
+  shift
+  format="$1"
+else
+  zstyle -s ":completion:${curcontext}:messages" format format ||
+      zstyle -s ":completion:${curcontext}:descriptions" format format
+fi
+
+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
+    compstate[list]='list force'
     compstate[insert]=''
-    compadd -UX "${format//\\%d/$1}" -n ''
-  else
-    compadd -X "${format//\\%d/$1}" -n ''
   fi
-  compstate[force_list]=yes
-else
-  compadd -n ''
 fi
diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index 5ef94a5c6..1ca6d11a6 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -395,7 +395,7 @@ xitem([ tt(-P) var(prefix) ] [ tt(-S) var(suffix) ])
 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 @@ duplicates be kept. Again, groups with and without this flag are in
 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 
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index f513d4a5a..9239fbee0 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -257,6 +257,7 @@ struct cadata {
     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. */
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 8e713348f..44ec8ef6a 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1538,6 +1538,8 @@ addmatches(Cadata dat, char **argv)
 		endcmgroup(NULL);
 		begcmgroup("default", 0);
 	    }
+	    if (dat->mesg)
+		addmesg(dat->mesg);
 	} SWITCHBACKHEAPS;
 
 	return 1;
@@ -1785,6 +1787,8 @@ addmatches(Cadata dat, char **argv)
 	    endcmgroup(NULL);
 	    begcmgroup("default", 0);
 	}
+	if (dat->mesg)
+	    addmesg(dat->mesg);
 	if (*argv) {
 	    if (dat->pre)
 		dat->pre = dupstring(dat->pre);
@@ -2366,6 +2370,28 @@ addexpl(void)
     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). */
 
 /**/
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 7a15eb077..8c8950303 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -413,7 +413,7 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 	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 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 		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 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 
  ca_args:
 
-    if (!*argv && !dat.group &&
+    if (!*argv && !dat.group && !dat.mesg &&
 	!(dat.aflags & (CAF_NOSORT|CAF_UNIQALL|CAF_UNIQCON)))
 	return 1;