From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19224 invoked by alias); 15 May 2014 18:40:03 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18827 Received: (qmail 11273 invoked from network); 15 May 2014 18:39:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Thu, 15 May 2014 20:39:57 +0200 From: Roman Neuhauser To: zsh-users@zsh.org Subject: Re: ${name/pattern/repl} with negated pattern Message-ID: <20140515183957.GA57920@isis.sigpipe.cz> References: <20140515122641.GI1629@isis.sigpipe.cz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline In-Reply-To: <20140515122641.GI1629@isis.sigpipe.cz> User-Agent: Mutt/1.5.21 (2010-09-15) --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline # neuhauser@sigpipe.cz / 2014-05-15 14:26:41 +0200: > this snippet in zshcontrib(1): > > for i in "$@"; do > if [[ $i == sh/* ]]; then > [[ -n $s ]] && s=$s, > s=${s}$i > fi > done > > can be reduced to [...] please find attached a tiny patch for Doc/Zsh/contrib.yo -- roman --rwEMma7ioTxnRzrJ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-vcs_info-simplify-vi-hgbookmarks-LPAR-RPAR-in-Doc-Zs.patch" >>From 0e40d433f1087367b718d3426eb22aa2fdd921e9 Mon Sep 17 00:00:00 2001 From: Roman Neuhauser Date: Thu, 15 May 2014 20:37:01 +0200 Subject: [PATCH] vcs_info: simplify +vi-hgbookmarks+LPAR()RPAR() in Doc/Zsh/contrib.yo --- Doc/Zsh/contrib.yo | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 9f59f23..efdb436 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1504,22 +1504,15 @@ function +vi-hgbookmarks+LPAR()RPAR() { # This makes the bookmarks string use only those # bookmarks. If there's more than one, it # concatenates them using commas. - local s i # The bookmarks returned by `hg' are available in # the functions positional parameters. - (( $# == 0 )) && return 0 - for i in "$@"; do - if [[ $i == sh/* ]]; then - [[ -n $s ]] && s=$s, - s=${s}$i - fi - done + local s="${(Mj:,:)@:#sh/*}" # Now, the communication with the code that calls # the hook functions is done via the hook_com[] # hash. The key, at which the `gen-hg-bookmark-string' # hook looks at is `hg-bookmark-string'. So: hook_com[hg-bookmark-string]=$s - # And to signal, that we want to use the sting we + # And to signal, that we want to use the string we # just generated, set the special variable `ret' to # something other than the default zero: ret=1 -- 1.9.2 --rwEMma7ioTxnRzrJ--