From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14009 invoked by alias); 18 Sep 2015 15:49:08 -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: 20585 Received: (qmail 26268 invoked from network); 18 Sep 2015 15:49:05 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=T/C1EZ6Q c=1 sm=1 tr=0 a=Qosx6O6xXGET3N4RHWVm7w==:117 a=Qosx6O6xXGET3N4RHWVm7w==:17 a=N659UExz7-8A:10 a=UsnRCveNSeEqhPjEyUkA:9 a=pILNOxqGKmIA:10 Message-id: <55FC326F.4050503@eastlink.ca> Date: Fri, 18 Sep 2015 08:49:03 -0700 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: autoload References: <55FAE223.2080502@eastlink.ca> <150917103419.ZM10067@torch.brasslantern.com> <55FB12FD.8000504@eastlink.ca> <150917134047.ZM10250@torch.brasslantern.com> <55FB476F.7080106@eastlink.ca> <150917162009.ZM10431@torch.brasslantern.com> <55FB66E8.5030503@eastlink.ca> <150917210453.ZM12575@torch.brasslantern.com> <55FB9A50.4060903@eastlink.ca> <150917225221.ZM25880@torch.brasslantern.com> In-reply-to: <150917225221.ZM25880@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 09/17/2015 10:52 PM, Bart Schaefer wrote: > It's not a mystery. Try this: > > zsh -nf /usr/share/zsh/functions/Completion/Base.zwc Ah, so the error is really from some other file. I assumed it was some sort of second parsing or something. Nice if the called file was identified tho. Anyway at least that's clear. > If we now throw zcompile into the mix, the -z / -k options to autoload > are ignored in favor of the -z / -k options to zcompile. However, the > rule about the file name having to be the same as the function name > doesn't change. Further "autoload -w" still doesn't define anything; > it just uses the index table in the zcompiled file to grab the list > of names to mark for later processing. This could be made clearer in the docs. > } Strangely there seems to be no trouble with multiple functions in one > } file except in the case of 'miscfunctions' so I have to source it > } separately. (The other multiple functions are all help functions only > } called by the main function in each file. I don't know why that makes > } a difference, but it does.) > > Does what I just wrote, above, help? In the "miscfunctions" case, the > name of the file matches NONE of the names of the functions inside it; > they can't be autoloaded. The name of the file has to match the name > of AT LEAST ONE function inside the file, *OR* the entire file has to > be that single function (as if it were a script). I see. Nuts, there's nothing about that in the docs is there? > ... The contents of fpath at the > instant of execution ALWAYS takes precedence; there is no "never get > this function from anywhere except [here]" in the autoload scheme. > As always Bart you make things as clear as they can be, but it sure is obtuse. I long for: $ autoload --just_DO_IT Source.zwc ... that is functionally identical to: $ for aa in /aWorking/Zsh/Source/*; do source $aa; done ( Of course that's after having done:) $ zcompile --just_DO_IT Source.zwc /aWorking/Zsh/Source/* ... but much faster--all functions are pre-digested to word code and ready for action, only not loaded into memory until/unless actually called. 'zcompile --just_DO_IT' is smart enough to create function names after filenames in the case of scripts, and of course named functions are named functions. No need for wandering around in $fpath, the names of all the functions found in '.../Source' (regardless of the name of any file except in the case of scripts) and their definition .zwc are tabled for instant access so the user can consider them as having been sourced already, it's just much faster and trimmer. (Speed is the point of all this, right?) "zcompile -t --just_DO_IT Source.zwc" returns the list of all *functions* found or created (from scripts) in 'Source.zwc'. Never mind, like completion, this is not for mortals to dabble in. My 'for' loop does it all in one line and there's no gotchas. Transparency is not a zsh virtue.