Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: better control for _cd



This makes _cd use the tags local-directories and path-directories to
decide if those in the cwd and/or those in $cdpath should be
completed.

I.e. you can put in your _sort_tags:

  *::cd:*)
      comptry local-directories
      comptry path-directories
      ;;

to first complete only the directories in $PWD and the ones in $cdpath 
only if that fails.

Bye
 Sven

diff -u -r oldcompletion/Builtins/_cd Completion/Builtins/_cd
--- oldcompletion/Builtins/_cd	Fri Dec  3 10:22:05 1999
+++ Completion/Builtins/_cd	Fri Dec  3 14:07:02 1999
@@ -33,11 +33,13 @@
   # Note we need a tilde because cdablevars also allows user home
   # directories, hence we also need nonomatch to suppress error messages.
   if [[ -o cdablevars && -n "$PREFIX" && ! -d ${tdir::=${PREFIX%%/*}} &&
-    -d ${~tdir2::="~$tdir"} ]]; then
+        -d ${~tdir2::="~$tdir"} ]]; then
       PREFIX="~$PREFIX"
       _path_files -/
   else
-    _path_files -W "(. $cdpath)" -/
+    _alternative \
+        'local-directories:local directories:_path_files -/' \
+	'path-directories: directories in cdpath:_path_files -W \(${cdpath:#.}\) -/'
   fi
 else
   _path_files -/
diff -u olddoc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- olddoc/Zsh/compsys.yo	Fri Dec  3 10:21:51 1999
+++ Doc/Zsh/compsys.yo	Fri Dec  3 14:09:05 1999
@@ -622,6 +622,10 @@
 item(tt(keysyms))(
 for names of X keysyms
 )
+item(tt(local-directories))(
+for names of directories in the current working directory when
+completing for the tt(cd) builtin command
+)
 item(tt(libraries))(
 for names of system libraries
 )
@@ -666,6 +670,10 @@
 )
 item(tt(parameters))(
 for names of parameters
+)
+item(tt(path-directories))(
+for names of directories in directories from the tt(cdpath) array when
+completing for the tt(cd) builtin command
 )
 item(tt(paths))(
 used to look up the values of the tt(expand) and tt(cursor) styles

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author