mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-25 05:31:19 +02:00
users/15011: add path-completion style
This commit is contained in:
parent
c30b038a42
commit
e694590b37
3 changed files with 39 additions and 8 deletions
|
@ -1,3 +1,10 @@
|
|||
2010-04-14 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* users/15011: Completion/Unix/Type/_path_files,
|
||||
Doc/Zsh/compsys.yo: add path-completion style to allow
|
||||
completion of preceeding directories in files to be be turned
|
||||
off.
|
||||
|
||||
2010-04-13 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* unposted: Functions/Calendar/calendar, Functions/Calendar/calendar_add,
|
||||
|
@ -13010,5 +13017,5 @@
|
|||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.4953 $
|
||||
* $Revision: 1.4954 $
|
||||
*****************************************************
|
||||
|
|
|
@ -32,6 +32,7 @@ local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
|
|||
local pats haspats ignore pfx pfxsfx sopt gopt opt sdirs ignpar cfopt listsfx
|
||||
local nm=$compstate[nmatches] menu matcher mopts sort mid accex fake
|
||||
local listfiles listopts tmpdisp origtmp1 Uopt
|
||||
local accept_exact_dirs path_completion
|
||||
integer npathcheck
|
||||
local -a Mopts
|
||||
|
||||
|
@ -191,6 +192,11 @@ zstyle -a ":completion:${curcontext}:" fake-files fake
|
|||
|
||||
zstyle -s ":completion:${curcontext}:" ignore-parents ignpar
|
||||
|
||||
zstyle -t ":completion:${curcontext}:paths" accept-exact-dirs &&
|
||||
accept_exact_dirs=1
|
||||
zstyle -T ":completion:${curcontext}:paths" path-completion &&
|
||||
path_completion=1
|
||||
|
||||
if [[ -n "$compstate[pattern_match]" ]]; then
|
||||
if { [[ -z "$SUFFIX" ]] && _have_glob_qual "$PREFIX" complete } ||
|
||||
_have_glob_qual "$SUFFIX" complete; then
|
||||
|
@ -350,16 +356,17 @@ for prepath in "$prepaths[@]"; do
|
|||
skipped=
|
||||
cpre=
|
||||
|
||||
if zstyle -t ":completion:${curcontext}:paths" accept-exact-dirs &&
|
||||
[[ $pre = (#b)(*)/([^/]#) ]]; then
|
||||
# We've been told that we can accept an exact directory
|
||||
# prefix immediately. Try this with the longest path prefix
|
||||
# first: this saves stats in the simple case and may get around
|
||||
# automount behaviour if early components don't yet exist.
|
||||
if [[ ( -n $accept_exact_dirs || -z $path_completion ) && \
|
||||
$pre = (#b)(*)/([^/]#) ]]; then
|
||||
# We've been told either that we can accept an exact directory prefix
|
||||
# immediately, or that path expansion is inhibited. Try the longest
|
||||
# path prefix first: in the first case, this saves stats in the simple
|
||||
# case and may get around automount behaviour if early components don't
|
||||
# yet exist, and in the second case this is the prefix we want to keep.
|
||||
tmp1=$match[1]
|
||||
tpre=$match[2]
|
||||
while true; do
|
||||
if [[ -d $prepath$realpath$donepath$tmp1 ]]; then
|
||||
if [[ -z $path_completion || -d $prepath$realpath$donepath$tmp1 ]]; then
|
||||
donepath=$donepath$tmp1/
|
||||
pre=$tpre
|
||||
break
|
||||
|
|
|
@ -1123,6 +1123,9 @@ When this style is true, any prefix of a path that matches an existing
|
|||
directory is accepted without any attempt to complete it further.
|
||||
Hence, in the given example, the path tt(/usr/bin/) is accepted
|
||||
immediately and completion tried in that directory.
|
||||
|
||||
If you wish to inhibit this behaviour entirely, set the tt(path-completion)
|
||||
style (see below) to tt(false).
|
||||
)
|
||||
kindex(add-space, completion style)
|
||||
item(tt(add-space))(
|
||||
|
@ -2259,6 +2262,20 @@ containing color names in the format of an X11 tt(rgb.txt) file. If
|
|||
the style is not set but this file is found in one of various standard
|
||||
locations it will be used as the default.
|
||||
)
|
||||
item(tt(path-completion))(
|
||||
This is used by filename completion. By default, filename completion
|
||||
examines all components of a path to see if there are completions of
|
||||
that component. For example, tt(/u/b/z) can be completed to
|
||||
tt(/usr/bin/zsh). Explicitly setting this style to tt(false) inhibits this
|
||||
behaviour for path components before the cursor; this overrides the
|
||||
setting of tt(accept-exact-dirs).
|
||||
|
||||
Even with the style set to tt(false), it is still possible to complete
|
||||
multiple paths by setting the option tt(COMPLETE_IN_WORD) and moving the
|
||||
cursor back to the first component in the path to be completed. For
|
||||
example, tt(/u/b/z) can be completed to tt(/usr/bin/zsh) if the cursor is
|
||||
after the tt(/u).
|
||||
)
|
||||
kindex(pine-directory, completion style)
|
||||
item(tt(pine-directory))(
|
||||
If set, specifies the directory containing PINE mailbox files. There
|
||||
|
|
Loading…
Reference in a new issue