about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-04-23 17:11:39 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-04-23 17:11:39 +0000
commit817b5a142c85a094079692b457c743db05ab0e27 (patch)
tree07a76745bbb2cba11a248ac4444e41176618de67
parent63442b3eaa58d5fd140306bd2ce85dd994284889 (diff)
downloadzsh-817b5a142c85a094079692b457c743db05ab0e27.tar.gz
zsh-817b5a142c85a094079692b457c743db05ab0e27.tar.xz
zsh-817b5a142c85a094079692b457c743db05ab0e27.zip
19825: add changes style
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Unix/Command/_perforce11
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 720cd1804..8c48d3129 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-04-23  Peter Stephenson  <pws@csr.com>
 
+	* 19825: Completion/Unix/Command/_perforce: suggested by Michael
+	Denio: add `changes' style to allow limitting list of changes
+	offered for completion.
+
 	* 19810: Src/exec.c: avoid setting flag on Eprog which may
 	no longer be valid.  Had no feedback, so don't know if
 	it helps, but at worst harmless.
diff --git a/Completion/Unix/Command/_perforce b/Completion/Unix/Command/_perforce
index e77267b45..7083470d6 100644
--- a/Completion/Unix/Command/_perforce
+++ b/Completion/Unix/Command/_perforce
@@ -47,6 +47,12 @@
 #   p4 jobs -e 'user=pws'
 # i.e. those assigned to Perforce user `pws'.
 #
+# Completion of changes can be controlled by the `changes' style.
+# This takes additional arguments to be passed to `p4 changes'.
+# An obvious example is:
+#   zstyle ':completion:*:p4-*:changes' changes -u $USER
+# to limit changes to the present user.
+#
 # The style `all-files' is used to tell the completion system to
 # complete any file in a given context.  This is for use in places
 # where it would, for example, only complete files opened for editing.
@@ -495,9 +501,10 @@ _perforce_branches() {
 (( $+functions[_perforce_changes] )) ||
 _perforce_changes() {
   local cline match mbegin mend max ctype num comma file
-  local -a cl cstatus amax
+  local -a cl cstatus amax xargs
 
   zstyle -s ":completion:${curcontext}:changes" max max || max=20
+  zstyle -a ":completion:${curcontext}:changes" changes xargs
   if [[ ${NUMERIC:-0} -lt 0 && -z $compstate[insert] ]]; then
     # Not inserting (i.e. just listing) and given a negative
     # prefix argument.  Instead of listing possible completions,
@@ -548,7 +555,7 @@ _perforce_changes() {
   # Limit to the 20 most recent changes by default to avoid huge
   # output.
   cl=(
-${${${${(f)"$(_perforce_call_p4 changes changes $amax $cstatus \$file)"}##Change\ }//\ on\ /:}/\ by\ /\ }
+${${${${(f)"$(_perforce_call_p4 changes changes $amax $xargs $cstatus \$file)"}##Change\ }//\ on\ /:}/\ by\ /\ }
 "default:change not yet numbered")
   [[ $#cl -eq 1 && $cl[1] = '' ]] && cl=()
   _describe -t changes "${ctype}change" cl -V changes-unsorted $comma