about summary refs log tree commit diff
path: root/Functions/VCS_Info
diff options
context:
space:
mode:
authorFrank Terbeck <bewater@users.sourceforge.net>2011-03-30 21:13:37 +0000
committerFrank Terbeck <bewater@users.sourceforge.net>2011-03-30 21:13:37 +0000
commitd7bcf2bb96047aa6a00d59885d1343ef4e0db54f (patch)
tree68219ca67c54935f7629e098fd6a076edef6e870 /Functions/VCS_Info
parent15779b019d2f68eedb7ef506f96b87e52a9e46ba (diff)
downloadzsh-d7bcf2bb96047aa6a00d59885d1343ef4e0db54f.tar.gz
zsh-d7bcf2bb96047aa6a00d59885d1343ef4e0db54f.tar.xz
zsh-d7bcf2bb96047aa6a00d59885d1343ef4e0db54f.zip
28958: Support registering hooks independent of the context.
Diffstat (limited to 'Functions/VCS_Info')
-rw-r--r--Functions/VCS_Info/VCS_INFO_hook18
1 files changed, 15 insertions, 3 deletions
diff --git a/Functions/VCS_Info/VCS_INFO_hook b/Functions/VCS_Info/VCS_INFO_hook
index 7274d726f..479f5968b 100644
--- a/Functions/VCS_Info/VCS_INFO_hook
+++ b/Functions/VCS_Info/VCS_INFO_hook
@@ -2,24 +2,36 @@
 ## Written by Frank Terbeck <ft@bewatermyfriend.org>
 ## Distributed under the same BSD-ish license as zsh itself.
 
-local hook func
+local hook static func
 local -x context hook_name
 local -xi ret
-local -a hooks
+local -a hooks tmp
 local -i debug
 
 ret=0
 hook_name="$1"
 shift
 context=":vcs_info:${vcs}+${hook_name}:${usercontext}:${rrn}"
+static=":vcs_info-static_hooks:${hook_name}"
 
 zstyle -t "${context}" debug && debug=1 || debug=0
 if (( debug )); then
     printf 'VCS_INFO_hook: running hook: "%s"\n' "${hook_name}"
     printf 'VCS_INFO_hook: current context: "%s"\n' "${context}"
+    printf 'VCS_INFO_hook: static context: "%s"\n' "${static}"
 fi
 
-zstyle -a "${context}" hooks hooks || return 0
+zstyle -a "${static}" hooks hooks
+if (( debug )); then
+    printf '+ static hooks: %s\n' "${(j:, :)hooks}"
+fi
+zstyle -a "${context}" hooks tmp
+if (( debug )); then
+    printf '+ context hooks: %s\n' "${(j:, :)tmp}"
+fi
+hooks+=( "${tmp[@]}" )
+(( ${#hooks} == 0 )) && return 0
+
 # Protect some internal variables in hooks. The `-g' parameter to
 # typeset does *not* make the parameters global here (they are already
 # "*-local-export). It prevents typeset from creating *new* *local*