From 715f4a4e9c6b7d356fc42639b565c6eaa19499ad Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Tue, 26 Sep 2017 12:28:08 -0500 Subject: [PATCH] [template] Use zrecompile and create digest zwc file for the autoloaded functions. According to the `zshbuiltins` documentation: Files containing multiple compiled functions are called `digest' files, and are intended to be used as elements of the FPATH/fpath special array. Also compiling all module init files, instead of some selected ones. This didn't impact performance much (time to run async block in zlogin when from 0.22s to 0.25s on my machine). Didn't manage to make adding the prompt `prompt_*_setup` functions to the digest file work, so kept these separate. Closes #86 --- init.zsh | 2 +- templates/zlogin | 42 ++++++++++++++---------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/init.zsh b/init.zsh index 2d87b61..c49782d 100755 --- a/init.zsh +++ b/init.zsh @@ -33,7 +33,7 @@ load_zim_function() { local mod_function # autoload searches fpath for function locations; add enabled module function paths - fpath=(${${zmodules}:+${ZIM_HOME}/modules/${^zmodules}/functions(/FN)} ${fpath}) + fpath=(${ZIM_HOME}/functions.zwc ${ZIM_HOME}/modules/prompt/functions ${fpath}) function { setopt LOCAL_OPTIONS EXTENDED_GLOB diff --git a/templates/zlogin b/templates/zlogin index bac8e6c..714941e 100644 --- a/templates/zlogin +++ b/templates/zlogin @@ -8,52 +8,38 @@ # ( - # Function to determine the need of a zcompile. If the .zwc file - # does not exist, or the base file is newer, we need to compile. - # These jobs are asynchronous, and will not impact the interactive shell - zcompare() { - if [[ -s ${1} && ( ! -s ${1}.zwc || ${1} -nt ${1}.zwc ) ]]; then - zcompile ${1} - fi - } - local zim_mods=${ZIM_HOME}/modules setopt EXTENDED_GLOB + autoload -U zrecompile # zcompile the completion cache; siginificant speedup. for file in ${ZDOTDIR:-${HOME}}/.zcomp^(*.zwc)(.); do - zcompare ${file} + zrecompile -pq ${file} done # zcompile .zshrc - zcompare ${ZDOTDIR:-${HOME}}/.zshrc + zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshrc - # zcompile some light module init scripts - zcompare ${zim_mods}/git/init.zsh - zcompare ${zim_mods}/git-info/init.zsh - zcompare ${zim_mods}/utility/init.zsh - zcompare ${zim_mods}/pacman/init.zsh - zcompare ${zim_mods}/spectrum/init.zsh - zcompare ${zim_mods}/completion/init.zsh - zcompare ${zim_mods}/fasd/init.zsh - - # zcompile all .zsh files in the custom module - for file in ${zim_mods}/custom/**/^(README.md|*.zwc)(.); do - zcompare ${file} + # zcompile all module init scripts + for file in ${zim_mods}/*/init.zsh; do + zrecompile -pq ${file} done # zcompile all autoloaded functions - for file in ${zim_mods}/**/functions/^(*.zwc)(.); do - zcompare ${file} + zrecompile -pq ${ZIM_HOME}/functions ${zim_mods}/*/functions/^([_.]*|prompt_*_setup|README*|*.zwc)(.) + + # zcompile all prompt setup scripts + for file in ${zim_mods}/prompt/functions/prompt_*_setup; do + zrecompile -pq ${file} done # syntax-highlighting for file in ${zim_mods}/syntax-highlighting/external/highlighters/**^test-data/*.zsh; do - zcompare ${file} + zrecompile -pq ${file} done - zcompare ${zim_mods}/syntax-highlighting/external/zsh-syntax-highlighting.zsh + zrecompile -pq ${zim_mods}/syntax-highlighting/external/zsh-syntax-highlighting.zsh # zsh-histery-substring-search - zcompare ${zim_mods}/history-substring-search/external/zsh-history-substring-search.zsh + zrecompile -pq ${zim_mods}/history-substring-search/external/zsh-history-substring-search.zsh ) &!