From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27360 invoked by alias); 21 Feb 2010 14:59:46 -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: 27731 Received: (qmail 6608 invoked from network); 21 Feb 2010 14:59:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.2.5 Received-SPF: none (ns1.primenet.com.au: domain at bewatermyfriend.org does not designate permitted sender hosts) From: Frank Terbeck To: zsh-workers@zsh.org Subject: PATCH: vcs_info: Set NO_warn_create_global option Date: Sun, 21 Feb 2010 15:53:24 +0100 Message-Id: <1266764004-15068-1-git-send-email-ft@bewatermyfriend.org> X-Mailer: git-send-email 1.7.0 X-Df-Sender: 430444 I wanted to do the following, because I'd like to have `check-for-changes' set in my own project directories, but not in others, I just check out (because it can be slow for big repos): function estyle-cfc() { local d local -a cfc_dirs cfc_dirs=( ${HOME}/src/code/*(/) ) for d in ${cfc_dirs}; do d=${d%/##} [[ $PWD == $d(|/*) ]] && return 0 done return 1 } zstyle -e ':vcs_info:git:*' \ check-for-changes 'estyle-cfc && reply=( true ) || reply=( false )' That however, welcomes me with this nice warning: VCS_INFO_get_data_git:49: array parameter reply created globally in function In theory the above should work (and it does except for the warning). It also works in compsys, where I'm using this: zstyle -e ':completion:*:approximate:*' \ max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) )' What compsys does is, it disables the warn_create_global option while it's running. While I like what the option does (prevent me from cluttering the shell with all sorts of variables if I forget `local'), I still want to be able to use `-e' with zstyle. So, there are three options: a) Get the big hammer and just disable `warn_create_global' in vcs_info. b) Use a smaller hammer, and create a wrapper function around zstyle for vcs_info, that disables the option locally. c) Disable `warn_create_global' in code executed by "zstyle -e". Or make `reply' and `REPLY' special in that case. Or whatever makes the most sense. This patch does what "a)" suggests, basically because it works and I was lazy. I think "c)" would be the cleanest solution, but I don't know if that's doable and I haven't looked at the involved code yet. I might implement "b)" at a later date if "c)" is not feasilbe with reasonable effort. Regards, Frank --- Functions/VCS_Info/vcs_info | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index 906d984..a9e65e1 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -40,7 +40,7 @@ vcs_info_setsys # and now, finally create the real vcs_info function vcs_info () { emulate -L zsh - setopt extendedglob + setopt extendedglob NO_warn_create_global [[ -r . ]] || return 0 -- 1.7.0