1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-30 11:56:04 +02:00

37027: allow subword context to discriminate between words

This commit is contained in:
Peter Stephenson 2015-10-30 16:59:04 +00:00
parent 26614ad0e0
commit 1eef57b3d1
3 changed files with 14 additions and 5 deletions

View File

@ -5,6 +5,9 @@
2015-10-30 Peter Stephenson <p.stephenson@samsung.com>
* 37027: Doc/Zsh/contrib.yo, Functions/Zle/match-word-context:
add editing word context to allow detecting being between words.
* 37022: Doc/Zsh/expn.yo, Doc/Zsh/options.yo, Src/glob.c,
Src/options.c, Src/zsh.h: add GLOB_STAR_SHORT option to
allow shorthand ** for **/* and *** for ***/*.

View File

@ -2016,9 +2016,10 @@ matched against each var(pattern) in turn until one matches; if it does,
the context is extended by a colon and the corresponding var(subcontext).
Note that the test is made against the original word on the line, with no
stripping of quotes. Special handling is done between words: the current
context is examined and if it contains the string tt(back), the word before
the cursor is considered, else the word after cursor is considered. Some
examples are given below.
context is examined and if it contains the string tt(between) the word
is set to a single space; else if it is contains the string tt(back),
the word before the cursor is considered, else the word after cursor is
considered. Some examples are given below.
The style tt(skip-whitespace-first) is only used with the
tt(forward-word) widget. If it is set to true, then tt(forward-word)

View File

@ -7,7 +7,7 @@ setopt extendedglob
local -a worcon bufwords
local pat tag lastword word backword forword
integer iword
integer iword between
zstyle -a $curcontext word-context worcon || return 0
@ -25,13 +25,18 @@ if [[ $lastword = ${bufwords[iword]} ]]; then
# If the word immediately left of the cursor is complete,
# we're not on it for forward operations.
forword=${bufwords[iword+1]}
# If, furthermore, we're on whitespace, then we're between words.
# It can't be significant whitespace because the previous word is complete.
[[ $RBUFFER[1] = [[:space:]] ]] && between=1
else
# We're on a word.
forword=${bufwords[iword]}
fi
backword=${bufwords[iword]}
if [[ $curcontext = *back* ]]; then
if [[ between -ne 0 && $curcontext = *between* ]]; then
word=' '
elif [[ $curcontext = *back* ]]; then
word=$backword
else
word=$forword