Browse files

autoload plugin functions in addition to adding to fpath

  • Loading branch information...
1 parent df79a65 commit 111805992b0cc78ce4e45e2054df10042228d3f6 @rsanders committed Feb 11, 2012
Showing with 33 additions and 2 deletions.
  1. +5 −1 zsh/functions/array~mapformat
  2. +27 −0 zsh/functions/path~glob_in_dirs
  3. +1 −1 zsh/functions/useplugin
View
6 zsh/functions/array~mapformat
@@ -1,6 +1,10 @@
#!/bin/zsh
-# use a format string to transform all the strings in an array - mutating
+# use a format string to transform all the strings in an array -
+# mutating
+#
+# usage: array~mapformat ARRAY_VARNAME FORMATSTRING
+#
function array~mapformat () {
emulate -L zsh
View
27 zsh/functions/path~glob_in_dirs
@@ -0,0 +1,27 @@
+#!/bin/zsh
+
+# given a glob suffix, apply it to an array of pathspecs and
+# glob-expand each, collecting all the results in the 'reply'
+# array.
+#
+# usage: path~glob_in_dirs GLOB PATHSPEC1 [PATHSPEC2 ...]
+#
+# each PATHSPEC may contain globbing characters itself.
+#
+function path~glob_in_dirs () {
+ emulate -L zsh
+ setopt nullglob no_match
+
+ typeset -g -a BASH_COMPLETION_DIRS
+ typeset -a funcpaths
+
+ local glob=$1
+ shift
+ funcpaths=($@)
+
+ array~mapformat funcpaths "%s/$glob"
+ set -A reply ${~funcpaths}
+}
+
+# path~glob_in_dirs '*' "$ZCONFIGDIR/functions" "$DOTTODIR/zsh/plugins/*/functions"
+# echo "reply is ${(j:,:)reply}"
View
2 zsh/functions/useplugin
@@ -25,7 +25,7 @@ function useplugin () {
zctrace "Loading plugin $plugin from $dir"
if [[ -d $dir/functions ]]; then
- fpath=($dir/functions $fpath)
+ dotto~autoload_paths $dir/functions
fi
if [[ -d $dir/completions ]]; then

0 comments on commit 1118059

Please sign in to comment.