From 3a97920199accf4f63b622645ea208ccad42d07b Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 14 Aug 2006 16:14:41 +0000 Subject: 22606: add match-word-context. Remove workaround from match-words-by-style --- Functions/Zle/match-words-by-style | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'Functions/Zle/match-words-by-style') diff --git a/Functions/Zle/match-words-by-style b/Functions/Zle/match-words-by-style index def43f2e9..ad74a984f 100644 --- a/Functions/Zle/match-words-by-style +++ b/Functions/Zle/match-words-by-style @@ -71,9 +71,10 @@ local wordstyle spacepat wordpat1 wordpat2 opt charskip wordchars wordclass local match mbegin mend pat1 pat2 word1 word2 ws1 ws2 ws3 skip local nwords MATCH MBEGIN MEND -if [[ -z $curcontext ]]; then - local curcontext=:zle:match-words-by-style -fi +local curcontext=${curcontext:-:zle:match-words-by-style} + +autoload -U match-word-context +match-word-context while getopts "w:s:c:C:" opt; do case $opt in @@ -108,27 +109,12 @@ case $wordstyle in # This splits the line into words as the shell understands them. bufwords=(${(z)LBUFFER}) nwords=${#bufwords} - # Work around bug: if stripping quotes failed, a bogus - # space is appended. Not a good test, since this may - # be a quoted space, but it's hard to get right. - wordpat1=${bufwords[-1]} - if [[ ${wordpat1[-1]} = ' ' ]]; then - wordpat1=${(q)wordpat1[1,-2]} - else - wordpat1="${(q)wordpat1}" - fi + wordpat1="${(q)bufwords[-1]}" # Take substring of RBUFFER to skip over $skip characters # from the cursor position. bufwords=(${(z)RBUFFER[1+$skip,-1]}) - # Work around bug again. - wordpat2=${bufwords[1]} - if [[ ${wordpat2[-1]} = ' ' ]] - then - wordpat2=${(q)wordpat2[1,-2]} - else - wordpat2="${(q)wordpat2}" - fi + wordpat2="${(q)bufwords[1]}" spacepat='[[:space:]]#' # Assume the words are at the top level, i.e. if we are inside -- cgit 1.4.1