Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: match-word-context



Bart Schaefer wrote:
> } +Here are some examples of use of the tt(word-context) style to extend
> } +the context.
> } +
> } +example(zstyle ':zle:*' word-context "[[:space:]]" whitespace "*/*" file
> 
> Will this do the correct thing when the cursor is on whitespace that is
> inside a quoted file name?  My first thought would be to list the two
> patterns in the opposite order.

It will, although the other order would be a good deal more logical so
I'll change it anyway.  Since it's anchored to the start and end
[[:space:]] will only match a single whitespace character.  Since the
test words never have quotes stripped, that can only come from real
whitespace between words.

On rereading I didn't make it clear that the test at this level is
always on shell words; anything else gets confusingly recursive.

Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.62
diff -u -r1.62 contrib.yo
--- Doc/Zsh/contrib.yo	14 Aug 2006 16:14:41 -0000	1.62
+++ Doc/Zsh/contrib.yo	14 Aug 2006 16:42:01 -0000
@@ -487,16 +487,15 @@
 the var(X) of tt(foo)var(X)tt(bar), where var(X) can be any character, then
 the resulting expression is tt(bar)var(X)tt(foo).
 
-Finer grained control can be obtained by setting the style
-tt(word-context) to an array of pairs of entries.  Each pair of entries
-consists of a var(pattern) and a var(subcontext).  The word the cursor is on is
+Finer grained control can be obtained by setting the style tt(word-context)
+to an array of pairs of entries.  Each pair of entries consists of a
+var(pattern) and a var(subcontext).  The shell argument the cursor is on is
 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.  If the cursor is at the end of the line
-the test is maded against an empty string; if it is on whitespace
-between words the test is made against a single space.  Some examples
-are given below.
+Note that the test is made against the original word on the line, with no
+stripping of quotes.  If the cursor is at the end of the line the test is
+performed against an empty string; if it is on whitespace between words the
+test is made against a single space.  Some examples are given below.
 
 Here are some examples of use of the styles, actually taken from the
 simplified interface in tt(select-word-style):
@@ -516,7 +515,7 @@
 Here are some examples of use of the tt(word-context) style to extend
 the context.
 
-example(zstyle ':zle:*' word-context "[[:space:]]" whitespace "*/*" file
+example(zstyle ':zle:*' word-context "*/*" file "[[:space:]]" whitespace
 zstyle ':zle:transpose-words:whitespace' word-style shell
 zstyle ':zle:transpose-words:filename' word-style normal
 zstyle ':zle:transpose-words:filename' word-chars '')


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



Messages sorted by: Reverse Date, Date, Thread, Author