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 18363 invoked from network); 14 Apr 2021 15:18:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Apr 2021 15:18:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1618413523; b=OXLgXjq2m03GnPFd5di5dNz/VqHerif3XCe+XlIQIdhh4l0dkwB5Kx2uF/VSjYYHTCMCvldnCK v+3gNYUs4lzQRRAeePE3WcfRRoz49uSyH7qHB+6Kzlmq6kZBqGe/k1W/SSK0fWMhozc9HqZb3D Im4FBEoQy9mNHNhqKHv0hdMQpr7lJ4HlIDF+tzRGHsNoQ610fDa1h1XqUODM8+8kayWi2MW/4w 1jajPY2AjIMI1Bd0my5SyIW/QZeuvH15jVrRUG0QFC8GBlAoscY6kaf2AB5IozNLjLo1SugVem Btd9yScM+3Ytatjadzzr3I4cXdalCr0varum0BENDmmnSQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout5-smtp.messagingengine.com) smtp.remote-ip=64.147.123.21; 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=1618413523; bh=TnV6w2eQMr0C1C/0+Nmuj+FkWF1lz2BPDnus3QIzpMA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:DKIM-Signature:DKIM-Signature:DKIM-Signature; b=aY/8xDenZEXzUD8loNKp2AY8fPMBRYuWSsCdoW5Mg0q5UDN3h3MQnQDyiV2NuyGZzkVvoqnBtu /m3Agic85+ISdq3EF/tSFCgPsyfgORYH+rO3mSv/dHrBWowZO1XB50AZ93swK8ZdcXXWABZNKV flPZ1+fIzGx7R3e6Y9QG51NCkf+UYKDCXjwemWKbJATKjDcsYL6t0D1IEdn4N45TusNhBE3ynt tGO5CggDwBaBQpgSpFL/ENAAA4eTlLSN8Zn8oNlU8h1ZFrZeble/XP9Wk3kIZx1aszTNpoZNNy 1+F0zaVMwyySCHZAa8uFNMWI02y/t/2jKvnAmLXrki+rjw==; 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:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=6h2WAv69Pz4JUv2dSD3zpQ+KdWquR9RxZGbn9htrDBg=; b=pFEegQtCp10z1vV3tL2R7DMHDE oP5hMqfyuMwQvSqmx03rvSXUE+49rapH/jqVG5OrbOCqLlZE2KfbRpBugK+JA4oQ20tGOkQyIm16B D4+rQhkvlYNrloj8lj4K5SBQWjGzlSbziJAxnm6YLT3oPLBdoyU/7UxvntBoIkj8tKHGlX15tLAiG 4punvfiP3quSicsneuTbVGNapB73si+72WV5LAbfBAtBT72JIyQVVHdLJ2Thd5XUge1oeeLWZXbUF VcYj6Aw+PFpoREj+5h5x57A6jSRCXRc/KzV2NSJVx2sxyZPlCW6LTnxdQO9midRTupHbj6fCwZSC9 6J0uKNQQ==; Received: from authenticated user by zero.zsh.org with local id 1lWhHv-0008Zy-4s; Wed, 14 Apr 2021 15:18:43 +0000 Authentication-Results: zsh.org; iprev=pass (wout5-smtp.messagingengine.com) smtp.remote-ip=64.147.123.21; 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 wout5-smtp.messagingengine.com ([64.147.123.21]:37765) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lWhHd-0008Lh-Vq; Wed, 14 Apr 2021 15:18:27 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 6AF5219F9; Wed, 14 Apr 2021 11:18:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 14 Apr 2021 11:18:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=fm3; bh=6h2WAv69Pz4JUv 2dSD3zpQ+KdWquR9RxZGbn9htrDBg=; b=um5b5PtjcHardqameKZw50FtHHTUUJ Z+i64fH5Vlil+se3JBE0mjjD8Oce0/z8pky4U3vV3RFSb8GFrSATGHOvaDb55qL1 6iVrMnnAHcdYSdM4ZSD1ztZ7VSAR+2C46H0OQF64ak+8RoxpqH8DSgUHF56jfKOa SRRpCZ9bcBMSxhy6Inc/Rq8ojnNld7c9CcGE2LaOeiDXS1AyVhBCFc8wOEVKRUnS EwmMb87r3JMoRfYewH/VRkbaEiL/pQtheXKIAkjwrJG3KTk0+pW8IVmLQeaYklLU AHoYtQutDkmg0r1vK/X+gQlij+mGOWrttMqZQevvUTe3vmoDu6wvhsOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=6h2WAv 69Pz4JUv2dSD3zpQ+KdWquR9RxZGbn9htrDBg=; b=bJo+LZ5uGglXUKIxJNXijl 6u3AWjmnYXqHIw4LbxpaC7CO64f60Iq7ksyuXCmHl+cRV/UnzKEarInDMwRqYRD1 RQLLZvKmwcuOf5uY6cP7UN/pC+r80gLBAMi7aPYq2e6wy4MlJRDakowJssS/trRI XRtWAwoscFWisL3OV2DJr2wJ+lEr0yw6LiCIcI4r/2zlKovaR4qXQ9HeCKXMBh8l lg39fZ6ss7/tClCwWauTQTD8ewF1kNPVmYtd2UtskSjDfUcsqeM/3pcIdxS6jIYc WUUFjWsi5TaW/REJxC+/zDGJX7RPl9NnrnzxmUUSMFV/ELW52gCpA6H+qB/VmKjg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeluddgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujggfsehmtd dtredtredvnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeduhefhieegkeduue eiieffieeutdegjeekueevuefhveeuuefgieehhfeivddutdenucfkphepuddtledrieei rdeifedrvdeftdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-109-66-63-230.red.bezeqint.net [109.66.63.230]) by mail.messagingengine.com (Postfix) with ESMTPA id 987011080063 for ; Wed, 14 Apr 2021 11:18:23 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4FL5hZ0Tkmz43s; Wed, 14 Apr 2021 15:18:22 +0000 (UTC) Date: Wed, 14 Apr 2021 15:18:22 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: docs patches for precmd hooks and $?, and vcs_info Message-ID: <20210414151822.GI3882@tarpaulin.shahaf.local2> References: <7E71FA83-356E-448B-9726-02DF3FF5BD14@gmail.com> <873D08A9-F321-474A-8440-CCE7DCCBA529@gmail.com> <20210414120551.GA3882@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HcAYCG3uE/tztfnV" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48574 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: --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Bart Schaefer wrote on Wed, Apr 14, 2021 at 07:00:32 -0700: > On Wed, Apr 14, 2021 at 5:06 AM Daniel Shahaf > wrote: > > > > > > +prompt_newuser_precmd() { > > > + local exitstatus=$? > > > > It's not documented that precmd hooks can rely on $? to be the exit code > > of the last command. That does work, though (because callhookfunc() > > calls doshfunc(noreturnval=1)), and seems useful, and I guess we won't > > want to change it, so shall we document it? > > > It's intentional and as far as I recall has always been assumed, so ... yes. Done. Attached as 4/8. Also did a few other things while I was in the area, and things that I noticed while auditing for other instances of the bugs fixed by the the former things. Split to rather small pieces, but in exchange, the log messages are informative. (Also, I do review my own patches to the same standard as others'.) Cheers, Daniel --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-docs-Minor-markup-tweak.patch.txt" >From ef53ae6286714123845ce80b5b8c2d1c8b7ce37c Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 14:12:25 +0000 Subject: [PATCH 1/8] docs: Minor markup tweak --- Doc/Zsh/func.yo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Zsh/func.yo b/Doc/Zsh/func.yo index d500a78ae..0944380b9 100644 --- a/Doc/Zsh/func.yo +++ b/Doc/Zsh/func.yo @@ -212,7 +212,7 @@ example, if tt($chpwd_functions) is an array containing the values execute the functions `tt(chpwd)', `tt(mychpwd)' and `tt(chpwd_save_dirstack)', in that order. Any function that does not exist is silently ignored. A function found by this mechanism is referred to -elsewhere as a `hook function'. An error in any function causes subsequent +elsewhere as a em(hook function). An error in any function causes subsequent functions not to be run. Note further that an error in a tt(precmd) hook causes an immediately following tt(periodic) function not to run (though it may run at the next opportunity). --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0002-docs-Fix-example-rendering-in-the-man-page-outpu.patch.txt" >From 4017180dcd861fed2e054de946d7612b13249dde Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 14:20:23 +0000 Subject: [PATCH 2/8] docs: Fix example rendering in the man page output The texi output was unaffected. However, in the man page on my system, everything after the example() was underlined and not indented. --- Doc/Zsh/contrib.yo | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 586ac06f5..55ea06f34 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2028,7 +2028,9 @@ disabled. item(Declare cleanup)( If your function makes any other changes that should be undone when the theme is disabled, your setup function may call + example(prompt_cleanup var(command)) + where var(command) should be suitably quoted. If your theme is ever disabled or replaced by another, var(command) is executed with tt(eval). You may declare more than one such cleanup hook. --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0003-docs-Fix-rendering-in-the-man-page-output.patch.txt" >From 49f9bb8ebe2a5ad0fc463930c6c8cf76a8eac8f9 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 14:23:58 +0000 Subject: [PATCH 3/8] docs: Fix rendering in the man page output In the man page output, the text was underlined from the var() to the end of the paragraph. The texi output in affected. For instance, the text `name' in TeX is now slanted Roman (\slshape\rmfamily) rather than slanted teletype (\slshape\ttfamily). --- Doc/Zsh/contrib.yo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 55ea06f34..5e91f9a8d 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2036,13 +2036,13 @@ disabled or replaced by another, var(command) is executed with tt(eval). You may declare more than one such cleanup hook. ) item(Define preview)( -Define or autoload a function tt(prompt_var(name)_preview) to display +Define or autoload a function tt(prompt_)var(name)tt(_preview) to display a simulated version of your prompt. A simple default previewer is defined by tt(promptinit) for themes that do not define their own. This preview function is called by `tt(prompt -p)'. ) item(Provide help)( -Define or autoload a function tt(prompt_var(name)_help) to display +Define or autoload a function tt(prompt_)var(name)tt(_help) to display documentation or help text for your theme. This help function is called by `tt(prompt -h)'. ) --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0004-docs-Document-that-hook-functions-may-rely-on-se.patch.txt" >From 20a22e5a4d7cd881c88554f87e571e1607612b28 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 14:27:10 +0000 Subject: [PATCH 4/8] docs: Document that hook functions may rely on $? (see workers/48570). --- Doc/Zsh/func.yo | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/Zsh/func.yo b/Doc/Zsh/func.yo index 0944380b9..7edad7f23 100644 --- a/Doc/Zsh/func.yo +++ b/Doc/Zsh/func.yo @@ -206,7 +206,8 @@ findex(hook functions) For the functions below, it is possible to define an array that has the same name as the function with `tt(_functions)' appended. Any element in such an array is taken as the name of a function to execute; it is executed -in the same context and with the same arguments as the basic function. For +in the same context and with the same arguments and same initial value of tt($?) +as the basic function. For example, if tt($chpwd_functions) is an array containing the values `tt(mychpwd)', `tt(chpwd_save_dirstack)', then the shell attempts to execute the functions `tt(chpwd)', `tt(mychpwd)' and --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0005-vcs_info-docs-Recommend-use-of-prompt-expandos-r.patch.txt" >From 0057f30bf04f8d0f5e855846805ca261a3c6c4a7 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 14:49:13 +0000 Subject: [PATCH 5/8] vcs_info docs: Recommend use of prompt expandos rather than terminal escape sequences. --- Doc/Zsh/contrib.yo | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 5e91f9a8d..07bf4e054 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1826,10 +1826,22 @@ example(zstyle ':vcs_info:bzr:*' use-simple true) If you do use tt(use-simple), please report if it does `the-right-thing[tm]'. Display the revision number in yellow for tt(bzr) and tt(svn): +example(zstyle ':vcs_info:(svn|bzr):*' \ + branchformat '%b%%F{yellow}:%r') + +The doubled percent sign is explained in +ifzman(the bf(Oddities) section)ifnzman(noderef(vcs_info Oddities)). + +Alternatively, one can use the raw colour codes directly: + example(zstyle ':vcs_info:(svn|bzr):*' \ branchformat '%b%{'${fg[yellow]}'%}:%r') -If you want colors, make sure you enclose the color codes in tt(%{)var(...)tt(%}) +Normally when a variable is interpolated into a format string, the variable +needs to be tt(%)-escaped. In this example we skipped that because we assume +the value of tt(${fg[yellow]}) doesn't contain any tt(%) signs. + +Make sure you enclose the color codes in tt(%{)var(...)tt(%}) if you want to use the string provided by tt(vcs_info) in prompts. Here is how to print the VCS information as a command (not in a prompt): --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0006-vcs_info-docs-Change-user-context-name-in-an-exa.patch.txt" >From 53a5e2b920e16d398e7869aaeb7077ebad049b9f Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 14:50:34 +0000 Subject: [PATCH 6/8] vcs_info docs: Change user-context name in an example, to avoid confusion with the special-casing of the value `command' in vcs_info_lastmsg. --- Doc/Zsh/contrib.yo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 07bf4e054..ef992bdeb 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1845,10 +1845,10 @@ Make sure you enclose the color codes in tt(%{)var(...)tt(%}) if you want to use the string provided by tt(vcs_info) in prompts. Here is how to print the VCS information as a command (not in a prompt): -example(alias vcsi='vcs_info command; vcs_info_lastmsg') +example(alias vcsi='vcs_info interactive; vcs_info_lastmsg') This way, you can even define different formats for output via -tt(vcs_info_lastmsg) in the 'tt(:vcs_info:*:command:*)' namespace. +tt(vcs_info_lastmsg) in the 'tt(:vcs_info:*:interactive:*)' namespace. Now as promised, some code that uses hooks: say, you'd like to replace the string `svn' by `subversion' in --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0007-vcs_info-docs-vcs_info_lastmsg-Correct-an-ambigu.patch.txt" >From 22b629e8a2cfe237ed6ec2fddfa8826d67ea6f93 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 15:10:03 +0000 Subject: [PATCH 7/8] vcs_info docs: vcs_info_lastmsg: Correct an ambiguous/wrong description. --- Doc/Zsh/contrib.yo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index ef992bdeb..5fe5601a7 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1510,7 +1510,7 @@ below for details. ) findex(vcs_info_lastmsg) item(tt(vcs_info_lastmsg))( -Outputs the last tt(${vcs_info_msg_*_}) value. +Outputs the current values of tt(${vcs_info_msg_*_}). Takes into account the value of the tt(use-prompt-escapes) style in tt(':vcs_info:formats:command:-all-'). It also only prints tt(max-exports) values. --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0008-vcs_info-git-Use-best-practices-in-an-example.patch.txt" >From 41f058912791b55b18de5e71f3426c3af1a5be8c Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 15:11:01 +0000 Subject: [PATCH 8/8] vcs_info git: Use best practices in an example The alias was vulnerable to SHORT_LOOPS syntax, not invokable from scripts, etc.. --- Doc/Zsh/contrib.yo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 5fe5601a7..3c4fdded0 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1845,7 +1845,7 @@ Make sure you enclose the color codes in tt(%{)var(...)tt(%}) if you want to use the string provided by tt(vcs_info) in prompts. Here is how to print the VCS information as a command (not in a prompt): -example(alias vcsi='vcs_info interactive; vcs_info_lastmsg') +example(vcsi+LPAR()+RPAR() { vcs_info interactive; vcs_info_lastmsg }) This way, you can even define different formats for output via tt(vcs_info_lastmsg) in the 'tt(:vcs_info:*:interactive:*)' namespace. --HcAYCG3uE/tztfnV--