Macro get_word()?
Tony Balinski
ajbj at free.fr
Mon Jan 22 21:21:41 CET 2007
Quoting Bert Wesarg <wesarg at informatik.uni-halle.de>:
> Yes,
>
> this is my actual code, to check if $cursor is on a right word boundary:
>
> define is_right {
> rwb = -1
> if ($cursor > 0) {
> rwb = search(">", $cursor - 1, "forward", "regex")
> } else if ($cursor < $text_length) {
> rwb = search(">", $cursor + 1, "backward", "regex")
> }
> if ($cursor != rwb) {
> return 0
> }
> return 1
> }
You want a predicate to test the current position.
Why not just:
return search(">", $cursor, "regex")
which is much the same as
return search("(?<=\\w)(?=\\W|$)", $cursor, "regex") == $cursor
Likewise for lwb: "<" or "?<=^|\\W)(?=\\w)"
Tony
More information about the Discuss
mailing list