From ae27b672e9bac15f9d1d4d03923580fdd426838a Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 31 Mar 2015 05:06:47 -0400 Subject: [PATCH] themes: add indirection to make "local" work in theme definitions --- plugins/themes/themes.plugin.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/themes/themes.plugin.zsh b/plugins/themes/themes.plugin.zsh index eb3ae6b0e..bc84f39e8 100644 --- a/plugins/themes/themes.plugin.zsh +++ b/plugins/themes/themes.plugin.zsh @@ -70,8 +70,8 @@ function _omz_load_theme_from_file() { values_before[$param]=${(P)param} done - # Actually load the theme - source $file + # Actually load the theme, using an indirection function + _omz_source_theme_file $file # Debugging stuff if [[ $ZSH_THEME_DEBUG == true ]]; then @@ -128,6 +128,14 @@ function _omz_load_theme_from_file() { fi } +# Sources the given file +# The only reason this function exists is to provide a layer of +# indirection so that the theme file runs in its own function call stack frame +# and "local" statements in the theme definitions work as intended. +function _omz_source_theme_file() { + source $1 +} + # Resets all theme settings to their default state # (To the extent that we know what themes do, that is.) # This will reset all variables used by the core OMZ *_prompt_info functions.