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=-2.2 required=5.0 tests=DKIM_ADSP_ALL,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1742 invoked from network); 22 Feb 2021 22:25:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Feb 2021 22:25:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614032702; b=0RhcnptVfpTsnsVmgr363IdmfIqGPeIzfPaMEOW8LJNVbTfXMEIwKIeunzPtRFcSo7OAzJT8It zkfK2rXla1gQtVhUdBfHpwaoEe5ivcgXq+LAqYE6TOr6+u9K2nlfrgIIoG2FI7EmNag5koO7cD LctOHzBwyGqfuDSuX6WcBR9qLSJYskaL/Liff/Gv0OwXUxc6JQp7BAF178SiNLhIxpJ4/7OZda swB9d1x7fkWUZ6FyhHT/7mPrKp3GbVr8p57c3v2hqTINttWGMSKR9XgM1kTpqS9C/fBVJpvTru RxlQcv/8BhcozUIGJbSi7K46qZrdUc67d3winufFTCp3Wg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail.cs.msu.ru) smtp.remote-ip=188.44.42.39; dkim=pass header.d=cs.msu.ru header.s=dkim header.a=rsa-sha256; dmarc=pass header.from=cs.msu.ru; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1614032702; bh=y68iYoKK9FtV9NYgL18Fu4K7E/T5W6dOFiJHJdS7Nrs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Subject:In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Cc:To:From:Date:DKIM-Signature:DKIM-Signature; b=rx+2Fj3vOSkgbEQkdUJSBnxON6QgV3QtUO++xzWgm+WLLLLr1wmDiOdkvtrXrvgeZ2VHmzrUQZ usp+XYdAC9efN7rs4s/ft9SlIzREu0tSvuZ7hYDPg1Gq179dLMwLWXYJzE8hviZSrtc+5uqroF 2fnblNyegGEd5ASkrSQyT2+HUPoOj86E/bX3oOS0jii4uzV4XX6fW76KDOsGcukQd7oF8fRsrF O+nr2mHmt/IX6wShEFG2+05Je0YgE3S5OIYe3h17X3JGeMBk1AHkUbKOrwRttBsT/t5dpTPYYH cHYgk29a8wjQXfNzugfovEGtQcDHJk2jxVVVc8Sci/CcCw==; 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:Subject:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=6ONeZHaMMXaCbzS9irMi8A4g9WeAJX47G+EkR4/CqF8=; b=J4hEGmoagHdTrmqUXfCD6PRXqw RILF2jvwRq7koDhTwLjzXEbLb5NwnMUpaz9JfEUK7cTdoa8BC7o5GSG/9SszGNRJhfWJoiBPHATXf X0z4ggNDYhQejffwaUMm6hJ75sJDUrDZSFIQQ0tNZc7Nwk335gYIYqVClLvQ3wWwZ5lT1vxgpUtq0 wawWMhZztKyxCS72NTnn5E3rdyVF2deU3msU5Wqa5ptpEZpN44PN1lQXlN5h6WV2+qDAa0ycC2SW4 Fo7F8ksJeFkqhIAy9uPRN2BpcVfUu89l/ELkTidgWsCbAtgzqPjGf5uIO8i4sLxzTfY/P6PAQQ/qd JrWnFJpQ==; Received: from authenticated user by zero.zsh.org with local id 1lEJdQ-000IRI-HQ; Mon, 22 Feb 2021 22:24:56 +0000 Authentication-Results: zsh.org; iprev=pass (mail.cs.msu.ru) smtp.remote-ip=188.44.42.39; dkim=pass header.d=cs.msu.ru header.s=dkim header.a=rsa-sha256; dmarc=pass header.from=cs.msu.ru; arc=none Received: from mail.cs.msu.ru ([188.44.42.39]:48445) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lEJd6-000II3-Mw; Mon, 22 Feb 2021 22:24:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cs.msu.ru; s=dkim; h=Subject:In-Reply-To:Content-Type:MIME-Version:References:Message-ID :Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6ONeZHaMMXaCbzS9irMi8A4g9WeAJX47G+EkR4/CqF8=; b=fvyNaUqZjYZeDlD1/If/euY/a3 P2ePx3/CK3r5aigRpbpbSlWsZ/qV2weShS+DczYWaamaiGnI6vmnJ3u+2BgoetQ8FLfKCXO8o5DcA 5Lw13XAhQX0aDY8GowR6wQ+cWW5+zO5lS0Gud86c6RAfYM3yiyYe3MTXwEFl29D6mK6Zl/BTNkyZh 9dUkeL2VcuEnzho/VeaeVXLssE+zHhDk29xg116rZgzLSw4B9z4PxeAkvuX548eZTi1d7sCE2SyVr 6EKOEPjiw0SEhFz0oFPLrrgm+7HAUmMoYjGvFAv3jgnOODtFRPFHdoNuZhvKrq8s2507CxYK+c8r4 lV1YzXNg==; Received: from [37.204.119.143] (port=33738 helo=cello) by mail.cs.msu.ru with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lEJd4-0001Qg-KT; Tue, 23 Feb 2021 01:24:34 +0300 Date: Tue, 23 Feb 2021 01:24:27 +0300 From: Arseny Maslennikov To: Bart Schaefer Cc: "zsh-workers@zsh.org" Message-ID: References: <20210125081625.3193714-1-ar@cs.msu.ru> <20210125081625.3193714-2-ar@cs.msu.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ecE8i+wVNonD/RWK" Content-Disposition: inline In-Reply-To: OpenPGP: url=http://grep.cs.msu.ru/~ar/pgp-key.asc X-SA-Exim-Connect-IP: 37.204.119.143 X-SA-Exim-Mail-From: ar@cs.msu.ru Subject: Re: [PATCH 2/2] promptinit: Fix prompt cleanups X-SA-Exim-Version: 4.2.1 X-SA-Exim-Scanned: Yes (on mail.cs.msu.ru) X-Seq: 48093 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: Archived-At: --ecE8i+wVNonD/RWK Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 22, 2021 at 10:29:52AM -0800, Bart Schaefer wrote: > On Mon, Jan 25, 2021 at 12:17 AM Arseny Maslennikov wrote: > > > > The promptinit framework fails to apply cleanup commands of the current > > theme on any theme change other than "prompt restore", as well as when > > invoking setup functions of a certain $theme as an implementation detail > > of `prompt -[hp] $theme'. >=20 > Thanks, I did have a chance to look at this. >=20 > > We fix it in the following way, hopefully without breaking compatibilit= y: > > * Rename zstyle `cleanup' on the context `:prompt-theme' to `restore' > > everywhere but in prompt_cleanup(). It is only used as a restore > > mechanism now. > > * Ensure prompt_cleanup() continues to store its command list in the > > `cleanup' style. > > * Clean up before theme switch at the end of set_prompt(). >=20 > These all seem fine, conceptually. >=20 > > * Prepend every use of prompt_*_setup (which might modify the shell > > state in ways that require cleanup) with a cleanup run. >=20 > Have you confirmed that this is a no-op when there has not been a > previous installation of a theme? I double-checked right now; in that case, with the patch applied as posted, it is a no-op when the command 'prompt -p' is invoked, but not when 'prompt -h' is =E2=80=94 the trap does not run. Thanks for the good ca= tch! The following diff on top of my patch fixes it: --->8--- diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit index ab2b50857..5c7dcc5a1 100644 --- a/Functions/Prompts/promptinit +++ b/Functions/Prompts/promptinit @@ -105,9 +105,11 @@ Use prompt -h for help on specific themes.' local +h PS1=3D$PS1 PS2=3D$PS2 PS3=3D$PS3 PS4=3D$PS4 RPS1=3D$RPS1 = RPS2=3D$RPS2 local +h PROMPT=3D$PROMPT RPROMPT=3D$RPROMPT RPROMPT2=3D$RPROMPT2 = PSVAR=3D$PSVAR local -a precmd_functions preexec_functions + local theme_reset=3D'' else - trap 'zstyle -t :prompt-theme cleanup; prompt_${prompt_theme[1]}_s= etup "${(@)prompt_theme[2,-1]}"' 0 + local theme_reset=3D'prompt_${prompt_theme[1]}_setup "${(@)prompt_= theme[2,-1]}"' fi + trap 'zstyle -t :prompt-theme cleanup;'"${theme_reset:+ $theme_reset= }" 0 ;; esac case "$opt" in -------- >=20 > > * Adjust `prompt restore' to do both parts of the newly split restore > > mechanism, cleanup first. >=20 > Also fine. Just a couple of nit-picky things about the diff itself: >=20 > > diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit > > index 5e42ebdd3..1c6d27ad7 100644 > > --- a/Functions/Prompts/promptinit > > +++ b/Functions/Prompts/promptinit > > @@ -123,6 +125,7 @@ Use prompt -h for help on specific themes.' > > # The next line is a bit ugly. It (perhaps unnecessarily) > > # runs the prompt theme setup function to ensure that if > > # the theme has a _help function that it's been autoloaded. > > + zstyle -t :prompt-theme cleanup > > prompt_$2_setup > > fi > > if functions prompt_$2_help >/dev/null; then >=20 > Placement of the added zstyle call makes the comment incorrect, move > it above the comment? Will do. >=20 > > @@ -179,28 +182,41 @@ Use prompt -h for help on specific themes= =2E' > > + # Will add the hook this time. > > + prompt_cleanup "$@" >=20 > This is logically correct, but I don't think it adds much in terms of > maintainability to make this a recursive call; there are only 2 > commands executed in that event. Ok; I'll have to refactor this again. :) --ecE8i+wVNonD/RWK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE56JD3UKTLEu/ddrm9dQjyAYL01AFAmA0LxQACgkQ9dQjyAYL 01CeVg/+Na+h4T9jUw4OfGZLNsHSxY+Eh1eyZFBTIP828iRJ8oxJg9smaqml1+fh hxIZSjqKxtrmhU7y+ekxIGqMm3pXQO4T2Av5tNpKDNlknHr7mzM8inW6/74IXzOF 5d8QvUpEBihICHWOhgi9jFhnZRskOjL65rhpDGjp3yWwNieCgFOV1ZTIFDHO96Zz mtjSyyx+NC5s08kar6KkWSwQoSQdnV+F9l3Vt97O2UyewubITdFUiZu+hI24MFCB PIaJ+fJZTdf5eqxqjgSOLc0MT1DrlXmUF0RqBkmc12aso71C6HBilWUny6OXcJhU /w4VJXNKb09ANRDpPOsmFAR8ifiHyCQASdmsA6TJdmrMV262ADOFjM0eG/1lkgsU boVTH//ixDRQh91xQDa3aOOrBoPfLKJspNTt7cNYYs2RT2fkYWh2JJUM+gTXSyAD j9uPhBTH+KIWSSY3/0esATZiziJ7+hGLw7XyQos2IydHNqlpBAtH6b/9PVzFl1Wq 2DcYj24w/4kiIVPI8Jk/KV66UosdzNqZQlKuDkdjooOjP0eruHvchC7itBnE+WRK 9d2r7QJy4V7RTNuCja7lbEaRY4eeOypRe6bW6YfUJiHGEDGWFlv8vWVuA3YokBr1 pNuBPsv1ALER0is+jaEsDRnZ4Lk166dOR+xSPpwIrr9bmmFnpg4= =ik0+ -----END PGP SIGNATURE----- --ecE8i+wVNonD/RWK--