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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7567 invoked from network); 22 Feb 2021 18:30:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Feb 2021 18:30:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614018626; b=Xn2fySFNAjj8/7359cIGWtZ+EqicmNq2m0Zueg2GBiwwpEeu7Jtd5cEJ6u90+efPGvdUdAwH4Y b3dFy+YxKL9ncFAMWKmDICu6rEIARDa6+bKiVues5U/b4WUHcmJ59GgmzBsHoCJHLPDPQ+l1tT P5rqfOnU+qfof5ybjIVQJiMZo+syUj5ftuqYjYUpBUL2z7tc9GY/fhWMjCENFmNUYSX0uVNKjO g60C2NP7S7LhqT9UCZTiXRSuYcp3mrTQdrS/3W9hzI4CLOeHWrBwYVgymMQah6WpFI04Fic1/P EO8U+US7Ri8L9vOAwHOt+3Jz+xRi1NEWFK9k20Rayl0EIQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f44.google.com) smtp.remote-ip=209.85.210.44; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1614018626; bh=arL7dzuZLerXb3oEAMSBDcJ8qf9rEJ7iUKIWj9UDYzM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=O3M5l4VYq/Xfkr5jkWF29k72JBUQRMHhRz1QLBs3C7TRfOoKDBNUr4+6PGDB8Dj9TKzLnTlGG2 Ng6VBniAyhxpBDqGliA7h3QymH356NMuwpuCEaSdihO56UrHF01syyY20HXtWCbXqRhhTP8CqN +QSXKKW6BenhEFSsZHAI6rJxAPy7TJMa34QRfeX05sH1iS5Em+GzjOy6Mucmb4KFBnxVcFrqM+ d8AINlm/+YyaF2EFxxOjDroMnhKekMAzP4KT7k+pItzi5XJ5309/2XXkNvD7uYnp7nnKoX3lsG /mvBQYRaG3eEw0HYLAqa0q+pwucnYEijpjWyOuznvPAbeA==; 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-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=dDYE6zqEaic3weSuS6C9IHEm+lF7sWTyKssZcwkKCOU=; b=YaFj88spQqjcG/4K8rsV9JWK// Vo5G2lF6Cr8HbtcZm/rxRlq/SG9qotyq1UgVob/T/q489mVsu+2pXrhEq3+dGN0VugPC3xmDgxXQs ZE+mUaYLLPbVahkprX1QYpXsmunv5O+cE4h6d5FJPg44YF0kwDF42zK2tUESqEr/8g9U9aZiZ0xS7 WvZQzD4DdF2bypKC5G1rrTbp7gMqDHuA6lAirNiyyQAsMG/OjhUCzvkgogTYBqPdTi+LSiT8liKo/ sXs6LuxpR79YlbG1kTGjeK7kfrf34wND/ZfSG2gcJHEMINOgjzZybYKIzJq+FlUWArsOlItyTn+s8 ceYUBBRA==; Received: from authenticated user by zero.zsh.org with local id 1lEFyR-000AnF-Ad; Mon, 22 Feb 2021 18:30:23 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f44.google.com) smtp.remote-ip=209.85.210.44; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ot1-f44.google.com ([209.85.210.44]:43091) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lEFy8-000Ado-IB; Mon, 22 Feb 2021 18:30:05 +0000 Received: by mail-ot1-f44.google.com with SMTP id l23so12930241otn.10 for ; Mon, 22 Feb 2021 10:30:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dDYE6zqEaic3weSuS6C9IHEm+lF7sWTyKssZcwkKCOU=; b=IBkX0fmXvmim4/VPmfftd5ggk7QKkxjBApx5IS57pJbphzvxgXVYcGgzZXeJiycGqq LPAcKm3esE5rj0Cc3jtcdbqYjI0RO1FygVi0pPkT38cV3/C4pvHi9wjHKBgegh7Jb8qs PHYeuCYCDFeLc5sW1FiA5zh8b89xkdtNRmgXaPu8HN0NdLpnbEYcid9j5UeINjNx/Ru8 L3qTJOJ9QyreG+omCXV/4RsKPrG+YuPa+9DHe2wpLQouWDula3Yen//b87sgvkPHjgTB MOtBMUTSBSsYomfnsxNwfdjJpVC9zzvRc7OqbKncO+ABeEE6vyqnxbhMHWCBviG72IC/ aInQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dDYE6zqEaic3weSuS6C9IHEm+lF7sWTyKssZcwkKCOU=; b=EIvowS92CL+gatoPwbMQI3hm/a+PWj7RXE5oEgnW3Z8BhMnlmCySfBR8jy7ERaZppM rVrCtOfU88QcfjpoOK7pQv2dvGibz+gYDhadOADZIS2p7xOElUGaiUdCZed1ignAcHF6 Qos1X2rHQO7TCjLimwMctBFZwxPAVVTAmudBPZ9pvIaLNlqZSKOKbYHerI4xligGWi3f zFXo7RJP2ugo6zkOcoqNjbBMbwBEpguGXHmNv487w+4vqJxCrt0tbPMYV1O3zMaNlLKb pJ962gznn07Mjcq872HfVjH8C4WXpe8Fv2Cfo4ZtwrqNSVuHFD6U/CATqnICP51JXtoz PGGw== X-Gm-Message-State: AOAM532s1Azf4do95X/mk4YfbJtQCFBCV6+SrnpixZwso+oeZz3HH7Uv Sevu6Rs8QprOr+GQqIkNx0pgMgHSRWqhuWtluYC96Efl1yMo+T3U X-Google-Smtp-Source: ABdhPJyMxp55EPhVAnj3d9q9hXufx/fkS8f1hcnTrGdwRLJLjWtyxEEDDjRl/jsOGufoxpue7JISMUBvwl1IVdHILFA= X-Received: by 2002:a05:6830:2106:: with SMTP id i6mr17523603otc.260.1614018603280; Mon, 22 Feb 2021 10:30:03 -0800 (PST) MIME-Version: 1.0 References: <20210125081625.3193714-1-ar@cs.msu.ru> <20210125081625.3193714-2-ar@cs.msu.ru> In-Reply-To: <20210125081625.3193714-2-ar@cs.msu.ru> From: Bart Schaefer Date: Mon, 22 Feb 2021 10:29:52 -0800 Message-ID: Subject: Re: [PATCH 2/2] promptinit: Fix prompt cleanups To: Arseny Maslennikov Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" X-Seq: 48092 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: 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'. Thanks, I did have a chance to look at this. > We fix it in the following way, hopefully without breaking compatibility: > * 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(). These all seem fine, conceptually. > * Prepend every use of prompt_*_setup (which might modify the shell > state in ways that require cleanup) with a cleanup run. Have you confirmed that this is a no-op when there has not been a previous installation of a theme? > * Adjust `prompt restore' to do both parts of the newly split restore > mechanism, cleanup first. Also fine. Just a couple of nit-picky things about the diff itself: > 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 Placement of the added zstyle call makes the comment incorrect, move it above the comment? > @@ -179,28 +182,41 @@ Use prompt -h for help on specific themes.' > + # Will add the hook this time. > + prompt_cleanup "$@" 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.