about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Base/_arguments20
-rw-r--r--Completion/X/_x_arguments39
-rw-r--r--Completion/X/_xt_arguments72
-rw-r--r--Doc/Zsh/compsys.yo12
5 files changed, 107 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index 36bbfade4..92f25d642 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2001-03-27  Sven Wischnowsky  <wischnow@zsh.org>
 
+	* 13790: Completion/Base/_arguments, Completion/X/_x_arguments,
+	Completion/X/_xt_arguments, Doc/Zsh/compsys.yo: make
+	_arguments return 300 only if given the -R option
+
 	* 13789: Completion/Base/_tilde, Completion/Builtins/_popd:
 	comment out looking up the prefix-needed style when
 	completing directory stack entries; make _tilde use _popd,
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments
index 68a7ba848..913e73895 100644
--- a/Completion/Base/_arguments
+++ b/Completion/Base/_arguments
@@ -4,7 +4,7 @@
 # descriptions given as arguments to this function.
 
 local long cmd="$words[1]" descr mesg subopts opt usecc autod
-local oldcontext="$curcontext" hasopts
+local oldcontext="$curcontext" hasopts rawret
 
 long=$argv[(I)--]
 if (( long )); then
@@ -173,11 +173,12 @@ if (( long )); then
 fi
 
 subopts=()
-while [[ "$1" = -(O*|C) ]]; do
+while [[ "$1" = -(O*|[CR]) ]]; do
   case "$1" in
-  -C) usecc=yes; shift ;;
-  -O) subopts=( "${(@P)2}" ); shift 2 ;;
-  -O*)  subopts=( "${(@P)1[3,-1]}" ); shift ;;
+  -C)  usecc=yes; shift ;;
+  -O)  subopts=( "${(@P)2}" ); shift 2 ;;
+  -O*) subopts=( "${(@P)1[3,-1]}" ); shift ;;
+  -R)  rawret=yes; shift;;
   esac
 done
 
