about summary refs log tree commit diff
path: root/Functions/Zle
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-06-24 16:09:28 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-06-24 16:09:28 +0000
commit46c8127e939e9102f27c5a10733cb444bf898a30 (patch)
tree0feedbf4a1f20c2e54209f3010ae11b820542f21 /Functions/Zle
parentc52864df2fd9fbf786ecd176a21eb34763993e05 (diff)
downloadzsh-46c8127e939e9102f27c5a10733cb444bf898a30.tar.gz
zsh-46c8127e939e9102f27c5a10733cb444bf898a30.tar.xz
zsh-46c8127e939e9102f27c5a10733cb444bf898a30.zip
25244: add subword-range style
Diffstat (limited to 'Functions/Zle')
-rw-r--r--Functions/Zle/match-words-by-style21
-rw-r--r--Functions/Zle/modify-current-argument4
-rw-r--r--Functions/Zle/split-shell-arguments3
3 files changed, 17 insertions, 11 deletions
diff --git a/Functions/Zle/match-words-by-style b/Functions/Zle/match-words-by-style
index 1597aa694..2cbc35469 100644
--- a/Functions/Zle/match-words-by-style
+++ b/Functions/Zle/match-words-by-style
@@ -69,14 +69,14 @@ setopt extendedglob
 
 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
+local nwords MATCH MBEGIN MEND subwordrange
 
 local curcontext=${curcontext:-:zle:match-words-by-style}
 
 autoload -U match-word-context
 match-word-context
 
-while getopts "w:s:c:C:" opt; do
+while getopts "w:s:c:C:r:" opt; do
   case $opt in
     (w)
     wordstyle=$OPTARG
@@ -94,6 +94,10 @@ while getopts "w:s:c:C:" opt; do
     wordchars=$OPTARG
     ;;
 
+    (r)
+    subwordrange=$OPTARG
+    ;;
+
     (*)
     return 1
     ;;
@@ -190,6 +194,10 @@ word1=$match[1]
 ws1=$match[2]
 
 if [[ $wordstyle = *subword* ]]; then
+  if [[ -z $subwordrange ]] &&
+    ! zstyle -s $curcontext subword-range subwordrange; then
+    subwordrange='[:upper:]'
+  fi
   # The rule here is that a word boundary may be an upper case letter
   # followed by a lower case letter, or an upper case letter at
   # the start of a group of upper case letters.  To make
@@ -199,10 +207,10 @@ if [[ $wordstyle = *subword* ]]; then
   # Here the initial "*" will match greedily, so we get the
   # last such match, as we want.
   integer epos
-  if [[ $word1 = (#b)(*)([[:upper:]][^[:upper:]]*) ]]; then
+  if [[ $word1 = (#b)(*)([${~subwordrange}][^${~subwordrange}]*) ]]; then
     (( epos = ${#match[1]} ))
   fi
-  if [[ $word1 = (#b)(*[^[:upper:]])([[:upper:]]*) ]]; then
+  if [[ $word1 = (#b)(*[^${~subwordrange}])([${~subwordrange}]*) ]]; then
     (( ${#match[1]} > epos ))  &&  (( epos = ${#match[1]} ))
   fi
   if (( epos > 0 )); then
@@ -226,14 +234,15 @@ if [[ $wordstyle = *subword* ]]; then
   # Do we have a group of upper case characters at the start
   # of word2 (that don't form the entire word)?
   # Again, rely on greedy matching of first pattern.
-  if [[ $word2 = (#b)([[:upper:]][[:upper:]]##)(*) && -n $match[2] ]]; then
+  if [[ $word2 = (#b)([${~subwordrange}][${~subwordrange}]##)(*) &&
+	  -n $match[2] ]]; then
     # Yes, so the last one is new word boundary.
     (( epos = ${#match[1]} - 1 ))
     # Otherwise, do we have upper followed by non-upper not
     # at the start?  Ignore the initial character, we already
     # know it's a word boundary so it can be an upper case character
     # if it wants.
-  elif [[ $word2 = (#b)(?[^[:upper:]]##)[[:upper:]]* ]]; then
+  elif [[ $word2 = (#b)(?[^${~subwordrange}]##)[${~subwordrange}]* ]]; then
     (( epos = ${#match[1]} ))
   else
     (( epos = 0 ))
diff --git a/Functions/Zle/modify-current-argument b/Functions/Zle/modify-current-argument
index be244ccc1..dd0b85a82 100644
--- a/Functions/Zle/modify-current-argument
+++ b/Functions/Zle/modify-current-argument
@@ -4,10 +4,10 @@
 # cursor with that.  Ensure the expression is suitable quoted.
 #
 # For example, to uppercase the entire shell argument:
-#   modify-current-word '${(U)ARG}'
+#   modify-current-argument '${(U)ARG}'
 # To strip the current quoting from the word (whether backslashes or
 # single, double or dollar quotes) and use single quotes instead:
-#   modify-current-word '${(qq)${(Q)ARG}}'
+#   modify-current-argument '${(qq)${(Q)ARG}}'
 
 # Retain most options from the calling function for the eval.
 # Reset some that might confuse things.
diff --git a/Functions/Zle/split-shell-arguments b/Functions/Zle/split-shell-arguments
index e8a231732..ee737a067 100644
--- a/Functions/Zle/split-shell-arguments
+++ b/Functions/Zle/split-shell-arguments
@@ -7,9 +7,6 @@
 # Hence ${reply[$REPLY][$REPLY2]} is the character under the cursor.
 #
 # reply, REPLY, REPLY2 should therefore be local to the enclosing function.
-#
-# The following formula replaces the current shell word, or previous word
-# if the cursor is on whitespace, by uppercasing all characters.
 
 emulate -L zsh
 setopt extendedglob