about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-10-05 11:56:56 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-10-05 11:56:56 +0000
commit4bf4818f5a4ffc04f98c796c8b44dd7472fc771b (patch)
tree068be29e8aa41431091a9e4a4da15471966e7410
parent22d506ed6b0a9ef5b9dba6fa81d74182ca890ff0 (diff)
downloadzsh-4bf4818f5a4ffc04f98c796c8b44dd7472fc771b.tar.gz
zsh-4bf4818f5a4ffc04f98c796c8b44dd7472fc771b.tar.xz
zsh-4bf4818f5a4ffc04f98c796c8b44dd7472fc771b.zip
make _cd use only one call to _alternative, including completions from _tilde (using the named-directories tag) (15945)
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Zsh/Command/_cd32
2 files changed, 20 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 79124f326..8ba7c2e18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2001-10-05  Sven Wischnowsky  <wischnow@zsh.org>
 
+	* 15945: Completion/Zsh/Command/_cd: make _cd use only one call
+	to _alternative, including completions from _tilde (using the
+	named-directories tag)
+
 	* 15944: Completion/Unix/Type/_path_files, Doc/Zsh/compsys.yo:
 	make expand style (file completion) work again; no more special
 	behaviour with menu completion; try to make docs clearer
diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd
index 3a536cb7b..384fe2d66 100644
--- a/Completion/Zsh/Command/_cd
+++ b/Completion/Zsh/Command/_cd
@@ -32,13 +32,17 @@ else
   fi
 
   if [[ $PREFIX != (\~|/|./|../)* ]]; then
-    local tmpcdpath
+    local tmpcdpath alt
+
     tmpcdpath=(${${(@)cdpath:#.}:#$PWD})
 
+    (( $#tmpcdpath )) &&
+      alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' )
+
     # With cdablevars, we can complete foo as if ~foo/
     if [[ -o cdablevars && -n "$PREFIX" && "$PREFIX" != <-> ]]; then
       if [[ "$PREFIX" != */* ]]; then
-        _tilde && ret=0
+        alt=( "$alt[@]" 'named-directories: : _tilde' )
       else
         local oipre="$IPREFIX" opre="$PREFIX" dirpre dir
 
@@ -51,26 +55,22 @@ else
         PREFIX="${PREFIX#*/}"
 
         [[ $#dir -eq 1 && "$dir[1]" != "~$dirpre" ]] &&
-          _wanted named-directories expl 'directories after cdablevar' \
+          _wanted named-directories expl 'directory after cdablevar' \
 	      _path_files -W dir -/ && ret=0
 
         PREFIX="$opre"
         IPREFIX="$oipre"
       fi
     fi
-    if [[ $#tmpcdpath -ne 0 ]]; then
-      # Don't complete local directories in command position, that's
-      # already handled by _command_names (see _autocd)
-      if [[ CURRENT -eq 1 ]]; then
-	_wanted path-directories expl 'directories in cdpath' \
-	  _path_files -W tmpcdpath -/ && ret=0
-      else
-        _alternative \
-	  'local-directories:local directories:_path_files -/' \
-	  "path-directories:directories in cdpath:_path_files -W tmpcdpath -/" && ret=0
-      fi
-      return ret
-    fi
+    # Don't complete local directories in command position, that's
+    # already handled by _command_names (see _autocd)
+
+    [[ CURRENT -ne 1 ]] &&
+        alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files -/" "$alt[@]" )
+
+    _alternative "$alt[@]" && ret=0
+
+    return ret
   fi
   _wanted directories expl directory _path_files -/ && ret=0