From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2190 invoked by alias); 26 Aug 2014 17:11:14 -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: 33057 Received: (qmail 5686 invoked from network); 26 Aug 2014 17:11:00 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7f776d000003e54-67-53fcbfa139af Date: Tue, 26 Aug 2014 18:10:55 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: PATCH: evaluation depth in prompts Message-id: <20140826181055.59c99bdc@pwslap01u.europe.root.pri> In-reply-to: <20140826174029.6478ee3a@pwslap01u.europe.root.pri> References: <20140826174029.6478ee3a@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmluLIzCtJLcpLzFFi42I5/e/4Vd2F+/8EG/z6yGRxsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4MuY/0iyYxFtx9OVF1gbGTVxdjJwcEgImEtdfvmWDsMUkLtxb D2RzcQgJLGWU6Lh6lQnCWc4kcfb5SkaQKhYBVYlvL++A2WwChhJTN80Gsjk4RAS0Jdo/ioGE hYHM+XPXMIPYvAL2EsfOHwRbwCngILFs7j9WEFsIKD6jfRoLiM0voC9x9e8nJogj7CVmXjnD CNErKPFj8j2wGmYBLYnN25pYIWx5ic1r3jJPYBSYhaRsFpKyWUjKFjAyr2IUTS1NLihOSs81 0itOzC0uzUvXS87P3cQICcCvOxiXHrM6xCjAwajEw/sg7XewEGtiWXFl7iFGCQ5mJRHeH0l/ goV4UxIrq1KL8uOLSnNSiw8xMnFwSjUwapSEJ9iYSCblfA9PFq2sftn8MeuS1UsmZd33x7UO vW2+7fXhqCcz2/+grysLDxczzV/w0Kag7EbgIa9TNruuciaa9F9Kd5i59cTtv8Vcctn38y5e ZDCNX2GvcIVr1+e483Wdv5w1ZcpVWA1z2911uu65n1Faelru2WLJt0zvmwznszPJ/1+hxFKc kWioxVxUnAgAz5660R4CAAA= 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). I won't commit this until the release now. Probably Thursday is my next chance for that while leaving enough time for people to moan. diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo index 0ed52b5..183a93a 100644 --- a/Doc/Zsh/prompt.yo +++ b/Doc/Zsh/prompt.yo @@ -108,6 +108,12 @@ the full path; ifzman(see em(Dynamic) and em(Static named directories) in zmanref(zshexpn))\ ifnzman(noderef(Filename Expansion)). ) +item(tt(%e))( +Evaluation depth of the current sourced file, shell function, or tt(eval). +This is incremented or decremented every time the value of tt(%N) is +set or reverted to a previous value, respectively. This is most useful +for debugging as part of tt($PS4). +) xitem(tt(%h)) item(tt(%!))( Current history event number. diff --git a/Src/prompt.c b/Src/prompt.c index 328ae3c..4762535 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -786,6 +786,19 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) if(bv->Rstring) stradd(bv->Rstring); break; + case 'e': + { + int depth = 0; + Funcstack fsptr = funcstack; + while (fsptr) { + depth++; + fsptr = fsptr->prev; + } + addbufspc(DIGBUFSIZE); + sprintf(bv->bp, "%d", depth); + bv->bp += strlen(bv->bp); + break; + } case 'I': if (funcstack && funcstack->tp != FS_SOURCE && !IN_EVAL_TRAP()) { pws