zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Teardown for prompts
Date: Fri, 06 Jan 2012 08:22:05 -0800	[thread overview]
Message-ID: <120106082205.ZM16261@torch.brasslantern.com> (raw)
In-Reply-To: <B3BC4505B3444C2EAEEF95F8B334D14F@gmail.com>

On Jan 5, 11:23am, Christian Holtje wrote:
}
} 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

I was looking again at the patch you sent for this, and for prompts it
seems it might be important to handle the zsh_directory_name hook too.

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

    for hook in ${=${(f)"$(add-zsh-hook)"}[-1]}

would do it, though it might be better to add a -L option to add-zsh-hook
so as not to rely on the usage message and that being printed to stdout.

There's actually a similar issue with prompt_preview_theme, which tries
to make hook lists local to prevent them from changing the world when a
prompt is "temporarily" installed.

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

If added, this should probably use "cleanup" rather than "teardown" to
be consistent with other zsh usages.

There's an example of something like this in prompt_bart_setup, where
you can say "prompt bart off" and it unloads itself.  A comment in there
seems to indicate that at one time there was a theme named "off" so you
could just say "prompt off" and it would unload everything, but I can't
find any other trace of the "prompt_off_setup" function any longer.

}  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 think I'd rather leave this up to the individual cleanup routines.


      parent reply	other threads:[~2012-01-06 16:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 15:47   ` Bart Schaefer
2012-01-06 16:22 ` Bart Schaefer [this message]

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=120106082205.ZM16261@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).