zsh-users
 help / color / mirror / code / Atom feed
From: Roman Neuhauser <neuhauser@sigpipe.cz>
To: zsh-users@zsh.org
Subject: Re: ${name/pattern/repl} with negated pattern
Date: Thu, 15 May 2014 20:39:57 +0200	[thread overview]
Message-ID: <20140515183957.GA57920@isis.sigpipe.cz> (raw)
In-Reply-To: <20140515122641.GI1629@isis.sigpipe.cz>

[-- Attachment #1: Type: text/plain, Size: 328 bytes --]

# 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

[-- Attachment #2: 0001-vcs_info-simplify-vi-hgbookmarks-LPAR-RPAR-in-Doc-Zs.patch --]
[-- Type: text/x-diff, Size: 1475 bytes --]

>From 0e40d433f1087367b718d3426eb22aa2fdd921e9 Mon Sep 17 00:00:00 2001
From: Roman Neuhauser <rneuhauser@suse.cz>
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


  parent reply	other threads:[~2014-05-15 18:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 12:26 Roman Neuhauser
2014-05-15 15:32 ` Peter Stephenson
2014-05-15 18:18   ` Roman Neuhauser
2014-05-15 15:45 ` Bart Schaefer
2014-05-15 16:37   ` Roman Neuhauser
2014-05-15 17:16     ` Bart Schaefer
2014-05-15 18:39 ` Roman Neuhauser [this message]
2014-05-16  8:40   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140515183957.GA57920@isis.sigpipe.cz \
    --to=neuhauser@sigpipe.cz \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).