about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/_describe4
-rw-r--r--Completion/Base/_values6
-rw-r--r--Completion/Builtins/_kill17
-rw-r--r--Completion/Builtins/_pids18
-rw-r--r--Completion/Builtins/_wait12
-rw-r--r--Completion/Core/_tags17
-rw-r--r--Completion/User/_gdb24
7 files changed, 52 insertions, 46 deletions
diff --git a/Completion/Base/_describe b/Completion/Base/_describe
index 29997e262..ddd35f0e7 100644
--- a/Completion/Base/_describe
+++ b/Completion/Base/_describe
@@ -23,9 +23,7 @@ shift OPTIND-1
 
 # Do the tests. `showd' is set if the descriptions should be shown.
 
-_tags -c "$cmd" -f "$func" "$type"
-
-_tags || return 1
+_tags -i -c "$cmd" -f "$func" "$type" || return 1
 
 [[ "$tags" = *:${type}\[*describe*\]* ]] && showd=yes
 
diff --git a/Completion/Base/_values b/Completion/Base/_values
index 5c2249929..9d89c7ea9 100644
--- a/Completion/Base/_values
+++ b/Completion/Base/_values
@@ -6,8 +6,7 @@ if compvalues -i "$@"; then
 
   if ! compvalues -D descr action; then
 
-    _tags value
-    _tags || return 1
+    _tags -i value || return 1
 
     compvalues -V noargs args opts
 
@@ -52,8 +51,7 @@ if compvalues -i "$@"; then
     fi
   fi
 
-  _tags argument
-  _tags || return 1
+  _tags -i argument || return 1
 
   _description expl "$descr"
 
diff --git a/Completion/Builtins/_kill b/Completion/Builtins/_kill
index b4fa5fb88..bb198b7a4 100644
--- a/Completion/Builtins/_kill
+++ b/Completion/Builtins/_kill
@@ -1,24 +1,21 @@
 #compdef kill
 
-local list expl
+local tags list expl
 
 if compset -P 1 -; then
+
+  _tags -i signal || return 1
+
   _description expl signal
   compadd "$expl[@]" $signals[1,-3]
 else
-  local tags ret=1
+  local ret=1
   
   _tags job process
   
   while _tags; do
-    [[ "$tags" = *:job:* ]] && _jobs && ret=0
-    if [[ "$tags" = *:process:* ]]; then
-      list=("${(@M)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*}")
-      _description expl 'process ID'
-      compadd "$expl[@]" -ld list - \
-        ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} &&
-          ret=0
-    fi
+    [[ "$tags" = *:job:*     ]] && _jobs && ret=0
+    [[ "$tags" = *:process:* ]] && _pids && ret=0
     (( ret )) || break
   done
 
diff --git a/Completion/Builtins/_pids b/Completion/Builtins/_pids
new file mode 100644
index 000000000..0ffda900b
--- /dev/null
+++ b/Completion/Builtins/_pids
@@ -0,0 +1,18 @@
+#autoload
+
+# If given the `-m <pattern>' option, this tries to complete only pids
+# of processes whose command line match the `<pattern>'.
+
+local list expl match
+
+if [[ "$1" = -m ]]; then
+  match="${2}*"
+  shift 2
+fi
+
+_description expl 'process ID'
+
+list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+
+compadd "$expl[@]" "$@" -ld list - \
+  ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]:#*${~match}}## #}%% *}
diff --git a/Completion/Builtins/_wait b/Completion/Builtins/_wait
index 0b58367f1..b03aac6e0 100644
--- a/Completion/Builtins/_wait
+++ b/Completion/Builtins/_wait
@@ -1,18 +1,12 @@
 #compdef wait
 
-local tags list ret=1 expl
+local tags ret=1
   
 _tags job process
   
 while _tags; do
-  [[ "$tags" = *:job:* ]] && _jobs && ret=0
-  if [[ "$tags" = *:process:* ]]; then
-    list=("${(@M)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*}")
-    _description expl 'process ID'
-    compadd "$expl[@]" -ld list - \
-      ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} &&
-        ret=0
-  fi
+  [[ "$tags" = *:job:*     ]] && _jobs && ret=0
+  [[ "$tags" = *:process:* ]] && _pids && ret=0
   (( ret )) || break
 done
 
diff --git a/Completion/Core/_tags b/Completion/Core/_tags
index f6a7fdc11..6517c78ea 100644
--- a/Completion/Core/_tags
+++ b/Completion/Core/_tags
@@ -2,13 +2,14 @@
 
 if (( $# )); then
   local cmd="$words[1]" func="$funcstack[2]" defs i tags tag pat style prio
-
-  while getopts 'c:f:' i; do
-    if [[ "$i" = c ]]; then
-      cmd="$OPTARG"
-    else
-      func="$OPTARG"
-    fi
+  local trynow
+
+  while getopts 'c:f:i' i; do
+    case "$i" in
+    c) cmd="$OPTARG"  ;;
+    f) func="$OPTARG" ;;
+    i) trynow=yes     ;;
+    esac
   done
 
   shift OPTIND-1
@@ -67,7 +68,7 @@ if (( $# )); then
   _prio_names[$funcstack]="$prio"
   eval "${prio}=( \"\${(@)tags:#}\" )"
 
-  return 0
+  [[ -z "$trynow" ]] && return 0
 fi
 
 local prios="$_prio_names[$funcstack]"
diff --git a/Completion/User/_gdb b/Completion/User/_gdb
index 22242caff..dab301b39 100644
--- a/Completion/User/_gdb
+++ b/Completion/User/_gdb
@@ -21,20 +21,22 @@ elif [[ "$PREFIX" = -* ]]; then
   _description expl option
   compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \
                               -directory\= -cd\= -tty\=
-  compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q -batch \
-                       -fullname -f -b
+  compadd "$expl[@]"        - -help -h -s -e -c -x -d -nx -n -quiet -q \
+			      -batch -fullname -f -b
 else
   prev="$words[CURRENT-1]"
 
   case "$prev" in
-  (-d) _files -/ && return 0 ;;
+  (-d)     _files -/ && return 0 ;;
   (-[csx]) _files && return 0 ;;
-  (-e) _description expl executable
-       _files "$expl[@]" -g '*(*)' && return 0 ;;
-  (-b) _description -V expl 'baud rate'
-       compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \
-                          9600 19200 38400 57600 115200 230400 && return 0 ;;
+  (-e)     _description expl executable
+           _files "$expl[@]" -g '*(*)' && return 0 ;;
+  (-b)     _description -V expl 'baud rate'
+           compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 \
+			      2400 4800 9600 19200 38400 57600 115200 \
+			      230400 && return 0 ;;
   esac
+
   w=( "${(@)words[2,-1]}" )
   while [[ "$w[1]" = -* ]]; do
     [[ "$w[1]" = -[decsxb] ]] && shift 1 w
@@ -42,10 +44,8 @@ else
   done
 
   if [[ $#w -gt 1 ]]; then
-    _files && ret=0
-    _description expl 'process ID'
-    list=("${(@M)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${w[1]:t}*}")
-    compadd "$expl[@]" -ld list - ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0
+    _files               && ret=0
+    _pids -m "${w[1]:t}" && ret=0
 
     return ret
   else