about summary refs log tree commit diff
path: root/Completion/X
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/X')
-rw-r--r--Completion/X/_x_colormapid5
-rw-r--r--Completion/X/_x_extension10
-rw-r--r--Completion/X/_x_font15
-rw-r--r--Completion/X/_x_keysym6
-rw-r--r--Completion/X/_x_window13
-rw-r--r--Completion/X/_xmodmap20
-rw-r--r--Completion/X/_xutils42
-rw-r--r--Completion/X/_xwit8
8 files changed, 80 insertions, 39 deletions
diff --git a/Completion/X/_x_colormapid b/Completion/X/_x_colormapid
index 4fe6aac42..3c637c1d9 100644
--- a/Completion/X/_x_colormapid
+++ b/Completion/X/_x_colormapid
@@ -2,7 +2,7 @@
 
 local expl list desc
 
-_wanted colormapids expl 'colormap id' || return 1
+_wanted colormapids || return 1
 
 list=(${(f)"$(xprop -root -f RGB_COLOR_MAP 32xcccccccxx ': $0\n'|awk -F'[ ():]' '/^[a-zA-Z_]+\(RGB_COLOR_MAP\)/ {print $5, "--", $1}')"})
 
@@ -12,4 +12,5 @@ else
   desc=()
 fi
 
-compadd "$expl[@]" "$@" "$desc[@]" - "${(@)list%% *}" 
+_all_labels colormapids expl 'colormap id' \
+    compadd "$@" "$desc[@]" - "${(@)list%% *}" 
diff --git a/Completion/X/_x_extension b/Completion/X/_x_extension
index 967938e28..11e53fa6c 100644
--- a/Completion/X/_x_extension
+++ b/Completion/X/_x_extension
@@ -2,16 +2,18 @@
 
 local expl
 
-(( $+_xe_cache )) || _xe_cache=( "${(@)${(@f)$(xdpyinfo)}[(r)number of extensions:*,-1][2,(r)default screen number:*][1,-2]//[      ]}" )
+_wanted extensions || return 1
 
-_description expl 'X extension'
+(( $+_xe_cache )) || _xe_cache=( "${(@)${(@f)$(xdpyinfo)}[(r)number of extensions:*,-1][2,(r)default screen number:*][1,-2]//[      ]}" )
 
 if [[ "$1" = -a ]]; then
   shift
 
-  compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - all "$_xe_cache[@]"
+  _all_labels extensions expl 'X extensions' \
+      compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - all "$_xe_cache[@]"
 else
   [[ "$1" = - ]] && shift
 
-  compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - "$_xe_cache[@]"
+  _all_labels extensions expl 'X extensions' \
+      compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - "$_xe_cache[@]"
 fi
diff --git a/Completion/X/_x_font b/Completion/X/_x_font
index e0acb4014..43a713b34 100644
--- a/Completion/X/_x_font
+++ b/Completion/X/_x_font
@@ -1,3 +1,16 @@
 #autoload
 
-_message 'font'
+local expl
+
+_wanted fonts || return 1
+
+# This *has* to be improved some day...
+
+if (( ! $+_font_cache )); then
+  typeset -gU _font_cache
+
+ _font_cache=( "${(@)^${(@f)$(_call fonts xlsfonts)}%%--*}--" )
+fi
+
+_all_labels fonts expl font \
+    compadd -M 'r:|-=* r:|=*' "$@" -S '' - "$_font_cache[@]"
diff --git a/Completion/X/_x_keysym b/Completion/X/_x_keysym
index 6b031014a..f50762f7e 100644
--- a/Completion/X/_x_keysym
+++ b/Completion/X/_x_keysym
@@ -2,6 +2,8 @@
 
 local expl
 
+_wanted keysyms || return 1
+
 if (( ! $+_keysym_cache )); then
   local file
 
@@ -16,5 +18,5 @@ if (( ! $+_keysym_cache )); then
   fi
 fi
 
