From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24519 invoked by alias); 27 Jan 2017 18:40:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40431 Received: (qmail 5197 invoked from network); 27 Jan 2017 18:40:22 -0000 X-Qmail-Scanner-Diagnostics: from new2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.224):SA:0(-0.4/5.0):. Processed in 1.413303 secs); 27 Jan 2017 18:40:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: psprint2@fastmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf.messagingengine.com designates 66.111.4.224 as permitted sender) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=VUfIY1RRjgnqzqHNjDN/7E/ry7 4=; b=g6aN7Cubz4qJB4cOZs+L9szzWby3ulmNc3JcXrI4BYVzfZ720vEw1mSSYH F0aqPpd3zzVfuHk5paamPVVB0AN6yHs2p9yI8jOCXLb4dYkzHHvHDHm1fqe0QoD0 EaRYioifjD2zJS6Hf4e8UyobHjlfNHVrOkU+AAmOSLV59vhrs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=smtpout; bh=VU fIY1RRjgnqzqHNjDN/7E/ry74=; b=qf61LzTyRNbUcsZ2ukOJtXWoPUnH4VHoW2 s6hLTowMVN807CWhrDUNWbALsciEG3rCZgEnqkWctmelXZjAhtKiWAt+abLmcHwZ PW1hX5gPm/a7fpXF2EBcTb/YXEz71Nk6bTQUtwJUdJNoqb/ZKgay2PIOTrfm7zVz /SsSzrhUU= X-ME-Sender: Message-Id: <1485542415.1037033.861766968.196E6FB9@webmail.messagingengine.com> From: Sebastian Gniazdowski To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-37809a74 References: <1485529979.987251.861563792.06CCDCAC@webmail.messagingengine.com> <20170127162440.10a5c85b@pwslap01u.europe.root.pri> Date: Fri, 27 Jan 2017 10:40:15 -0800 In-Reply-To: <20170127162440.10a5c85b@pwslap01u.europe.root.pri> Subject: Re: PATH: autoload with explicit path On Fri, Jan 27, 2017, at 08:24 AM, Peter Stephenson wrote: > On Fri, 27 Jan 2017 07:12:59 -0800 > Sebastian Gniazdowski wrote: > > I do the non-fpath autoloading by local FPATH parameter. There's > > drawback: if autoloaded function does further autoloading of other > > function, then the earlier supplied local FPATH parameter isn't active > > anymore. > > > > So it's not possible to have /home/user/functions/{fun1,fun2}, autoload > > fun1, and have fun2 available for fun1. Now, with the new feature, > > directory path can be attached to function and if it calls autoload > > itself, then the attached directory can be examined before FPATH. > > You're worried about something like this? > > > # set up function > local path_that_only_appears_here=/foo/bar > autoload -Uz $path_that_only_appears_here/fun1 > > > # definition of fun1 > autoload -Uz /fun2 > fun2 > > > You can already do this using funcsourcetrace from zsh/parameter: > ${funcsourcetrace[1]%%:<->} is the source file for the immediately > enclosing scope, so take the directory part of that and you've > got what you want (being careful if you happen to have evals > or anonymous functions which generate their own scopes). Internally via autoload it will be easy to create custom versions of multiple functions. For example calendar does: autoload -Uz calendar_{add,parse,read,scandate,show,lockfiles} With the requested feature, I can copy any subset of above functions to /home/user/functions, and "autoload -Uz /home/user/functions/calendar" will pull them. This is also possible by prepending FPATH with /home/user/functions, true. But deciding whether I want to pull in custom calendar or not via FPATH management or by removing calendar* files is hard. The new feature will be very convenient if user will have multiple directories, for example a second one /home/user/new_functions. To choose from where to pull in the calendar will be to simply change path to it in autoload call. So in .zshrc there will be: # My custom calendar autoload -Uz /home/user/functions/calendar and that's it, no FPATH management or removing files from /home/user/functions (to revert to official calendar, if the directory is in FPATH). > It's a bit limiting you can't get that information for any function, > since it's alrady available internally in the shfunc structure. I'd be > happy to add an associative array in zsh/parameter parallel to > $functions, say $function_sources, that gives the information for all > functions. Sounds nice, though it's nice that current implementation of the absolute-path feature uses pointers to paths to limit memory usage, a new parameter would probably spend that. -- Sebastian Gniazdowski