@@ -394,10 +395,11 @@ if (( $# )) && comparguments -i "$autod" "$@"; then
 
   [[ -z "$aret" || -z "$usecc" ]] && curcontext="$oldcontext"
 
-  [[ -n "$aret" ]] && return 300
-
-  [[ -n "$noargs" && nm -eq "$compstate[nmatches]" ]] && _message "$noargs"
-
+  if [[ -n "$aret" ]]; then
+    [[ -n $rawret ]] && return 300
+  else
+    [[ -n "$noargs" && nm -eq "$compstate[nmatches]" ]] && _message "$noargs"
+  fi
   # Set the return value.
 
   [[ nm -ne "$compstate[nmatches]" ]]
diff --git a/Completion/X/_x_arguments b/Completion/X/_x_arguments
index 23243002c..8f1723cc6 100644
--- a/Completion/X/_x_arguments
+++ b/Completion/X/_x_arguments
@@ -1,6 +1,35 @@
-#compdef -P */X11/*
+#compdef -P */X11(|R[456])/*
 
-_arguments \
-  '-display:display:_x_display' \
-  '-geometry:geometry:_x_geometry' \
-  "$@"
+local ret long xargs opts rawret nm="$compstate[nmatches]"
+
+xargs=(
+  '-display:display:_x_display'
+  '-geometry:geometry:_x_geometry'
+)
+
+(( $# )) || xargs=( "$xargs[@]" '*:default: _default' )
+
+long=$argv[(I)--]
+if (( long )); then
+  argv[long]=( "$xargs[@]" -- )
+else
+  set -- "$@" "$xargs[@]"
+fi
+
+opts=()
+while [[ $1 = -(O*|[CR]) ]]; do
+  opts=($opts $1)
+  [[ $1 = -R ]] && rawret=yes
+  shift
+done
+
+_arguments -R "$opts[@]" "$@"
+
+ret=$?
+
+if [[ "$ret" = 300 ]]; then
+  compstate[restore]=''
+  [[ -z $rawret ]] && ret=$(( nm == $compstate[nmatches] ))
+fi
+
+return ret
diff --git a/Completion/X/_xt_arguments b/Completion/X/_xt_arguments
index 02f11e226..e8dafc60c 100644
--- a/Completion/X/_xt_arguments
+++ b/Completion/X/_xt_arguments
@@ -20,26 +20,52 @@
 
 # cf. XrmParseCommand(3X11), X11R6.4/xc/lib/Xt/Initialize.c, X(5)
 
-_arguments \
-  '+rv' '-rv' '-reverse' \
-  '+synchronous' '-synchronous' \
-  '-background:background color:_colors' \
-  '-background:background color:_colors' \
-  '-bd:border color:_colors' \
-  '-bg:background color:_colors' \
-  '-bordercolor:border color:_colors' \
-  '-borderwidth:border width:_x_borderwidth' \
-  '-bw:border width:_x_borderwidth' \
-  '-display:display:_x_display' \
-  '-fg:foreground color:_colors' \
-  '-fn:font:_x_font' \
-  '-foreground:foreground color:_colors' \
-  '-geometry:geometry:_x_geometry' \
-  '-iconic' \
-  '-name:name:_x_name' \
-  '-selectionTimeout:selection timeout (milliseconds):_x_selection_timeout' \
-  '-title:title:_x_title' \
-  '-xnllanguage:locale:_x_locale' \
-  '-xrm:resource:_x_resource' \
-  '-xtsessionID:session ID:_xt_session_id' \
-  "$@"
+local ret long xargs opts rawret nm="$compstate[nmatches]"
+
+xargs=(
+  -+{rv,synchronous}
+  -{reverse,iconic}
+  '-background:background color:_x_color'
+  '-bd:border color:_x_color'
+  '-bg:background color:_x_color'
+  '-bordercolor:border color:_x_color'
+  '-borderwidth:border width:_x_borderwidth'
+  '-bw:border width:_x_borderwidth'
+  '-display:display:_x_display'
+  '-fg:foreground color:_x_color'
+  '-font:font:_x_font'
+  '-fn:font:_x_font'
+  '-foreground:foreground color:_x_color'
+  '-geometry:geometry:_x_geometry'
+  '-name:name:_x_name'
+  '-selectionTimeout:selection timeout (milliseconds):_x_selection_timeout'
+  '-title:title:_x_title'
+  '-xnllanguage:locale:_x_locale'
+  '*-xrm:resource:_x_resource'
+  '-xtsessionID:session ID:_xt_session_id'
+)
+
+long=$argv[(I)--]
+if (( long )); then
+  argv[long]=( "$xargs[@]" -- )
+else
+  set -- "$@" "$xargs[@]"
+fi
+
+opts=()
+while [[ $1 = -(O*|[CR]) ]]; do
+  opts=($opts $1)
+  [[ $1 = -R ]] && rawret=yes
+  shift
+done
+
+_arguments -R "$opts[@]" "$@"
+
+ret=$?
+
+if [[ "$ret" = 300 ]]; then
+  compstate[restore]=''
+  [[ -z $rawret ]] && ret=$(( nm == $compstate[nmatches] ))
+fi
+
+return ret
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index de1c42422..0456ba8c3 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -3070,12 +3070,18 @@ vindex(opt_args, use of)
 An var(action) of the form `tt(->)var(string)' is used by functions
 that implement a state machine. In this case, the `var(string)'s (with
 all leading and trailing spaces and tabs removed) of all actions that
-have to be used will be stored in
-the global array tt(state) and the function returns with a return
+have to be used will be stored in the global array tt(state).  The
+function returns with a non-zero return value if the cursor is not in
+a position where options can be completed or if the current word could 
+not be completed to an option.  But if the tt(-R) option is given to
+tt(_arguments), the function will instead return with a return
 value of 300 (to make it distinguishable from other return values)
 after setting the global `tt(context)', `tt(line)' and `tt(opt_args)'
 parameters as described below, and without resetting any changes made
-to the special parameters such as tt(PREFIX) and tt(words).
+to the special parameters such as tt(PREFIX) and tt(words).  This
+allows to write wrapper functions around tt(_arguments) that have to
+be able to find out if they have to make sure that the special
+completion parameters are not reset when they return.
 
 Note that this means that a function calling tt(_arguments) with at least
 one action containing such a `tt(->)var(string)' has to declare