From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15413 invoked by alias); 13 Sep 2015 16:11:27 -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: 36529 Received: (qmail 18467 invoked from network); 13 Sep 2015 16:11:26 -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-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=pmv0CajXWd4Lqh5uZVEVJG/zOb3U9EL8MyjXy8PkZdk=; b=lFs7swhJoPLo6B72rGR+KqWVvACruOboPRyE481UcUnmbVpw2dsIrdI0ziL/Oz1vn6 rIOuEal/WRt636K52i1BPr8/QqeZaRF2evRDtNhWgmvGcCYJ5zinVkeP6b29eMO+8cU3 J+C/H717dmeq6JAuTUHSBQx6Zu5ozb7B9FEf0gSYo+BFBVooAIjvj5iuxPIbI6r6a34M vJVpzhQuet6ZaZ2EAdy1teHoG5JxDNfHMIDR8vHsUgqOcnVigDZZpZOA0RvefVOLPbSW 31chPNWV1nBx/Bd6i03CNs0VggFzffo1GbST7S8g2cgzggQEHGjhftAhUbDlUr/QnPm9 VD1g== X-Gm-Message-State: ALoCoQnzqPMaBeA/dNKpRBSlkOkM61DtW6zFpV4itsoNpJrPXJcde7SQ+CrwQV3o3QcRMdaqHDZX X-Received: by 10.182.19.135 with SMTP id f7mr7520439obe.24.1442160682010; Sun, 13 Sep 2015 09:11:22 -0700 (PDT) From: Bart Schaefer Message-Id: <150913091118.ZM23399@torch.brasslantern.com> Date: Sun, 13 Sep 2015 09:11:18 -0700 In-Reply-To: Comments: In reply to Sebastian Gniazdowski "Re: Announce of Zsh Navigation Tools" (Sep 13, 11:10am) References: <55F465E6.1040405@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: autoloading fpath (was Re: Announce of Zsh Navigation Tools) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 13, 11:10am, Sebastian Gniazdowski wrote: } } I the rest of the emails you apparently have an idea of a } autostart-functions directory that would automatically do "autoload } {function}" for each file placed there. It would make installation of } scripts like ZNT easier and I thought about such directory too. This is effectively what "compinit" does for every file in the $fpath that is named beginning with an underscore. It reads the first line of every such file to decide what to do with it. While we're on the subject, though, take a look at the "zcompile" builtin and the "zrecompile" utility. If you zcompile a collection of functions into a .zwc file, you can -- -- add the .zwc file name directly to $fpath and it will be searched like a directory at autoloaded-function execution time -- specify the -z / -k behavior options at zcompile time so they don't have to be passed to autoload -- easily autoload everything in the file: autoload -w functions.zwc ZWC files are machine-independent but zsh-version-dependent. They get memory-mapped when that's supported so the OS pages them efficiently. The drawbacks are the version dependency if you frequently rebuild a bleeding-edge shell (but see zrecompile) and that zcompile doesn't yet support "sticky emulation" in any meaningful way. Also, a ZWC file is not like an archive file (e.g. a ZIP); you can't append or remove individual functions, the whole file has to be rebuilt. Finally, for Ray, you can for example replace your entire $fpath with a single ZWC file: # Assume starting here with the default $fpath zsh_default_functions=~/.zsh-default-functions.zwc if ! zcompile -t $zsh_default_functions >&/dev/null then # File is missing or out of date. Rebuild it. # Removes the file if any function cannot be compiled. zcompile $zsh_default_functions $^fpath/*(N.:A) fi if [[ -f $zsh_default_functions ]] then fpath=( $zsh_default_functions ) autoload -w $zsh_default_functions fi