From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13873 invoked from network); 24 Jun 2008 00:20:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 24 Jun 2008 00:20:07 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 60532 invoked from network); 24 Jun 2008 00:19:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 24 Jun 2008 00:19:57 -0000 Received: (qmail 29775 invoked by alias); 24 Jun 2008 00:19:53 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25242 Received: (qmail 29763 invoked from network); 24 Jun 2008 00:19:53 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 24 Jun 2008 00:19:53 -0000 Received: from smtp.bredband2.net (mail.bredband2.net [82.209.166.4]) by bifrost.dotsrc.org (Postfix) with ESMTP id D4B7080524FD for ; Tue, 24 Jun 2008 02:19:49 +0200 (CEST) Received: (qmail 29691 invoked from network); 24 Jun 2008 00:19:18 -0000 Received: from kr-lun-154-152-233-83.3.cust.bredband2.com (HELO mika.l3ib.org) ([83.233.152.154]) (envelope-sender ) by smtp.bredband2.net (qmail-ldap-1.03) with SMTP for ; 24 Jun 2008 00:19:18 -0000 Date: Tue, 24 Jun 2008 02:19:47 +0200 (CEST) From: Mikael Magnusson To: zsh-workers@sunsite.dk Subject: New test character V for conditional prompts Message-ID: User-Agent: Alpine 1.00 (LNX ) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Virus-Scanned: ClamAV 0.92.1/7545/Mon Jun 23 23:39:43 2008 on bifrost X-Virus-Status: Clean Hi, I'm already using psvar for Some Stuff, and now I wanted to also use it for Some Other Stuff, in both cases my construct looks like %(3v.(%3v).) ie I don't want the parentheses when the psvar is unset. When using psvar for two different things, at least one will currently always enable the other since %(3v..) tests psvar for having at least 3 elements. The following patch adds the V character for testing if element of psvar is actually set to a string (it currently tests false if the element is set but the empty string). diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo index d517734..3c96733 100644 --- a/Doc/Zsh/prompt.yo +++ b/Doc/Zsh/prompt.yo @@ -274,6 +274,7 @@ sitem(tt(S))(True if the tt(SECONDS) parameter is at least var(n).) sitem(tt(T))(True if the time in hours is equal to var(n).) sitem(tt(t))(True if the time in minutes is equal to var(n).) sitem(tt(v))(True if the array tt(psvar) has at least var(n) elements.) +sitem(tt(V))(True if element var(n) of the array tt(psvar) is set and non-empty.) sitem(tt(w))(True if the day of the week is equal to var(n) (Sunday = 0).) endsitem() ) diff --git a/Src/prompt.c b/Src/prompt.c index 034a4fa..72ba2e2 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -321,6 +321,12 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) if (arrlen(psvar) >= arg) test = 1; break; + case 'V': + if (arrlen(psvar) >= arg) { + if (*psvar[(arg ? arg : 1) - 1]) + test = 1; + } + break; case '_': test = (cmdsp >= arg); break; -- Mikael Magnusson