summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Zsh/Context/_dynamic_directory_name10
-rw-r--r--Doc/Zsh/expn.yo20
3 files changed, 29 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 03a69a846..135846f30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2010-06-11 Peter Stephenson <p.w.stephenson@ntlworld.com>
+ * 28026: Completion/Zsh/Context/_dynamic_directory_name,
+ Doc/Zsh/expn.yo: use "zsh_directory_name c" for completion
+ of dynamic directory names.
+
* 28025: Doc/Zsh/expn.yo, Src/subst.c, Src/utils.c: (D)
parameter flag to abbreviate directories.
@@ -13272,5 +13276,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4998 $
+* $Revision: 1.4999 $
*****************************************************
diff --git a/Completion/Zsh/Context/_dynamic_directory_name b/Completion/Zsh/Context/_dynamic_directory_name
index 85f8ff2ee..5f7fe9a90 100644
--- a/Completion/Zsh/Context/_dynamic_directory_name
+++ b/Completion/Zsh/Context/_dynamic_directory_name
@@ -1,7 +1,7 @@
#autoload
-# The core libraries don't check for dynamic directory name expansion;
-# this gets called from _subscript. This is a placeholder for
-# people to overload.
-
-_message 'dynamic directory name: redefine _dynamic_directory_name to use'
+if [[ -n $functions[zsh_directory_name] ]]; then
+ zsh_directory_name c
+else
+ _message 'dynamic directory name: implemented as zsh_directory_name c'
+fi
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 83a195def..b2a2b59f0 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -1451,6 +1451,12 @@ parts of the directory path, as described below; it is used if the prefix
length matched (16 in the example) is longer than that matched by any
static name.
+The completion system calls `tt(zsh_directory_name c)' in order to
+completion dynamic names for directories. The code for this should be
+as for any other completion function as described in
+ifnzman(noderef(Completion System))\
+ifzman(zmanref(zshcompsys)).
+
As a working example, here is a function that expands any dynamic names
beginning with the string tt(p:) to directories below
tt(/home/pws/perforce). In this simple case a static name for the
@@ -1461,16 +1467,28 @@ example(zsh_directory_name+LPAR()RPAR() {
setopt extendedglob
local -a match mbegin mend
if [[ $1 = d ]]; then
+ # turn the directory into a name
if [[ $2 = (#b)(/home/pws/perforce/)([^/]##)* ]]; then
typeset -ga reply
reply=(p:$match[2] $(( ${#match[1]} + ${#match[2]} )) )
else
return 1
fi
- else
+ elif [[ $1 = n ]]; then
+ # turn the name into a directory
[[ $2 != (#b)p:(?*) ]] && return 1
typeset -ga reply
reply=(/home/pws/perforce/$match[1])
+ elif [[ $1 = c ]]; then
+ # complete names
+ local expl
+ local -a dirs
+ dirs=(/home/pws/perforce/*(/:t))
+ dirs=(p:${^dirs})
+ _wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs
+ return
+ else
+ return 1
fi
return 0
})