From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17807 invoked by alias); 23 Jul 2015 01:41:35 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20343 Received: (qmail 25866 invoked from network); 23 Jul 2015 01:41:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=3r0eSVVFPSXCzj9zeRR46O6ES20ROXyaFr2ir+JKjMc=; b=kHYl8uur7wWHwG/EqpBsHh1skgIiCkyfVYhmsr+n98C0E6P0SXlk+gBcCT7MWguT4V SvkfYCFalBg2/yuRHu0x5TDmgwp8etMxYcpVVQ2IA6cCWPWNYb2TDZA1ohVFZrgSvsYS Rj5Y32Y3ZccQQ2XM7nERqz6USvIvQ3+leqC0fSsGACPk7p7Xc6mkTW5cFZ1PVy6PRQdX QbZj5F4PMxCq8wFbg+lKV/pB5s4Gc34AaL+8nm7u47ZOFvmDyGnSjnJDEYD7k0uLUgpg zwc/awrYiUzbflqAiY+lSDxT76ohus3kMwXBHfgrDeaBGk283LbNBbq7ypvHa0ACJQNV RX0A== X-Gm-Message-State: ALoCoQmRCwOeh1Pk7UK7/g6cMoeZ34YokmevuquppZTDPyZ8Ae3hgiP0BOPj4Cb21GfqnH03ptNC X-Received: by 10.182.95.69 with SMTP id di5mr5367072obb.73.1437615693439; Wed, 22 Jul 2015 18:41:33 -0700 (PDT) From: Bart Schaefer Message-Id: <150722184130.ZM327@torch.brasslantern.com> Date: Wed, 22 Jul 2015 18:41:30 -0700 In-Reply-To: <87zj2nsrjt.fsf@nl106-137-147.student.uu.se> Comments: In reply to Emanuel Berg "Re: sound policy on global variables for "distributed" DWIM function" (Jul 23, 1:25am) References: <87fv4hm3ia.fsf@nl106-137-147.student.uu.se> <20150722135519.GA11359@Qliphoth.local> <87zj2nsrjt.fsf@nl106-137-147.student.uu.se> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: sound policy on global variables for "distributed" DWIM function MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jul 23, 1:25am, Emanuel Berg wrote: } } But it doesn't have to be global outside the file } where those couple of functions are defined. Shells do not, generally speaking, have file-scoped variables. You get globals, variables that are local to functions, and the exported process environment, and that's about it. Howver, zsh does have yet another place to stash stuff like this: The zstyle mechanism. The ":completion:..." format is nothing but a convention used in compsys; styles can actually look like anything you want. So you could have file names for contexts, e.g. zstyle '*/.zsh/dump' file-extension png and then dump-vt () { local ext zstyle -s $HOME/.zsh/dump file-extension ext local file=$1.${ext:-png} # ... etc ... } You could also have a different file-extension based on the current working directory, or whatever.