zsh-workers
 help / color / mirror / code / Atom feed
From: "Christian Höltje" <docwhat@gerf.org>
To: zsh-workers@zsh.org
Subject: Teardown for prompts
Date: Thu, 5 Jan 2012 11:23:16 -0500	[thread overview]
Message-ID: <B3BC4505B3444C2EAEEF95F8B334D14F@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]

I have some suggestions for the promptinit stuff....  

1) Remove other prompt related hooks.  Currently, it removes preexec and precmd, but it doesn't remove chpwd, periodic, zshexit, nor zshaddhistory.
      e.g.
for hook in preexec precmd chpwd periodic zshexit zshaddhistory; do
          add-zsh-hook -D "${hook}" "prompt_*_${hook}"
        done

     Bonus points for getting the list of hooks from add-zsh-hook itself.

 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', it would look for prompt_adam2_teardown and run it if it exists before switch to the new prompt.

 3) On switching away from a prompt, look for any and all variables and functions with pattern "prompt_${current_prompt_name}_*" and unset/unfunction them.

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 still being called when I switched to a new prompt.  

--  
Christian Höltje
docwhat@gerf.org
http://docwhat.org/


             reply	other threads:[~2012-01-05 16:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05 16:23 Christian Höltje [this message]
2012-01-05 18:44 ` Teardown for prompts [patch - remove all hooks] Christian Höltje
2012-01-06 15:47   ` Bart Schaefer
2012-01-06 16:22 ` Teardown for prompts Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B3BC4505B3444C2EAEEF95F8B334D14F@gmail.com \
    --to=docwhat@gerf.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).