From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24862 invoked by alias); 30 Aug 2014 20:35:34 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33070 Received: (qmail 19660 invoked from network); 30 Aug 2014 20:35:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140830133555.ZM13185@torch.brasslantern.com> Date: Sat, 30 Aug 2014 13:35:55 -0700 In-reply-to: <20140826181055.59c99bdc@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "PATCH: evaluation depth in prompts" (Aug 26, 6:10pm) References: <20140826174029.6478ee3a@pwslap01u.europe.root.pri> <20140826181055.59c99bdc@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "Zsh Hackers' List" Subject: Re: PATCH: evaluation depth in prompts MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 26, 6:10pm, Peter Stephenson wrote: } Subject: PATCH: evaluation depth in prompts } } On Tue, 26 Aug 2014 17:40:29 +0100 } Peter Stephenson wrote: } > A better solution might be for a prompt escape that tracks the } > nesting level (which is trivial apart from picking a new letter). } } %e for evaluation depth (%E is taken but %e isn't). Nifty, but it should also be added as %N(e.deep.shallow). diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo index 183a93a..17af5b0 100644 --- a/Doc/Zsh/prompt.yo +++ b/Doc/Zsh/prompt.yo @@ -305,6 +305,7 @@ least var(n) elements relative to the root directory, hence tt(/) is counted as 0 elements.) sitem(tt(D))(True if the month is equal to var(n) (January = 0).) sitem(tt(d))(True if the day of the month is equal to var(n).) +sitem(tt(e))(True if the evaluation depth is at least var(n).) sitem(tt(g))(True if the effective gid of the current process is var(n).) sitem(tt(j))(True if the number of jobs is at least var(n).) sitem(tt(L))(True if the tt(SHLVL) parameter is at least var(n).) diff --git a/Src/prompt.c b/Src/prompt.c index 4762535..9ed6c54 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -372,6 +372,17 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) if (t0 >= arg) test = 1; break; + case 'e': + { + Funcstack fsptr = funcstack; + test = arg; + while (fsptr && test > 0) { + test--; + fsptr = fsptr->prev; + } + test = !test; + } + break; case 'L': if (shlvl >= arg) test = 1;