-_description expl 'key symbol'
-compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - $_keysym_cache
+_all_labels keysyms expl 'key symbol' \
+    compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - $_keysym_cache
diff --git a/Completion/X/_x_window b/Completion/X/_x_window
index 118c7f131..1862db9a7 100644
--- a/Completion/X/_x_window
+++ b/Completion/X/_x_window
@@ -1,19 +1,18 @@
 #autoload
 
-setopt localoptions extendedglob
-
 local list expl
 
-list=( "${(@)${(M@)${(@f)$(xwininfo -root -tree)}:#[ 	]#0x[0-9a-f]# \"*}##[ 	]#}" )
+_wanted windows || return 1
+
+list=( "${(@)${(M@)${(@f)$(_call windows xwininfo -root -tree)}:#[ 	]#0x[0-9a-f]# \"*}##[ 	]#}" )
 
 if [[ "$1" = -n ]]; then
   shift
 
-  _description expl 'window name'
-  compadd "$@" "$expl[@]" -d list - "${(@)${(@)list#*\"}%%\"*}"
+  _all_labels windows expl 'window name' \
+      compadd "$@" -d list - "${(@)${(@)list#*\"}%%\"*}"
 else
   [[ "$1" = - ]] && shift
 
-  _description expl 'window ID'
-  compadd "$@" "$expl[@]" -d list - "${(@)list%% *}"
+  _all_labels windows expl 'window ID' compadd "$@" -d list - "${(@)list%% *}"
 fi
diff --git a/Completion/X/_xmodmap b/Completion/X/_xmodmap
index 0f6514eb6..1cd461d4c 100644
--- a/Completion/X/_xmodmap
+++ b/Completion/X/_xmodmap
@@ -1,11 +1,9 @@
 #compdef xmodmap
 
-setopt localoptions extendedglob
+local curcontext="$curcontext" state line ret=1
+typeset -A opt_args
 
-local state line ret=1
-typeset -A options
-
-_x_arguments \
+_x_arguments -C \
   -{help,grammar,verbose,quiet} \
   '-n[only show what would be done]' \
   '*-e[specify expression]:expression:->expr' \
@@ -57,7 +55,7 @@ if [[ -n "$state" ]]; then
     pointer*)
       if compset -P '*=[ 	]#'; then
         compset -P '*[ 	]'
-        _description expl 'button code'
+        _description values expl 'button code'
         compadd "$expl[@]" -qS ' ' 1 2 3 4 5 default
         return
       else
@@ -84,9 +82,13 @@ if [[ -n "$state" ]]; then
     [[ "$what" = *ksym* ]] && _x_keysym "$suf[@]" && ret=0
 
   else
-    _description expl command
-    compadd "$expl[@]" -S ' ' keycode keysym clear add remove && ret=0
-    compadd "$expl[@]" -S ' = ' pointer && ret=0
+    if _wanted commands; then
+      while _next_label commands expl command; do
+        compadd "$expl[@]" -S ' ' keycode keysym clear add remove && ret=0
+        compadd "$expl[@]" -S ' = ' pointer && ret=0
+        (( ret )) || return 0
+      done
+    fi
   fi
 fi
 
diff --git a/Completion/X/_xutils b/Completion/X/_xutils
index 1818b447f..4eea8ded1 100644
--- a/Completion/X/_xutils
+++ b/Completion/X/_xutils
@@ -8,7 +8,7 @@ xdpyinfo)
   ;;
 xwininfo)
   _x_arguments \
-    -{help,int,stats,bits,events,size,wm,shape,frame,all,english,metric} \
+    -{help,int,children,tree,stats,bits,events,size,wm,shape,frame,all,english,metric} \
     '(-id -name)-root' \
     '(-id -root)-name:name: _x_window -n' \
     '(-name -root)-id:id: _x_window'
@@ -46,12 +46,33 @@ xev)
     '-rv'
   ;;
 xhost)
-  local expl type ret=1
+  local expl type ret=1 tmp
 
   if compset -P '-'; then
