zsh-workers
 help / color / mirror / code / Atom feed
* Teardown for prompts
@ 2012-01-05 16:23 Christian Höltje
  2012-01-05 18:44 ` Teardown for prompts [patch - remove all hooks] Christian Höltje
  2012-01-06 16:22 ` Teardown for prompts Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: Christian Höltje @ 2012-01-05 16:23 UTC (permalink / raw)
  To: zsh-workers

[-- 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/


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-06 16:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-05 16:23 Teardown for prompts Christian Höltje
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

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).