From 27a64a16fb5407c64ff190f2af5182797ac048a8 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 2 Dec 2019 01:54:17 +0000 Subject: unposted: vcs_info: Add an example of using $functions to find hooks by name. --- Misc/vcs_info-examples | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Misc/vcs_info-examples') diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index 58dd8cf98..c46fad93a 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -212,6 +212,16 @@ function +vi-git-remotebranch() { } +### Derive hook names dynamically +# With the following line: +zstyle -e ':vcs_info:git+set-message:*' hooks 'reply=( ${${(k)functions[(I)[+]vi-git-set-message*]}#+vi-} )' +# Any function named `+vi-git-set-message-' would be automatically +# registered as a hook. For example: ++vi-git-set-message-foo() {} ++vi-git-set-message-bar() {} +# Both of these functions would be called, even if they are defined after the zstyle is set. + + ### hg: Show marker when the working directory is not on a branch head # This may indicate that running `hg up` will do something # NOTE: the branchheads.cache file is not updated with every Mercurial -- cgit 1.4.1