From 1d5c0c18d149a1cca5d8feef929353071003d754 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Sun, 26 Sep 2021 19:47:44 -0500 Subject: [PATCH] Initalization options are all auto or all manual in `zmodule`, since there's no way to unset a default value to "nothing". --- CHANGELOG.md | 3 +++ src/stage2/30_zmodule.zsh.erb | 16 +++++++++------- zimfw.zsh | 18 ++++++++++-------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2b260..b673dfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Be quieter and don't output warnings when `-q` is provided. +- Manually setting any `zmodule` initialization option will disable all the + default values from the other initialization options, so only user-provided + values are used in this case. I.e. it's either all automatic, or all manual. ### Fixed - Error in `zimfw update` with the `git` tool when module directory is under a diff --git a/src/stage2/30_zmodule.zsh.erb b/src/stage2/30_zmodule.zsh.erb index f8b6d4e..7dbe313 100644 --- a/src/stage2/30_zmodule.zsh.erb +++ b/src/stage2/30_zmodule.zsh.erb @@ -36,7 +36,11 @@ Initialization options: %B-c%b|%B--cmd%b Execute specified command. Occurrences of the %B{}%b placeholder in the command are substituted by the module root directory path. I.e., %B-s 'script.zsh'%b and %B-c 'source {}/script.zsh'%b are equivalent. - %B-d%b|%B--disabled%b Don't initialize or uninstall the module." + %B-d%b|%B--disabled%b Don't initialize or uninstall the module. + + Setting any initialization option above will disable all the default values from the other ini- + tialization options, so only your provided values are used. I.e. these values are either all + automatic, or all manual." if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then print -u2 -PRl "%F{red}${0}: Must be called from %B<%= home %>/.zimrc%b%f" '' ${zusage} return 2 @@ -153,8 +157,11 @@ Initialization options: _zfailed=1 return 1 fi - if (( ! ${#zfpaths} && ! ${#zcmds} )); then + if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then zfpaths=(${zdir}/functions(NF)) + # _* functions are autoloaded by compinit + # prompt_*_setup functions are autoloaded by promptinit + zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t)) local -ra prezto_scripts=(${zdir}/init.zsh(N)) if (( ${#zfpaths} && ${#prezto_scripts} )); then # this follows the prezto module format, no need to check for other scripts @@ -165,11 +172,6 @@ Initialization options: zcmds=("source ${^zscripts[@]:A}") fi fi - if (( ! ${#zfunctions} )); then - # _* functions are autoloaded by compinit - # prompt_*_setup functions are autoloaded by promptinit - zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t)) - fi if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then _zimfw_print -u2 -PRl "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f" '' ${zusage} fi diff --git a/zimfw.zsh b/zimfw.zsh index bfc7f7f..2d1dc23 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -146,7 +146,11 @@ Initialization options: %B-c%b|%B--cmd%b Execute specified command. Occurrences of the %B{}%b placeholder in the command are substituted by the module root directory path. I.e., %B-s 'script.zsh'%b and %B-c 'source {}/script.zsh'%b are equivalent. - %B-d%b|%B--disabled%b Don't initialize or uninstall the module." + %B-d%b|%B--disabled%b Don't initialize or uninstall the module. + + Setting any initialization option above will disable all the default values from the other ini- + tialization options, so only your provided values are used. I.e. these values are either all + automatic, or all manual." if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then print -u2 -PRl "%F{red}${0}: Must be called from %B${ZDOTDIR:-${HOME}}/.zimrc%b%f" '' ${zusage} return 2 @@ -263,8 +267,11 @@ Initialization options: _zfailed=1 return 1 fi - if (( ! ${#zfpaths} && ! ${#zcmds} )); then + if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then zfpaths=(${zdir}/functions(NF)) + # _* functions are autoloaded by compinit + # prompt_*_setup functions are autoloaded by promptinit + zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t)) local -ra prezto_scripts=(${zdir}/init.zsh(N)) if (( ${#zfpaths} && ${#prezto_scripts} )); then # this follows the prezto module format, no need to check for other scripts @@ -275,11 +282,6 @@ Initialization options: zcmds=("source ${^zscripts[@]:A}") fi fi - if (( ! ${#zfunctions} )); then - # _* functions are autoloaded by compinit - # prompt_*_setup functions are autoloaded by promptinit - zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t)) - fi if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then _zimfw_print -u2 -PRl "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f" '' ${zusage} fi @@ -371,7 +373,7 @@ _zimfw_compile() { } _zimfw_info() { - print -R 'zimfw version: '${_zversion}' (built at 2021-09-23 19:29:01 UTC, previous commit is 6ca4690)' + print -R 'zimfw version: '${_zversion}' (built at 2021-09-27 00:46:27 UTC, previous commit is b1edcf3)' print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'Zsh version: '${ZSH_VERSION} print -R 'System info: '$(command uname -a)