From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9034 invoked by alias); 20 Mar 2011 10:49:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28931 Received: (qmail 11827 invoked from network); 20 Mar 2011 10:49:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at bewatermyfriend.org does not designate permitted sender hosts) From: Frank Terbeck To: Johan =?utf-8?Q?Sundstr=C3=B6m?= Cc: zsh-workers@zsh.org Subject: Re: PATCH: git --pretty completion, and (new) completion for npm In-Reply-To: ("Johan =?utf-8?Q?Sundstr=C3=B6m=22's?= message of "Sun, 13 Mar 2011 23:38:34 -0700") References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Date: Sun, 20 Mar 2011 11:35:25 +0100 Message-ID: <871v22krki.fsf@ft.bewatermyfriend.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Df-Sender: 430444 Johan Sundstr=C3=B6m wrote: [...] > I took to adding documented completion for to the=C2=A0git completer for = syntax that > is impossible to remember and hard to find in the man page; git log --pre= tty > (and whichever other commands support --pretty / --format) now covers the= whole > lot except %w, which seemed like it would need a whole little state machi= ne in > itself. Hm. This only works for stuff directly after the `=3D', doesn't it? As in: % git log -1 --pretty=3D% But not in: % git log -1 --pretty=3D"%H % That would be pretty useful, don't you think?=20 Also, you can cancel out the use of sed(1) from the code: diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index d65362e..ef4f263 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5550,8 +5550,7 @@ __git_setup_pretty_aliases () { aliases=3D() for spec in $(git config --get-regexp '^pretty\.' 2>/dev/null); do name=3D"${${spec#pretty.}/ */}" - pfmt=3D"${spec#pretty.$name }" - pfmt=3D"$(sed 's_\([]:["]\)_\\\1_g' <<<"$pfmt")" # escapes ], :, [, an= d " + pfmt=3D"${${spec#pretty.$name }//(#b)([]:[\"])/\\\\${match[1]}}" aliases+=3D(${name}'\:"git config alias for\: '${pfmt}'"') done pretty_aliases=3D"${(pj:\n:)aliases}" ...which would save a fork(). Regards, Frank PS: I've just committed the _npm completion from the message I'm replying to. --=20 In protocol design, perfection has been reached not when there is nothing left to add, but when there is nothing left to take away. -- RFC 1925