summaryrefslogtreecommitdiffstats
path: root/Functions/Zle
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-01-13 19:51:07 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2016-01-13 19:51:07 -0800
commit4a30b542a0028f04251c4364efeed9ef2b8adaef (patch)
treed08da29e6c85ed57df036d81d9065e41b9f93bd7 /Functions/Zle
parent37567: use (Z:n:) to split the buffer into words so line breaks are treated a... (diff)
downloadzsh-4a30b542a0028f04251c4364efeed9ef2b8adaef.tar
zsh-4a30b542a0028f04251c4364efeed9ef2b8adaef.tar.gz
zsh-4a30b542a0028f04251c4364efeed9ef2b8adaef.tar.bz2
zsh-4a30b542a0028f04251c4364efeed9ef2b8adaef.tar.lz
zsh-4a30b542a0028f04251c4364efeed9ef2b8adaef.tar.xz
zsh-4a30b542a0028f04251c4364efeed9ef2b8adaef.tar.zst
zsh-4a30b542a0028f04251c4364efeed9ef2b8adaef.zip
37570: give truth to the doc assertion transpose-words-match is a drop-in replacement for transpose-words
Diffstat (limited to 'Functions/Zle')
-rw-r--r--Functions/Zle/transpose-words-match11
1 files changed, 10 insertions, 1 deletions
diff --git a/Functions/Zle/transpose-words-match b/Functions/Zle/transpose-words-match
index c1db310c1..4d2ac71f1 100644
--- a/Functions/Zle/transpose-words-match
+++ b/Functions/Zle/transpose-words-match
@@ -11,14 +11,23 @@
# on X would be turned into `barXfoo' with the cursor still on the X,
# regardless of what the character X is.
+emulate -L zsh
autoload -Uz match-words-by-style
-local curcontext=":zle:$WIDGET" skip
+local curcontext=":zle:$WIDGET"
local -a matched_words
integer count=${NUMERIC:-1} neg
(( count < 0 )) && (( count = -count, neg = 1 ))
+if [[ $WIDGET == transpose-words ]]; then
+ # default is to be a drop-in replacement, check styles for change
+ zstyle -m $curcontext skip-chars \* ||
+ zstyle -m $curcontext word-style '*subword*' ||
+ { [[ $LBUFFER[-1] != [[:space:]] && $RBUFFER[1] != [[:space:]] ||
+ -z ${RBUFFER//[[:space:]]/} ]] && zle backward-word }
+fi
+
while (( count-- > 0 )); do
match-words-by-style