On Tue, Oct 17, 2006 at 04:54:21PM -0500, Tim Chase wrote:
> >     Let's think big and look for a generic solution.  IMHO, it is way
> >too restrictive to insist that a word is anything matching the pattern
> >/\k\+/ .  I want a new option, 'wordpat', with a default value of
> >'\k\+', that specifies what should be recognized as a word, for purposes
> >of search patterns, Normal-mode commands such as w and b, and maybe
> >other uses.  (Oh, yes:  Insert-mode completion.)
> >
> >Examples:
> >
> >:let &l:wordpat = '\k\+\(-\k\+\)*'
> 
> In the general, I like it!  In the implementation, I don't know 
> if there are snags that one will encounter.  One might have to 
> include the cursor position to anchor it in the search text.

     I have not thought about implementation.  I have been wondering for
a while what a good solution to the TeX \long\def\foo problem, where I
am not entirely happy with isk+=\ nor with isk-=\ .  This is the first
idea I have had that might be workable from a user's point of view.

     I am not sure why you think including the cursor position is
important.

> Funky conditions could occur if patterns contain certain atoms 
> (for better or worse).  Could things like using \%<9c enforce 
> that words are only contained before column 9 (makes me think of 
> my cobol days)?  Or even something like '\%>0l\%<42l\k*\%#\k*' 
> enforce that keywords are only found in the first 41 lines of 
> your file?  Or can keywords only be duplicate-part words like 
> "mahimahi" using a pattern like '\(\k\+\)\1'?  Or keywords are 
> only ever preceeded by "int" like 'int\_s\+\zs\k+'?  Or alter the 
> behavior of the "*" and "#" commands to find the word that 
> *preceeds* the word under the cursor with something like 
> '\k\+\ze\K\+\k*\%#'
> 
> All these seem like sensible (for cases where "sensible" may be a 
> subset of as "pathological") potential use-cases for such a thing.

     That is the way generic solutions work.  Once you give users the
flexibility of specifying any regular expression as an option, they will
come up with applications that did not occur to you.  Sometimes, they
will shoot themselves in the foot.

     I would expect this option to affect the * and # commands, and also
the \< and \> regular expressions.  Also the iw text object.

HTH                                     --Benji Fisher

Reply via email to