zsh-workers
 help / color / mirror / code / Atom feed
* _perforce completer
@ 2004-04-23 15:41 Michael Denio
  2004-04-23 15:48 ` Clint Adams
  2004-04-23 15:58 ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Denio @ 2004-04-23 15:41 UTC (permalink / raw)
  To: zsh-workers

Hello,

I made a change to the _perforce completer to optionally restrict the 
list of changes to only those owned by the current user.  To whom should 
I send the patch?

-- 
Michael Denio (Michael.Denio@morganstanley.com)
Equity Trading Infrastructure


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: _perforce completer
  2004-04-23 15:41 _perforce completer Michael Denio
@ 2004-04-23 15:48 ` Clint Adams
  2004-04-23 15:58 ` Peter Stephenson
  1 sibling, 0 replies; 6+ messages in thread
From: Clint Adams @ 2004-04-23 15:48 UTC (permalink / raw)
  To: Michael Denio; +Cc: zsh-workers

> I made a change to the _perforce completer to optionally restrict the 
> list of changes to only those owned by the current user.  To whom should 
> I send the patch?

Send it to the list.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: _perforce completer
  2004-04-23 15:41 _perforce completer Michael Denio
  2004-04-23 15:48 ` Clint Adams
@ 2004-04-23 15:58 ` Peter Stephenson
  2004-04-23 16:03   ` Michael Denio
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2004-04-23 15:58 UTC (permalink / raw)
  To: Michael Denio; +Cc: zsh-workers

Michael Denio wrote:
> Hello,
> 
> I made a change to the _perforce completer to optionally restrict the 
> list of changes to only those owned by the current user.  To whom should 
> I send the patch?

zsh-workers.

Note that it should use styles to be sufficiently general.  Something
similar to the jobview style would be appropriate:

# Completion of jobs can also be controlled by the `jobview' style.
# This uses the standard Perforce JobView syntax, and is applied
# in connection with the `max' style.  In other words,
# if you set
#   zstyle ':completion:*:p4-*:jobs' max 0
#   zstyle ':completion:*:p4-*:jobs' jobview 'user=pws'
# then jobs to be completed will be those from the output of
#   p4 jobs -e 'user=pws'
# i.e. those assigned to Perforce user `pws'.

except the form will be a bit different.  One possibility is to allow
e.g.

zstyle ':completion:*:p4-*:changes' changes -u pws

i.e. the argument would be added to `p4 changes'.  Then you could
specify a maximum that way (-m 20).  It would make the `max' style
obsolete.

-- 
Peter Stephenson <pws@csr.com>                  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
**********************************************************************


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: _perforce completer
  2004-04-23 15:58 ` Peter Stephenson
@ 2004-04-23 16:03   ` Michael Denio
  2004-04-23 16:22     ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Denio @ 2004-04-23 16:03 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

Peter Stephenson wrote:

> Michael Denio wrote:
> 
>>Hello,
>>
>>I made a change to the _perforce completer to optionally restrict the 
>>list of changes to only those owned by the current user.  To whom should 
>>I send the patch?
> 
> 
> zsh-workers.

I've attached the patch
> 
> 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.



-- 
Michael Denio (Michael.Denio@morganstanley.com)
Equity Trading Infrastructure

[-- Attachment #2: _perforce.patch --]
[-- Type: text/plain, Size: 1127 bytes --]

--- _perforce.orig	Fri Apr 23 11:53:07 2004
+++ _perforce	Fri Apr 23 11:23:14 2004
@@ -495,9 +495,13 @@
 (( $+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 auser
 
   zstyle -s ":completion:${curcontext}:changes" max max || max=20
+	if zstyle -t ":completion:${curcontext}:changes" current_user; then
+    auser=(-u $USER)
+  fi
+
   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 +552,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 $auser $amax $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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: _perforce completer
  2004-04-23 16:03   ` Michael Denio
@ 2004-04-23 16:22     ` Peter Stephenson
  2004-04-23 17:01       ` Michael Denio
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2004-04-23 16:22 UTC (permalink / raw)
  To: Michael Denio; +Cc: zsh-workers

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@csr.com>                  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
**********************************************************************


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: _perforce completer
  2004-04-23 16:22     ` Peter Stephenson
@ 2004-04-23 17:01       ` Michael Denio
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Denio @ 2004-04-23 17:01 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

Peter Stephenson wrote:

> Michael Denio wrote:
> 
<snip>

> 
> 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?

Yes, that is better.  Works for me!


-- 
Michael Denio (Michael.Denio@morganstanley.com)
Equity Trading Infrastructure


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-04-23 17:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-23 15:41 _perforce completer Michael Denio
2004-04-23 15:48 ` Clint Adams
2004-04-23 15:58 ` Peter Stephenson
2004-04-23 16:03   ` Michael Denio
2004-04-23 16:22     ` Peter Stephenson
2004-04-23 17:01       ` Michael Denio

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).