mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-04 10:41:11 +02:00
unposted: Make _perforce easier to use with add-on commands.
This commit is contained in:
parent
78bef99b73
commit
a190add859
2 changed files with 56 additions and 13 deletions
|
@ -1,5 +1,8 @@
|
|||
2003-10-13 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* unposted: Completion/Unix/Command/_perforce: make it
|
||||
easier to use add-on commands with _perforce.
|
||||
|
||||
* 19183: Doc/Zsh/contrib.yo,
|
||||
Functions/Zle/delete-whole-word-match: New word-matching function
|
||||
to delete entire word around cursor.
|
||||
|
|
|
@ -217,6 +217,35 @@
|
|||
# Perforce options, comme ca:
|
||||
# compdef _perforce p4reopen=p4-job-global
|
||||
#
|
||||
# Anything more complicated should be modelled on one of the
|
||||
# _perforce_cmd_* handlers below. To get this to work, the full
|
||||
# set of _perforce functions must be loaded; because of the way
|
||||
# autoloading works, a trick is required: call "_perforce -l" which
|
||||
# causes the function to be executed, loading all the associated
|
||||
# functions as a side effect, but tells _perforce to return without
|
||||
# generating any completions. For example, here is the completion
|
||||
# for my `p4desc' function which is an enhanced version of `p4 describe'
|
||||
# (without any handling for global Perforce arguments):
|
||||
#
|
||||
# #compdef p4desc
|
||||
#
|
||||
# _perforce -l
|
||||
#
|
||||
# _arguments -s : \
|
||||
# '-d-[select diff option]:diff option:((b\:ignore\ blanks c\:context d\:basic\ diff n\:RCS s\:summary u\:unified w\:ignore\ all\ whitespace))' \
|
||||
# '-s[short form]' \
|
||||
# '-j[select by job]:job:_perforce_jobs' \
|
||||
# '*::change:_perforce_changes'
|
||||
#
|
||||
# To add handling of global options to this, see the end of the _perforce
|
||||
# function below. Something like:
|
||||
#
|
||||
# local -a _perforce_global_options _perforce_option_dispatch
|
||||
# if _perforce_global_options; then
|
||||
# _arguments -s : $_perforce_option_dispatch \
|
||||
# '<other stuff>'
|
||||
# fi
|
||||
#
|
||||
# TODO
|
||||
# ====
|
||||
#
|
||||
|
@ -232,6 +261,12 @@ _perforce() {
|
|||
local p4cmd==p4 match mbegin mend
|
||||
integer _perforce_cmd_ind
|
||||
|
||||
if [[ $1 = -l ]]; then
|
||||
# Run to load _perforce and associated functions but do
|
||||
# nothing else.
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $service = -value-* ]]; then
|
||||
# Completing parameter value.
|
||||
# Some of these --- in particular P4PORT --- don't need
|
||||
|
@ -269,19 +304,6 @@ _perforce() {
|
|||
# get confused...
|
||||
local -a _perforce_global_options
|
||||
local -a _perforce_option_dispatch
|
||||
_perforce_option_dispatch=(
|
||||
'-c+[client]:client:_perforce_clients' \
|
||||
'-C+[charset]:charset:_perforce_charsets' \
|
||||
'-d+[current directory]:directory:_path_files -g "*(/)"' \
|
||||
'-H+[hostname]:host:_perforce_hosts' \
|
||||
'-G[python output]' \
|
||||
'-L+[message language]:language: ' \
|
||||
'-p+[server port]:port:_perforce_hosts_ports' \
|
||||
'-P+[password on server]:password: ' \
|
||||
'-s[output script tags]' \
|
||||
'-u+[user]:user name:_perforce_users' \
|
||||
'-x+[filename or -]:file:_perforce_files_or_minus' \
|
||||
)
|
||||
|
||||
# If we are given a service of the form p4-cmd, treat this
|
||||
# as if it was after `p4 cmd'. This provides an easy way in
|
||||
|
@ -414,6 +436,24 @@ _perforce_global_options() {
|
|||
# case they will be handled OK anyway.
|
||||
local argopts_ignore="Lx"
|
||||
|
||||
# The options we support in the form for _arguments.
|
||||
# This is here for modularity and convenience, but note that since the
|
||||
# actual dispatch takes place later, this is not local to this
|
||||
# function and so must be made local in the caller.
|
||||
_perforce_option_dispatch=(
|
||||
'-c+[client]:client:_perforce_clients' \
|
||||
'-C+[charset]:charset:_perforce_charsets' \
|
||||
'-d+[current directory]:directory:_path_files -g "*(/)"' \
|
||||
'-H+[hostname]:host:_perforce_hosts' \
|
||||
'-G[python output]' \
|
||||
'-L+[message language]:language: ' \
|
||||
'-p+[server port]:port:_perforce_hosts_ports' \
|
||||
'-P+[password on server]:password: ' \
|
||||
'-s[output script tags]' \
|
||||
'-u+[user]:user name:_perforce_users' \
|
||||
'-x+[filename or -]:file:_perforce_files_or_minus' \
|
||||
)
|
||||
|
||||
integer i
|
||||
|
||||
# We need to try and check if we are before or after the
|
||||
|
|
Loading…
Reference in a new issue