From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25420 invoked by alias); 5 Jan 2012 18:44:44 -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: 30087 Received: (qmail 11057 invoked from network); 5 Jan 2012 18:44:41 -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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, HTML_MESSAGE,RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.213.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:date:from:to:message-id:in-reply-to:references:subject :x-mailer:mime-version:content-type; bh=BOzK2Ly8+/pPyrMAQmTurmz8Dqqp0+0+98+1alnRSYo=; b=L6kAX8jDLqy6jjPBjtsg4QaTA7I5kmxhRkNpiQaOmSXLJL0LLQzNyNtyoukb+Pufnd eWAfASBJ8RucKtHQO+zoq72HtMpAZt+IdfrUdKEIuF0TOw5JvfxvaMfOAjVFVQQDy7ft 1kLCmsDzO9GUz23cUBtv4jI0TfeMvjvZ7Ozb8= Sender: =?UTF-8?Q?Christian_H=C3=B6ltje?= Date: Thu, 5 Jan 2012 13:44:31 -0500 From: =?utf-8?Q?Christian_H=C3=B6ltje?= To: zsh-workers@zsh.org Message-ID: <78D2AAEB600F453B8ED374A29B7642F7@gmail.com> In-Reply-To: References: Subject: Re: Teardown for prompts [patch - remove all hooks] X-Mailer: sparrow 1.5 (build 1043.1) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="4f05ef8f_47398c89_d01" --4f05ef8f_47398c89_d01 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This patch will remove all prompt hooks when changing prompts, using the = prompt system. The current code only catches the precmd and preexec hooks, but all the h= ooks should be checked. diff --git a/=46unctions/Prompts/promptinit b/=46unctions/Prompts/prompti= nit index b07eabb..66e73a7 100644 --- a/=46unctions/Prompts/promptinit +++ b/=46unctions/Prompts/promptinit =40=40 -155,8 +155,10 =40=40 Use prompt -h for help on specific t= hemes.' fi =20 =23 Reset some commonly altered bits to the default - add-zsh-hook -D precmd =22prompt=5F*=5Fprecmd=22 - add-zsh-hook -D preexec =22prompt=5F*=5Fpreexec=22 + local hook + for hook in chpwd precmd preexec periodic zshaddhistory zshexit; = do + add-zsh-hook -D =22=24=7Bhook=7D=22 =22prompt=5F*=5F=24=7Bhook=7D= =22 + done set -A zle=5Fhighlight =24=7Bzle=5Fhighlight:=23default:*=7D (( =24=7B=23zle=5Fhighlight=7D )) =7C=7C unset zle=5Fhighlight =20 -- =20 Christian H=C3=B6ltje docwhat=40gerf.org http://docwhat.org/ On Thursday, January 5, 2012 at 11:23 AM, Christian H=C3=B6ltje wrote: > I have some suggestions for the promptinit stuff.... =20 > =20 > 1) Remove other prompt related hooks. Currently, it removes preexec an= d precmd, but it doesn't remove chpwd, periodic, zshexit, nor zshaddhisto= ry. > e.g. > for hook in preexec precmd chpwd periodic zshexit zshaddhistory; do > add-zsh-hook -D =22=24=7Bhook=7D=22 =22prompt=5F*=5F=24=7Bhoo= k=7D=22 > done > =20 > Bonus points for getting the list of hooks from add-zsh-hook itsel= f. > =20 > 2) Add a teardown function. This could be used to unset things, etc. = if the prompt changes. If prompt is switching from the prompt 'adam2', i= t would look for prompt=5Fadam2=5Fteardown and run it if it exists before= switch to the new prompt. > =20 > 3) On switching away from a prompt, look for any and all variables and= functions with pattern =22prompt=5F=24=7Bcurrent=5Fprompt=5Fname=7D=5F*=22= and unset/unfunction them. > =20 > I discovered this when I wrote a prompt that used the chpwd hook to try= to minimize certain VCS checks (an optimization) and that function was s= till being called when I switched to a new prompt. =20 > =20 > -- =20 > Christian H=C3=B6ltje > docwhat=40gerf.org (mailto:docwhat=40gerf.org) > http://docwhat.org/ > =20 --4f05ef8f_47398c89_d01--