From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25548 invoked from network); 14 Oct 2003 22:58:57 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 14 Oct 2003 22:58:57 -0000 Received: (qmail 8980 invoked by alias); 14 Oct 2003 22:58:17 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6702 Received: (qmail 8894 invoked from network); 14 Oct 2003 22:58:16 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 14 Oct 2003 22:58:16 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.193.203.32] by sunsite.dk (MessageWall 1.0.8) with SMTP; 14 Oct 2003 22:58:15 -0000 Received: from DervishD.pleyades.net (212.Red-80-35-44.pooles.rima-tde.net [80.35.44.212]) by madrid10.amenworld.com (8.10.2/8.10.2) with ESMTP id h9EMwA916173; Wed, 15 Oct 2003 00:58:10 +0200 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1A9Snl-0000Cz-00>; Tue, 14 Oct 2003 19:17:41 +0200 Date: Tue, 14 Oct 2003 19:17:41 +0200 From: DervishD To: Bart Schaefer Cc: Zsh Users Subject: Re: Is this an orthodox use of zstyle? Message-ID: <20031014171741.GG211@DervishD> Mail-Followup-To: Bart Schaefer , Zsh Users References: <20031014160041.GA343@DervishD> <1031014164250.ZM22562@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1031014164250.ZM22562@candle.brasslantern.com> User-Agent: Mutt/1.4i Organization: Pleyades User-Agent: Mutt/1.4i Hi Bart :) * Bart Schaefer dixit: > } I think I can use styles to carry state information from one > } widget execution to another, so the widget will behave differently > } depending on the result of past executions, but: is this an orthodox > } use of styles [...]? > Typically functions read styles but don't set them, unless they're a > special kind of function that's designed to help the user set up his > environment (e.g., (in 4.1.1) select-word-style). That's the cause of my question, I haven't seen this kind of use in zsh functions (well, I haven't checked all...). > If the same function will behave differently depending on context > (e.g., it might be called as either a normal widget or a completion > widget) then styles might be appropriate, but if you don't need to > save different state in different contexts, parameters are better. Well, the first widgets I want to modify using state information really don't need contexts, but I think that I may need it in the future, for example if I write any completion widget (I don't use compsys), so it may be a good thing using styled from the beginning. > } I know that I can do this with an environment variable but since > } the state information can be a bit complex I will need an array, or > } maybe a couple for separating information, or even an associative > You presumably don't want to "export" the widget state parameters > (you can't export styles) so it's fine to use arrays and associative > arrays for your state. Yes, you're true, I don't want nor need to export the state, so this is not an issue. Anyway, since styles doesn't pollute namespace, wouldn't be better to directly use them for storing state information even without contexts? > For example, look at the set of parameters > used by the zftp functions to maintain state. Yes, I've took that as an example ;)) but then my idea about using styles arose. I must admit that for simple state information, a simple array is enough, or maybe one per 'session' (whatever you call a session), but the power of styles is exciting ;) Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/