From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20974 invoked from network); 13 Oct 2007 19:10:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Oct 2007 19:10:59 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 46972 invoked from network); 13 Oct 2007 19:10:53 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Oct 2007 19:10:53 -0000 Received: (qmail 16668 invoked by alias); 13 Oct 2007 19:10:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23950 Received: (qmail 16647 invoked from network); 13 Oct 2007 19:10:50 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Oct 2007 19:10:50 -0000 Received: (qmail 46665 invoked from network); 13 Oct 2007 19:10:50 -0000 Received: from mtaout02-winn.ispmail.ntl.com (81.103.221.48) by a.mx.sunsite.dk with SMTP; 13 Oct 2007 19:10:44 -0000 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20071013191043.HRYD25022.mtaout02-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com> for ; Sat, 13 Oct 2007 20:10:43 +0100 Received: from pws-pc.ntlworld.com ([81.107.45.67]) by aamtaout01-winn.ispmail.ntl.com with ESMTP id <20071013191043.PJBO219.aamtaout01-winn.ispmail.ntl.com@pws-pc.ntlworld.com> for ; Sat, 13 Oct 2007 20:10:43 +0100 Received: from pws-pc.ntlworld.com (pws-pc.ntlworld.com [127.0.0.1]) by pws-pc.ntlworld.com (8.14.1/8.13.8) with ESMTP id l9DJA3kr003265 for ; Sat, 13 Oct 2007 20:10:03 +0100 Message-Id: <200710131910.l9DJA3kr003265@pws-pc.ntlworld.com> From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: precmd, preexec, and supplied prompt themes In-Reply-To: Message from Bart Schaefer of "Sat, 13 Oct 2007 10:11:18 PDT." <071013101120.ZM14875@torch.brasslantern.com> Date: Sat, 13 Oct 2007 20:10:03 +0100 Bart Schaefer wrote: > So some discussion of how this ought to be redesigned would be useful > before someone jumps in to do it. It's always seemed a bit clunky to > me to do build up function names by sticking the theme name in the > middle, but that's at nit-pick. Maybe all we need is another one of > those functions, prompt_ZZZ_off (or pick another word). We could do it with one level of indirection... Generically: if [[ -z ${precmd_functions[(R)precmd_prompt]} ]]; then precmd_functions+=(precmd_prompt) fi precmd_prompt() { if (( ${+prompt_functions[precmd]} )); then $prompt_functions[precmd] fi } For each prompt: typeset -gA prompt_function_hooks prompt_functions=(precmd my_fantastic_precmd_function setup my_absolutely_superb_setup_function teardown my_truly_wonderful_teardown_function) and so on. As long as the functions in question are defined at the same time as the prompt_functions associative array there isn't a namespace clash. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/