summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/contrib.yo9
-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
5 files changed, 29 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 31947a466..4f72e7029 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-06-24  Peter Stephenson  <pws@csr.com>
 
+	* 25244: Doc/Zsh/contrib.yo, Functions/Zle/match-words-by-style,
+	Functions/Zle/modify-current-argument,
+	Functions/Zle/split-shell-arguments: enhance users/12987 with
+	style for subword start and fix a few bits of documentation.
+
 	* users/12985, users/12986, users/12988: Tomasz Pala:
 	Completion/Linux/Command/_ethtool,
 	Completion/Linux/Command/_ipset, Completion/Unix/Command/_arp:
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index e1640116a..0d3b16aa9 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -459,11 +459,15 @@ Restore the default settings; this is usually the same as `tt(normal)'.
 )
 enditem()
 
-All but `tt(default)' can be input as an upper case character, which was
+All but `tt(default)' can be input as an upper case character, which has
 the same effect but with subword matching turned on.  In this case, words
 with upper case characters are treated specially: each separate run of
 upper case characters, or an upper case character followed by any number of
-other characters, is considered a word.
+other characters, is considered a word.  The style tt(subword-range)
+can supply an alternative character range to the default `tt([:upper:])';
+the value of the style is treated as the contents of a `tt([)var(...)tt(])'
+pattern (note that the outer brackets should not be supplied, only
+those surrounding named ranges).
 
 More control can be obtained using the tt(zstyle) command, as described in
 ifzman(zmanref(zshmodules))\
@@ -591,6 +595,7 @@ sitem(tt(-w))(var(word-style))
 sitem(tt(-s))(var(skip-chars))
 sitem(tt(-c))(var(word-class))
 sitem(tt(-C))(var(word-chars))
+sitem(tt(-r))(var(subword-range))
 endsitem()
 
 For example, tt(match-words-by-style -w shell -c 0) may be used to
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