From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11217 invoked from network); 12 Nov 2004 09:24:43 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Nov 2004 09:24:43 -0000 Received: (qmail 28163 invoked from network); 12 Nov 2004 09:24:37 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Nov 2004 09:24:37 -0000 Received: (qmail 1448 invoked by alias); 12 Nov 2004 09:23:48 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8208 Received: (qmail 1433 invoked from network); 12 Nov 2004 09:23:47 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Nov 2004 09:23:47 -0000 Received: (qmail 26340 invoked from network); 12 Nov 2004 09:22:48 -0000 Received: from smtp-out1.blueyonder.co.uk (195.188.213.4) by a.mx.sunsite.dk with SMTP; 12 Nov 2004 09:22:45 -0000 Received: from sc ([82.41.214.33]) by smtp-out1.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Fri, 12 Nov 2004 09:23:11 +0000 Date: Fri, 12 Nov 2004 09:22:26 +0000 From: Stephane Chazelas To: Zsh users list Subject: Re: [tip] mouse support Message-ID: <20041112092226.GA4461@sc> Mail-Followup-To: Zsh users list References: <20041111122011.GB4451@sc> <4483.1100184032@csr.com> <20041111162209.GC4451@sc> <20041111182225.GA4345@sc> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.6i X-OriginalArrivalTime: 12 Nov 2004 09:23:11.0827 (UTC) FILETIME=[3AFA9A30:01C4C899] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: * X-Spam-Status: No, hits=1.5 required=6.0 tests=RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 1.5 On Thu, Nov 11, 2004 at 05:02:47PM -0800, Bart Schaefer wrote: > On Thu, 11 Nov 2004, Stephane Chazelas wrote: > > > zero='%([BSUbsu]|{*%})' > > > > It replaces '%%some %{%{some%}%}' with '%ome %}' instead of > > '%%some ' > > Hmm. To fix that, you need extended globbing: > > setopt extendedglob > zero='(#b)([^%]|(#s))%([BSUbsu]|{*%})' > print ${(%%)PS1//$~zero/$match[1]} [...] That moves the problem (the first one) ow, there's a problem with '%%%S' A better fix: zero='(#b)(%([BSUbsu]|{*%})|(%[^BSUbsu{}]))' print ${(S%%)PS1//$~zero/$match[3]} But, it still doesn't fix the problem of nested %{ (maybe not too big an issue, as I can't think of any case where nesting %{'s can be useful). > On Thu, 11 Nov 2004, Stephane Chazelas wrote: > > > Well the (%%) expansion flag has another problem: > > > > var='%Sfoo%s' > > PS1='$var' > > > > In that case, you need to expand first the variables in PS1 or > > you'll miss the %S %s visual sequences. > > That's easy enough: > > if [[ -o promptsubst ]] > then print ${(%%)${(e)PS1}//$~zero/$match[1]} > else print ${(%%)PS1//$~zero/$match[1]} > fi Yes, that was what I did. Except that I used (%) instead of (%%). But with (%%) PS1 may be expanded again (PS1='$(echo "\$foo")') So a refined solution could be: local cur_prompt if [[ -n $PREBUFFER ]]; then cur_prompt=$PS2 # decide wether we're at the PS2 or PS1 prompt else cur_prompt=$PS1 fi [[ -o promptsubst ]] && cur_prompt=${${(e)cur_prompt}//(#b)([\\\$\`])/\\$match} # restore the exit status in case $PS relies on it set-status $last_status cur_prompt=${(S%%)cur_prompt//(#b)(%([BSUbsu]|{*%})|(%[^BSUbsu{}]))/$match[3]} what do you think? -- Stéphane