From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Subject: PATCH: (1/4) vcs_info: Support registering hooks independent of the context
Date: Wed, 30 Mar 2011 22:37:13 +0200 [thread overview]
Message-ID: <1301517436-11451-2-git-send-email-ft@bewatermyfriend.org> (raw)
In-Reply-To: <1301517436-11451-1-git-send-email-ft@bewatermyfriend.org>
---
Functions/VCS_Info/VCS_INFO_hook | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/Functions/VCS_Info/VCS_INFO_hook b/Functions/VCS_Info/VCS_INFO_hook
index 7274d72..479f596 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*
--
1.7.4.1.140.g89781
next prev parent reply other threads:[~2011-03-30 20:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-30 20:37 PATCH: (0/4) Frank Terbeck
2011-03-30 20:37 ` Frank Terbeck [this message]
2011-03-30 20:37 ` PATCH: (2/4) vcs_info: Add functions to add/remove static hooks Frank Terbeck
2011-03-30 20:37 ` PATCH: (3/4) vcs_info: Add `no-vcs' hook Frank Terbeck
2011-03-30 20:37 ` PATCH: (4/4) vcs_info: nvcsformats style should be used if the system is disabled Frank Terbeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1301517436-11451-2-git-send-email-ft@bewatermyfriend.org \
--to=ft@bewatermyfriend.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).