163
163
# File completion for some functions is restricted by the Perforce
164
164
# status of the file; for example, `p4 opened' only completes opened
165
165
# files (surprised?) However, you can set the style (N.B. not tag)
166
# all-files; so, for example, you can turn off the limit in this case by
166
# `all-files'; so, for example, you can turn off the limit in this case by
167
167
# zstyle ':completion:*:p4-opened:*' all-files true
168
# Normally the file-patterns style would be used to control matching,
168
# Normally the `file-patterns' style would be used to control matching,
169
169
# but as the file types are not selected by globbing it doesn't work here
170
170
# However, if you set the all-files style, all filename completion is done
171
# by the standard mechanism; in this case, the file-patterns style works
172
# as usual. The style ignored-patterns is available in any case, even
173
# without all-files; this is therefore generally the one to use.
171
# by the standard mechanism; in this case, the `file-patterns' style works
172
# as usual. The style `ignored-patterns' is available in any case, even
173
# without `all-files'; this is therefore generally the one to use.
175
# The style `whole-path' allows you complete the entire path to a file
176
# at once. This is useful in cases such as opened files where the
177
# list of files is likely to be short but may include files with
178
# widely different paths. As with the `glob' style, the tag is the
179
# Perforce disposition of the file: integrated, opened, resolved, dirs,
180
# files. For example, with
181
# zstyle ':completion:*:p4-revert:*:opened' whole-path true
182
# completion after `p4 revert' will offer you the entire depot path
183
# to a file rather than just part of the path at once (with the
184
# usual methods of disambiguation). Directory completion is turned
185
# off during a `whole-path' completion. The `whole-path' style can
186
# also take the value `absolute'; this means that an initial `/'
187
# activates `whole-path' completion, otherwise a relative file path
188
# will be completed in the normal way. For example, with
189
# zstyle ':completion:*:p4-revert:*:opened' whole-path absolute
190
# then after `p4 revert <TAB>' you are offered open files in the
191
# current directory plus directories; after `p4 revert /<TAB>' you
192
# are offered all open files in depot syntax.
175
194
# With `p4 diff', the shell will spot if you have used an option that
176
195
# allows you to diff unopened files (such as -f) and in that case offer
813
# Helper function for the helper function for the helper functions
814
# for the helper function _perforce_files.
816
# Check if we should do whole-path completion.
817
# The argument is the Perforce disposition of files are looking at.
818
_perforce_whole_path() {
821
zstyle -s ":completion:${curcontext}:$1" whole-path wp
828
[[ ${(Q)PREFIX} = /* ]] && return 0
795
836
# Helper function for the helper functions for the helper function
796
837
# _perforce_files. This is common code to retrieve a list of files
809
if zstyle -t ":completion:${curcontext}:$1" glob; then
850
if _perforce_whole_path $1; then
851
files=(${${(f)"$(_perforce_call_p4 $1 $1 2>/dev/null)"}%%\#*})
852
elif zstyle -t ":completion:${curcontext}:$1" glob; then
810
853
# Limit the list by using Perforce to glob the pattern.
811
854
# This may be faster, but won't use matcher specs etc.
1072
1118
! zstyle -t ":completion:${curcontext}:" all-files; then
1073
1119
for type in $types; do
1074
1120
altfiles+=("$type-files:$type file:_perforce_${type}_files")
1121
_perforce_whole_path $type && nodirs=1
1077
1124
altfiles+=("depot-files:file in depot:_perforce_depot_files")
1080
# Intermediate directories in a client view.
1081
# See function for notes.
1082
altfiles+=("client-dirs:client directory:_perforce_client_dirs")
1127
if [[ -z $nodirs ]]; then
1128
# Intermediate directories in a client view.
1129
# See function for notes.
1130
altfiles+=("client-dirs:client directory:_perforce_client_dirs")
1084
1133
altfiles+=("depot-dirs:directory in depot:_perforce_depot_dirs"
1085
1134
# "subdirs:subdirectory search:_perforce_subdirs"
1119
1168
for type in $types; do
1120
1169
altfiles+=("$type-files:$type file:_perforce_${type}_files")
1170
_perforce_whole_path $type && nodirs=1
1123
# altfiles+=("subdirs:subdirectory search:_perforce_subdirs")
1124
if zstyle -t ":completion:${curcontext}:" depot-files; then
1125
altfiles+=("depot-dirs:directory in depot:_perforce_depot_dirs")
1127
altfiles+=("directories:directory:_path_files -/")
1173
if [[ -z $nodirs ]]; then
1174
# altfiles+=("subdirs:subdirectory search:_perforce_subdirs")
1175
if zstyle -t ":completion:${curcontext}:" depot-files; then
1176
altfiles+=("depot-dirs:directory in depot:_perforce_depot_dirs")
1178
altfiles+=("directories:directory:_path_files -/")
1129
1181
_alternative $altfiles
1130
1182
elif zstyle -t ":completion:${curcontext}:" depot-files; then