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

Re: _perforce completer



Michael Denio wrote:
> > Note that it should use styles to be sufficiently general.  Something
> > similar to the jobview style would be appropriate:
> 
> It does.  Here is my zstyle line from .zshrc
> 
> zstyle ':completion:*:changes' current_user true
> 
> I user the value of $USER thinking it was more appropriate.  If you like 
> I could change it so the user name has to be specified.

This is perfectly workable, but on the whole I'm inclined to prefer my
proposal to avoid accumulating ever new arguments.

Now you need to do:

zstyle ':completion:*:changes' changes -u $USER

Is this OK?

Index: Completion/Unix/Command/_perforce
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_perforce,v
retrieving revision 1.18
diff -u -r1.18 _perforce
--- Completion/Unix/Command/_perforce	11 Nov 2003 10:35:55 -0000	1.18
+++ Completion/Unix/Command/_perforce	23 Apr 2004 16:21:09 -0000
@@ -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 @@
 (( $+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 @@
   # 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

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



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