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

Re: PATCH: some small speedups



I wrote:

> ...

Damn, sent the wrong patch, use this one instead, please.

Sorry.

Bye
 Sven

diff -ru ../z.old/Completion/Builtins/_pids Completion/Builtins/_pids
--- ../z.old/Completion/Builtins/_pids	Mon Dec 13 12:47:14 1999
+++ Completion/Builtins/_pids	Mon Dec 13 12:48:20 1999
@@ -3,7 +3,7 @@
 # If given the `-m <pattern>' option, this tries to complete only pids
 # of processes whose command line match the `<pattern>'.
 
-local list expl match desc listargs args
+local out list expl match desc listargs args
 
 _wanted processes expl 'process ID' || return 1
 
@@ -12,12 +12,18 @@
   shift 2
 fi
 
-zstyle -a ":completion${curcontext}:ps" list-arguments listargs
 zstyle -a ":completion${curcontext}:ps" arguments args
-(( $#listargs )) || listargs=( "$args[@]" )
+
+out="$(command ps $args 2>/dev/null)"
 
 if zstyle -t ":completion${curcontext}:processes" verbose; then
-  list=("${(@Mr:COLUMNS-1:)${(f@)$(command ps $listargs 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  zstyle -a ":completion${curcontext}:ps" list-arguments listargs
+  (( $#listargs )) || listargs=( "$args[@]" )
+  if [[ "$listargs" = "$args" ]]; then
+    list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  else
+    list=("${(@Mr:COLUMNS-1:)${(f@)$(command ps $listargs 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  fi
   desc=(-ld list)
 else
   desc=()
diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files
--- ../z.old/Completion/Core/_path_files	Mon Dec 13 12:47:21 1999
+++ Completion/Core/_path_files	Mon Dec 13 12:48:42 1999
@@ -6,7 +6,7 @@
 local linepath realpath donepath prepath testpath exppath
 local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf opre osuf cpre
 local pats haspats=no ignore group expl addpfx addsfx remsfx
-local nm=$compstate[nmatches] menu match matcher mopts
+local nm=$compstate[nmatches] menu match matcher mopts atmp
 
 typeset -U prepaths exppaths
 
@@ -366,12 +366,12 @@
 	fi
       else
         if [[ "$tmp3" = */* ]]; then
+	  atmp=( -Qf "$mopts[@]" -p "$linepath$tmp4"
+	         -W "$prepath$realpath$testpath" "$ignore[@]"
+	         "$addpfx[@]" "$addsfx[@]" "$remsfx[@]"
+                 -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" )
           for i in "$tmp1[@]"; do
-	    compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -s "/${i#*/}" \
-		    -W "$prepath$realpath$testpath" "$ignore[@]" \
-		    "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
-                    -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \
-		    - "${i%%/*}"
+	    compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}"
 	  done
         else
 	  compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \
diff -ru ../z.old/Completion/Core/compinit Completion/Core/compinit
--- ../z.old/Completion/Core/compinit	Mon Dec 13 12:47:21 1999
+++ Completion/Core/compinit	Mon Dec 13 12:50:53 1999
@@ -485,13 +485,13 @@
 
 # Default styles. This should be executed conditionally somehow.
 
-compstyle '*'         verbose       'yes'
-compstyle '*'         prefix-needed 'yes'
-compstyle '*'         prefix-hidden 'no'
-compstyle ':correct'  accept        '2n'
-compstyle ':correct'  prompt        'correct to:'
-compstyle '*'         completer     '_complete'
-compstyle '*:default' list-colors   no=0 fi=0 di=0 ln=0 pi=0 so=0 bd=0 cd=0 ex=0
+zstyle ':completion:*'        verbose       'yes'
+zstyle ':completion:*'        prefix-needed 'yes'
+zstyle ':completion:*'        prefix-hidden 'no'
+zstyle ':completion:correct'  accept        '2n'
+zstyle ':completion:correct'  prompt        'correct to:'
+zstyle ':completion:*'        completer     '_complete'
+zstyle ':completion*:default' list-colors   no=0 fi=0 di=0 ln=0 pi=0 so=0 bd=0 cd=0 ex=0
 
 # Now we automatically make the definition files autoloaded.
 
diff -ru ../z.old/Completion/User/_cvs Completion/User/_cvs
--- ../z.old/Completion/User/_cvs	Mon Dec 13 12:47:25 1999
+++ Completion/User/_cvs	Mon Dec 13 12:48:20 1999
@@ -578,7 +578,7 @@
     omit=(${pref}*(D:t))
     eval 'entries=(${entries:#('${(j:|:)${(@)omit:q}}')})'
     _tags directories && compadd "$@" -P "$qpref" - ${entries:q} ||
-    _cvs_directories "$@"
+        _cvs_directories "$@"
   else
     _files "$@"
   fi
@@ -595,9 +595,9 @@
     omit=($_cvs_ignore_default ${entries:q} ${=cvsignore})
     [[ -r ~/.cvsignore ]] && omit=($omit $(<~/.cvsignore))
     [[ -r ${pref}.cvsignore ]] && omit=($omit $(<${pref}.cvsignore))
-    _files "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' ||
-    _files "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' ||
-    _cvs_directories "$@"
+    _path_files "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' ||
+        _path_files "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' ||
+        _cvs_directories "$@"
   else
     _files "$@"
   fi
diff -ru ../z.old/Completion/User/_pbm Completion/User/_pbm
--- ../z.old/Completion/User/_pbm	Mon Dec 13 12:47:29 1999
+++ Completion/User/_pbm	Mon Dec 13 12:48:21 1999
@@ -21,7 +21,7 @@
     _description files expl 'picture file'
     set -- "$expl[@]"
   fi
-  _files "$@" -g "$pat" || _files "$@" -g '*.(#i)p[bgp]m'
+  _path_files "$@" -g "$pat" || _files "$@" -g '*.(#i)p[bgp]m'
   return
 fi
 
@@ -774,5 +774,5 @@
 
 *)
   _description files expl 'picture file'
-  _files "$expl[@]" -g "$pat" || _files "$expl[@]" -g '*.(#i)p[bgp]m'
+  _path_files "$expl[@]" -g "$pat" || _files "$expl[@]" -g '*.(#i)p[bgp]m'
 esac

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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