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

PATCH: completion in vared



I thought about this again... this adds the (completely shell-code
based) special context `-vared-' and the function _in_vared to handle
completion there.

It also makes the insert-tab style default to `false' in vared. Hope
that's OK for everyone.

Bye
 Sven

Index: Completion/Base/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/.distfiles,v
retrieving revision 1.2
diff -u -r1.2 .distfiles
--- Completion/Base/.distfiles	2000/04/25 09:48:09	1.2
+++ Completion/Base/.distfiles	2000/05/15 13:14:59
@@ -1,7 +1,7 @@
 DISTFILES_SRC='
     .distfiles 
     _arg_compile _argument_sets _arguments _brace_parameter _combination
-    _command_names _condition _default _describe _equal _first _jobs _math
-    _parameter _precommand _redirect _regex_arguments _subscript _tilde
-    _value _values
+    _command_names _condition _default _describe _equal _first _in_vared
+    _jobs _math _parameter _precommand _redirect _regex_arguments _subscript
+    _tilde _value _values
 '
Index: Completion/Base/_in_vared
===================================================================
RCS file: _in_vared
diff -N _in_vared
--- /dev/null	Tue May  5 13:32:27 1998
+++ _in_vared	Mon May 15 06:14:59 2000
@@ -0,0 +1,28 @@
+#compdef -vared-
+
+local also
+
+# Completion inside vared.
+
+if [[ $compstate[vared] = *\[* ]]; then
+  # vared on an array-element
+  compstate[parameter]=${compstate[vared]%%\[*}
+  compstate[context]=-value-
+  also=value
+else
+  # vared on a parameter, let's see if it is an array
+  compstate[parameter]=$compstate[vared]
+  if [[ ${(tP)compstate[vared]} = *(array|assoc)* ]]; then
+    compstate[context]=array_value
+    also=-array-value-
+  else
+    compstate[context]=value
+    also=-value-
+  fi
+fi
+
+# Don't insert TAB in first column. Never.
+
+compstate[insert]="${compstate[insert]//tab /}"
+
+_compalso "$also"
Index: Completion/Core/_compalso
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_compalso,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 _compalso
--- Completion/Core/_compalso	1999/04/15 18:26:38	1.1.1.4
+++ Completion/Core/_compalso	2000/05/15 13:14:59
@@ -7,11 +7,11 @@
 # `_compalso -math-' to get the completions that would be generated for a
 # mathematical context.
 
-local i tmp
+local i tmp ret=1
 
 for i; do
   tmp="$_comps[$1]"
-  [[ -z "$tmp" ]] || "$tmp" && return 0
+  [[ -z "$tmp" ]] || "$tmp" && ret=0
 done
 
-return 1
+return ret
Index: Completion/Core/_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_complete,v
retrieving revision 1.3
diff -u -r1.3 _complete
--- Completion/Core/_complete	2000/05/02 08:18:54	1.3
+++ Completion/Core/_complete	2000/05/15 13:15:00
@@ -36,21 +36,7 @@
 # If we are inside `vared' and we don't have a $compcontext, we treat
 # this like a parameter assignment. Which it is.
 
-if [[ -n $compstate[vared] ]]; then
-  if [[ $compstate[vared] = *\[* ]]; then
-    # vared on an array-element
-    compstate[parameter]=${compstate[vared]%%\[*}
-    compstate[context]=value
-  else
-    # vared on a parameter, let's see if it is an array
-    compstate[parameter]=$compstate[vared]
-    if [[ ${(tP)compstate[vared]} = *(array|assoc)* ]]; then
-      compstate[context]=array_value
-    else
-      compstate[context]=value
-    fi
-  fi
-fi
+[[ -n $compstate[vared] ]] && compstate[context]=vared
 
 # For arguments and command names we use the `_normal' function.
 
Index: Completion/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v
retrieving revision 1.17
diff -u -r1.17 _main_complete
--- Completion/Core/_main_complete	2000/05/11 08:40:10	1.17
+++ Completion/Core/_main_complete	2000/05/15 13:15:00
@@ -35,8 +35,10 @@
 
 [[ -z "$curcontext" ]] && curcontext=:::
 
-if [[ "$compstate[insert]" = tab* ]]; then
-  zstyle -T ":completion:${curcontext}:" insert-tab && return 1
+if [[ "$compstate[insert]" = tab* && "$WIDGET" != *list* ]]; then
+  { zstyle -T ":completion:${curcontext}:" insert-tab &&
+    { [[ "$curcontext" != :* || -z "$compstate[vared]" ]] ||
+        zstyle -t ":completion:vared${curcontext}:" insert-tab } } && return 1
 
   compstate[insert]="${compstate[insert]//tab /}"
 fi
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.46
diff -u -r1.46 compsys.yo
--- Doc/Zsh/compsys.yo	2000/05/14 22:08:41	1.46
+++ Doc/Zsh/compsys.yo	2000/05/15 13:15:04
@@ -1258,7 +1258,8 @@
 (i.e. when there is no non-blank character to the left of the cursor
 yet). If set to `false', completion will be done even there.
 
-The default value of this style is `true'.
+The default value of this style is `true' unless when completing
+inside the tt(vared) builtin command, where it defaults to `false'.
 )
 kindex(insert-unambiguous, completion style)
 item(tt(insert-unambiguous))(

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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