From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20315 invoked from network); 7 Apr 2021 20:23:22 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Apr 2021 20:23:22 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617827002; b=Rdcs862EuZO1NWSxH2zBaotEAUMp24xu1XK8iSs0h6VlEyUmLm5qrYwVNA4ZaBUg+NTzHW8Q3q lKbK3N8nXL1Uj56tcXpna+lrG/GLjzC1ypoVfND3vrfXWHmwqjoykpPVpA9FWTK15f9S4ZMNA0 VtrPms5sPKcYmN86+tXVXxJmWBv+MJAa86ibF3kskyFCW/rgja/IowRNyOwgj1XEhpI0ReNdZh t6UZ2i9Dx2rfKav3bjvNgKaua8dnWn/RoHt7YHojN48fL7Cp53sNkkTAMa0K4yVsOpzG4B76X9 lpI1+00Bsm3boWrdYDch3lB2Kaa+2qI12RGXtJzend7ISQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out5-smtp.messagingengine.com) smtp.remote-ip=66.111.4.29; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1617827002; bh=2/ZeROdyPAs78pZhWhYuUl6noNo758DY0JwmJS+0pFQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Date:Subject:To:From:DKIM-Signature:DKIM-Signature: DKIM-Signature; b=VIUb13W8SDK6SoGLwikkfOEhGEt2j3+DQYc1EkIYvrpgbHj9WvtQ3nK10nm6h0z6dxppvvAfHJ yry6U9oM8QhPmEUJ/YWYLSz3EGJAUCUiTrfN5xIpb0ilZiFdQk1PGRK/X5fXwKY3ECExQroKHC o4C+wwDScMx1wnDFRWLtYL4lxboRQDHYNJ9By5djB3aKoQ2IKvP9KAtjLH9ZW9K0oi+Z2LJynr PBUuMHLZ6uln5COJahcRqs7tD0hEMUiOoYpk5C6XzdSdqErUAfhEzwtzN1jZj+1YoQO+qG2Xbe 7xOY3K3XI4IciBZFJoLjULRhU6IRO1BBukGjOZ7L+4eq7Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:To:From:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=TYfZOsnxTF3MraNdfYpVBqUNAliMWqh+c/XkMsXPlIY=; b=atJJ7LwCPxeyINU3x86IoDN/TN ry1M6u8DUiAwlBztmN2Vo5eX1hOOAWPwOEnS4ooXKiH9+wqcF0G/dZ62vEeLhSv2Iib4IUm4MSTk8 VwF50fIGNwPoIwus+i31Hk7lo48I+ZkBaapqERfIPlGYg5d6NFknkXmjxHauUg/43crY8rKz4m+i4 0Dzgvx3mjbGFCTwTxuRrhLrKguAjQcsBOhnoTIsh5ONUCs3uDIRSD7Z32+Vbqe5vTo9xIZ9hjtBXb tx11l+N0Kh1IpcWzUerF+5SBpT3TSZMWNdLVMfm36YlXuVHn08ieqr09OdKt0LBav7vMOpVT6tpno xYFpPpvQ==; Received: from authenticated user by zero.zsh.org with local id 1lUEht-000JEa-LY; Wed, 07 Apr 2021 20:23:21 +0000 Authentication-Results: zsh.org; iprev=pass (out5-smtp.messagingengine.com) smtp.remote-ip=66.111.4.29; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out5-smtp.messagingengine.com ([66.111.4.29]:46401) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lUEhh-000Iyd-3F; Wed, 07 Apr 2021 20:23:10 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id DB4455C00B1; Wed, 7 Apr 2021 16:23:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 07 Apr 2021 16:23:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=from:to:subject:date:message-id :mime-version:content-type:content-transfer-encoding; s=fm3; bh= TYfZOsnxTF3MraNdfYpVBqUNAliMWqh+c/XkMsXPlIY=; b=yOo2uCvmb81fB8fE ChsdTJq42BYSIY2MkgSBwSYYUrqBnUXV1S1Dox3zZvsY+hf51T7oUiFgjQHfDaaI Tqp8DOcTroCGGPjjrxG9z5/ujPT9stfLjVaNPYRYw/CdblB7lMzvXtKWZcbnEiWQ yezp/y45qcSB43BnYUBohZU4Lac/Egt2pVQnJXpmZhQEXZF8jbHYFpJT9cBysHry fWevzyB6QC7c7DWIy2h2u6qhqOFoOYW7z50oLfVVeD7d/+kTFUcDpb3uDhh41z3W rwg0I02zrv0lK+//0VI5bTfzkm1745A/DxSK/vOM3wrCEeNr8Bp7cfbqGRN5QoLb G+6STA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=TYfZOs nxTF3MraNdfYpVBqUNAliMWqh+c/XkMsXPlIY=; b=daVG7O4OLOwAgnjV1JYvmF YxUtJNI6XvhNzJtITU3aekJc7pl1/sfXwvccXAmjy7v5ZDmMMhwH0XCNTcudaQLf xkAUGPlGGhhh9GsfE7pZECnQVYKkPWeH22YVQQUkJHQRQO/i2Gisc3FPCDEnlmRV SkiiLKorBPmIxSgou/Q2I5Y+MPD+OE1jttanrn7ycQ84FgG+GHFdJlSAMjuEBVaf 2zocvWOGBUwl2uNHvdFflMbdZFnW8d74p712AXI7ytt/PIv5xghLlLCf7UzMPkxp IZcgMkl8pRASb7gOl6HoxFIYo33O3+j5MGe/E7FVlVd4pSE/8Vjo9XF27/UUANrQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejjedgudehtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffogggtgfesthektd dtredtjeenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgv lhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepfffgtedtgedtiedtte dvjeekleeiteethfejgffgiedvgfevfeeutdejvedtteevnecukfhppeejledrudekvddr feeirddukedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-182-36-181.red.bezeqint.net [79.182.36.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 04BE8240054 for ; Wed, 7 Apr 2021 16:23:07 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4FFwnP3C0gzX1; Wed, 7 Apr 2021 20:23:05 +0000 (UTC) From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] vcs_info docs: applied-string/unapplied-string: Correct an omission in the documentation and add an example. Date: Wed, 7 Apr 2021 20:22:58 +0000 Message-Id: <20210407202257.4525-1-danielsh@tarpaulin.shahaf.local2> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Seq: 48435 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: The example code is a reduced version of my function from workers/47519, with one bug fixed. (In workers/47519, if $1 doesn't contain spacesĀ - which is the case under hg mq - then $H and $s will be set to the same value.) --- Doc/Zsh/contrib.yo | 13 ++++++++--- Misc/vcs_info-examples | 51 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 586ac06f5..4c7443ffc 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1652,10 +1652,15 @@ Called in the tt(git) (with tt(stgit) or during rebase or merge), and tt(hg) is generated; the tt(use-quilt) zstyle must be true for tt(quilt) (the tt(mq) and tt(stgit) backends are active by default). -This hook gets the names of all applied patches which tt(vcs_info) collected -so far in the opposite order, which means that the first argument is the +The arguments to this hook describe applied patches +in the opposite order, which means that the first argument is the top-most patch and so forth. +When the patches' log messages can be extracted, those are embedded +within each argument after a space, so each argument is of the form +`var(patch-name) var(first line of the log message)', where var(patch-name) +contains no whitespace. + When setting tt(ret) to non-zero, the string in tt(${hook_com[applied-string]}) will be available as tt(%p) in the tt(patch-format) and tt(nopatch-format) styles. @@ -1669,9 +1674,11 @@ tt(mq)) backend and in tt(quilt) support when the tt(unapplied-string) is generated; the tt(get-unapplied) style must be true. This hook gets the names of all unapplied patches which tt(vcs_info) -collected so far in order, which means that the first argument is +in order, which means that the first argument is the patch next-in-line to be applied and so forth. +The format of each argument is as for tt(gen-applied-string), above. + When setting tt(ret) to non-zero, the string in tt(${hook_com[unapplied-string]}) will be available as tt(%u) in the tt(patch-format) and tt(nopatch-format) styles. diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index 94b8a7b5e..36b6fbc51 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -282,6 +282,54 @@ function +vi-hg-branchhead() { } +### Show information about patch series +# This is used with with hg mq, quilt, and git rebases and conflicts. +# +# All these cases have a notion of a "series of patches/commits" that is being +# applied. The following shows the information about the most recent patch to +# have been applied: +zstyle ':vcs_info:*+gen-applied-string:*' hooks gen-applied-string +function +vi-gen-applied-string() { + # Separate the patch id from the patch log message. + if [[ $1 == *\ * ]]; then + local patch_name_or_filename="${1%% *}" + local patch_description="${1#* }" + else + local patch_name_or_filename="$1" + local patch_description="" + fi + + # Apply escaping; see `Oddities' in the manual. + patch_name_or_filename=${patch_name_or_filename//'%'/%%} + patch_description=${patch_description//'%'/%%} + + # Apply different colouring to the patch description. + if [[ -n ${patch_description} ]]; then + patch_description="%F{yellow}${patch_description}%f" + fi + + # Re-assemble $1, escaped and coloured. + hook_com[applied-string]="${patch_name_or_filename} ${patch_description}" + ret=1 +} +# The value of hook_com[applied-string] is incorporated into the %m expando +# (see the 'patch-format' style for details), which is not included in the +# 'formats' and 'actionformats' style by default, so to actually use this, +# you'll need to add %m (or %Q under quilt in add-on mode) to your 'formats' +# and 'actionformats' styles, as in: +# +# zstyle ':vcs_info:*' actionformats ' (%s)-[%b|%a]%u%c- %m' +# zstyle ':vcs_info:*' formats ' (%s)-[%b]%u%c- %m' +# +# Or you could add it as a new word, as in: +# +# zstyle ':vcs_info:*' actionformats ' (%s)-[%b|%a]%u%c-' '%m' +# zstyle ':vcs_info:*' formats ' (%s)-[%b]%u%c-' '%m' +# +# In the latter case, you will need to arrange to print ${vcs_info_msg_1_} in +# addition to ${vcs_info_msg_0_}; see the top of this file for details. + + ### Run vcs_info selectively to increase speed in large repos ################ # The following example shows a possible setup for vcs_info which displays @@ -544,6 +592,9 @@ function +vi-set-quilt-patches() { # This would take care of all the dedicated-patches-directory-in-${HOME} # from earlier examples, too. +# Finally, the "Show information about patch series" example above this section +# may also be useful. + ### Using vcs_info from CVS ##################################################