-    _description expl 'disallow access'
-    compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' - \
-        "${${(@M)${(@f)$(xhost)}[2,-1]:#LOCAL:*}#INET:}"
+    tmp=(${(f)"$(xhost)"})
+    shift tmp
+    tmp=(${tmp:#LOCAL:|<*>})
+    if [[ "$tmp" = *:* ]]; then
+      if compset -P '(#b)(*):'; then
+	type="$match[1]"
+	_wanted displays &&
+            while _next_label displays expl 'disallow access'; do
+	      { compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' - \
+		        ${${(M)tmp:#(#i)$type:*}#(#i)$type:} ||
+	            _hosts "$expl[@]" } && return 0
+	    done
+      else
+	_alternative \
+	    'types:name family:compadd -S: ${(L)tmp%%:*}' \
+	    'hosts:host:compadd ${(@)tmp#*:}' && ret=0
+      fi
+    else
+      _wanted displays &&
+          while _next_label displays expl 'disallow access'; do
+	    { compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' - $tmp ||
+              _hosts "$expl[@]" } && return 0
+          done
+    fi
   else
     compset -P +
 
@@ -66,9 +87,9 @@ xhost)
       krb)  _message 'Kerberos V5 principal';;
       esac
     else
-      _description expl 'name family'
-      compadd -S: - inet dnet nis krb && ret=0
-      _hosts && ret=0
+      _alternative \
+          'types:name family:compadd -S: - inet dnet nis krb' \
+	  'hosts:: _hosts' && ret=0
     fi
     return ret
   fi
@@ -120,7 +141,7 @@ xrdb)
     '(-global -all -screens)-screen' \
     '(-global -all -screen)-screens' \
     '-n[only display on stdout]' \
-    '(-nocpp)-cpp:preprocessor program:_files -g \*\(\*\)' \
+    '(-nocpp)-cpp:preprocessor program:_files -g \*\(-\*\)' \
     '(-cpp)-nocpp' \
     '(-load -override -merge -remove)-query' \
     '(-query -override -merge -remove)-load' \
@@ -131,6 +152,7 @@ xrdb)
     '-backup:backup extension:' \
     '*-D-:symbol to define:' \
     '*-U-:symbol to undefine:' \
-    '*-I-:include directory:_files -/'
+    '*-I-:include directory:_files -/' \
+    '*:defaults file:_files'
   ;;
 esac
diff --git a/Completion/X/_xwit b/Completion/X/_xwit
index e86443a32..998627869 100644
--- a/Completion/X/_xwit
+++ b/Completion/X/_xwit
@@ -16,8 +16,8 @@ _xwit_guard () {
 
 _xwit_compopts () {
   local expl
-  _description options expl option
-  compadd "$expl[@]" - ${(k)no[(R)*~0]} || compadd "$expl[@]" - ${(k)no}
+  _wanted options expl option compadd - ${(k)no[(R)*~0]} ||
+      _all_labels options expl option compadd - ${(k)no}
 }
 
 _regex_arguments _xwit_parse \
@@ -39,8 +39,8 @@ _regex_arguments _xwit_parse \
     \| "/iconmove$nul/" "$guard" "/$word/" ":_message x" "/$word/" ":_message y" \
     \| "/id$nul/" "$guard" "/$word/" ":_x_window" \
     \| "/(no|)keyrepeat$nul/" "$guard" \
-        \( "/[0-9]##$nul/" ":_message keycode" \
-	  \( "/-$nul/" "/[0-9]##$nul/" ":_message 'last keycode'" \| \) \) \# \
+        \( "/[0-9]##$nul/" ":[[ -prefix [0-9]# ]] && _message keycode" \
+	  \( "/-$nul/" "/[0-9]##$nul/" ":[[ -prefix [0-9]# ]] && _message 'last keycode'" \| \) \) \# \
     \| "/names$nul/" "$guard" "/$word/" ":_x_window -n" \# \
     \| "/[]/" ':_xwit_compopts' \
     \) \