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,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32565 invoked from network); 11 Aug 2022 14:31:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2022 14:31:55 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1660228315; b=NgWVVoUaGem7E9nSFDIYBTAOJ1ipswm0bRnKcIXdfBC/iGUkM4gRXrGL4w6rUo7ipuojxTp4GS CRb0gHxfieMAx511mT86meAZhkvmsBv9qufEb1JmE0OcnYHh1IpkgskG1Mvss03UfrTpiNLJIw ZH6Wb2sX6eZ+kkIPpxXqweYUZSB4mg5cLsrGMHvZjmZow8TCywJP8YrxmNXZSe20iqW55khPz6 yQJaDYHHh6/gOKZ7imM53P/XVL6LhRdHLxQOK4sZg0ho71wFAI3BMkmpVe+1sMjsk6GXZHYa/y HMPUOK/wop26OZfRdGTypfZBmtc/cM1oiDApEOHxNNVNRA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f53.google.com) smtp.remote-ip=209.85.208.53; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1660228315; bh=mmyx7nBf3ORVvqcFIYp4yJClkZ09WAZcQkgTEMWe1x4=; 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=jz3wFX4bgXajvbj2EC+VK47ikswyFwA4RJOhSQd7UcwfmA08D6vkzqsHyPdFAfDd4cdHSmv0Oh J6sIDRxvQMD9exnQcPQZo2hNGGVCKChpZDv/bo4KIj+iJYhA+ujrUyrzkqVjzq/ARzTo2vXr3F qB/TYJrsZ5CnpQuFomTPPSXXpXqnrT87o0uOYBsW2O2NAxf32Kuy+1j522lkwkk7WQESBlTZeH VzUD85zn4P87t/ybltGBV6r9taRLDYg0f08LjgNcri08praOYFbJ+WfEvIc0V2pX2TiqH4trBx vbNH92ovxq2Omf0jfehOgLGzlznZZhHvKdxc9JmnoEi9oA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; 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=OhpMgzR0zwbSe6ark5EO3CpM7s01JIUYLRf6RKOcm2s=; b=qxe6RA5SX/hTqRScT6shP2O+yZ 8l4OuZLy4twvgeY1mmBdLmIL69KCLLJHncnzrMj+zpNW65QoFfVBZrmHVJVXftUk5aRs3Tx5KdQRv fw3XGnGzFl4Vt3M6A2KDmDV4iTq1EI4XDDxIX/TRt9TCt2ArwlLJOp5NH04Rltf/syPOM2vhZafNb ej4cir1FAVuzMsIPh8jHW1nRYNFBzzfltz7+gY181F/G1zo6oy9hJO+7iGUrgAxy+idAfM+teMERH 04zH22Op921vNgdic/kzEtjVHbktdn2x4FOVmhiAAepu8Emfpfp7BV9korXmOzbylMawcuIkRyJag WLi8O6oQ==; Received: from authenticated user by zero.zsh.org with local id 1oM9E3-0008IJ-96; Thu, 11 Aug 2022 14:31:55 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f53.google.com) smtp.remote-ip=209.85.208.53; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ed1-f53.google.com ([209.85.208.53]:36593) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oM990-0007dr-N0; Thu, 11 Aug 2022 14:26:43 +0000 Received: by mail-ed1-f53.google.com with SMTP id x21so23188920edd.3; Thu, 11 Aug 2022 07:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=OhpMgzR0zwbSe6ark5EO3CpM7s01JIUYLRf6RKOcm2s=; b=SAu1n1E1L+7vtHS5iRwx7zkcvCZ9KuawxjRzv8YOVby+ENNQNpxa5G04Tzi2jWNBXI dUyPFayg0RNU0mOPV9GHjS2p8wIGu9k6wf6UwHdKX4hhISCPB55kfr4REJS8qDWvkgDU hzzMt/2vDvWd8KZ+v1CUMmXjdHMdqbCm41J+I2C6A51C/t4I3syByXFnO9xoutzXCsQy kxV+rAg0PLWyyzu/taBHfrmFfafYZ/RRw9SnRkSOYzjFE4cFUfJoo//22hpOfNBk74E/ MCo23S+YEhICa3eTHWpttAUKey0/6ZUMsNp65+Rs7aIFjJiNpYBsqdGId+csFeyjxfcs byJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=OhpMgzR0zwbSe6ark5EO3CpM7s01JIUYLRf6RKOcm2s=; b=o3yikAlxyA42sXF/b3SU5DKLRdr0XftArcGTDanbSY4PuNB/ihcWTxgNHl8dl0GXGu +Oyj0ugJsAKV73JjQXwMNd2mwWfxIhoNn0dKPJ9tRi8UHKHCKgBUOYBX4S9Er51POSQc lRn3gRLaPN7LWmhRPsVEcNYyHLK3PPrxkYZ7wKRTAUvlZETYSInYNrGO1F/BPitcaQ+v wnk6NqJ6DWXJXH8gDU8ndn9KmZD4D6HHQQAW8Fxvf81tnzS4wa2fu2Vczko/7dXl2Xze b5H7co5vRQ63k1j2DvUN3Ol78tPDB7Z9W1s4FOoghM7vVnpGHdBVKVxGjXwYwSBuPLdl cgvA== X-Gm-Message-State: ACgBeo1TpxvM7dft+TQzw/ZiTVyhngdyhhZ3fUbAzAo0Y6ZqL3npvvhb mhz93LiIfuf7S4+cgPyUiE8kJd7e3U/WsDhzOLo= X-Google-Smtp-Source: AA6agR4cqyX2dM5zvNReJHGLc9fuj+XKQPKJqGqLbype7WrPUUh2wh3vYxPH3Dqv4/rOblidNEQoHQq6fI/4X8dslFA= X-Received: by 2002:a05:6402:2792:b0:43f:6873:7497 with SMTP id b18-20020a056402279200b0043f68737497mr29596769ede.175.1660228002240; Thu, 11 Aug 2022 07:26:42 -0700 (PDT) MIME-Version: 1.0 References: <20220810115120.182853-1-felipe.contreras@gmail.com> In-Reply-To: From: Felipe Contreras Date: Thu, 11 Aug 2022 09:26:30 -0500 Message-ID: Subject: Re: [PATCH] prompt: support generic non-visible regions To: Mikael Magnusson Cc: zsh-workers@zsh.org, Oliver Kiddle , dana Content-Type: text/plain; charset="UTF-8" X-Seq: 50453 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: On Thu, Aug 11, 2022 at 9:02 AM Mikael Magnusson wrote: > On 8/10/22, Felipe Contreras wrote: > > On Wed, Aug 10, 2022 at 1:59 PM Mikael Magnusson wrote: > >> The commit message seems a bit confused, %F has nothing to do with > >> marking characters as 0-width, rather everything between %{ and %} > >> will be treated as such. You can use %{%} (or \001 https://www.logicallyfallacious.com/logicalfallacies/Slippery-Slopeand \002) to set > >> colors via the specific \e [ Ps m code, but also to send any other > >> codes handled by the terminal. > > > > If I do PS1='%F{red}foo' putpromptchar() will call > > set_colour_attribute(), which eventually calls this: > > > > if (!bv->dontcount) { > > addbufspc(1); > > *bv->bp++ = Inpar; > > } > > tputs(tgoto(tcstr[tc], colour, colour), 1, putstr); > > if (!bv->dontcount) { > > addbufspc(1); > > *bv->bp++ = Outpar; > > } > > > > I can do the same thing fputs() is doing with PS1=$'\e[31mfoo', but > > now zsh will think my prompt is bigger than it actually is and the > > shell will be screwed. So I have to put that inside %{%}. > > > > Therefore "%F{red}" = $'%{\e[31m%}' > > Sure, this agrees 100% with what I was saying, but the statement in > the commit still doesn't make sense. You've proven that you can use %{ > or \001 to do what %F{} does, but the commit message states the > opposite which is not true. The commit message says: 1. We do readline $'\001\e[31m\002' as zsh '%F{red}'. This is true. 2. We could support $'\001\e[31m\002'. This is also true. > >> That aside, I don't really see a reason to add support for > >> bash-specific prompt sequences that are more cumbersome to use than > >> the already existing zsh ones. Bash prompts are already completely > >> incompatible anyway. > > > > The prompts are not compatible, but the functions used in those prompts can > > be. > > > > __git_ps1_test () { > > local branch='master' > > local red=$'\001\e[31m\002' > > local clear=$'\001\e[m\002' > > echo "${red}${branch}${clear}" > > } > > > > The function above works perfectly fine in bash and zsh with my patch, > > and I can add $(__git_ps1_test) to both of my prompts. > > You could also have a $START_INVIS and $END_INVIS parameter depending > on what shell you're in. Yes, and I can do red=$'\001\e[31m\002' or red='%F{red}' depending what shell I'm in, which is what I was doing. But *why* would I do that when zsh is perfectly capable of interpreting \001 and \002? (with my patch) > Well, I don't have a strong opinion either > way, but it doesn't seem worth it to me. If we support this, people > might ask "but you support \001, why not this other xyz prompt feature > from bash?" Slippery slope fallacy [1]. Yes, they might ask that, and you might answer "no, unline \001, xyz requires too much effort". This doesn't require too much effort. [1] https://www.logicallyfallacious.com/logicalfallacies/Slippery-Slope -- Felipe Contreras