Macro get_word()?

Thorsten Haude yoo at vranx.de
Mon Jan 22 20:19:53 CET 2007


Hi,

* YT Lim wrote (2007-01-22 20:48):
>Has someone implemented a macro routine to perform
>get_word()? I.e. when the cursor is anywhere inside a
>word (delimited by spaces), the routine will return
>the complete word.

Here is my version:
- - - Schnipp - - -
define pos2word
{
    if (1 != $n_args)
    {
        #   wrong number of arguments
        beep()
        return ""
    }

    position = $1

    sow = search("<", position, "regex", "backward")
    eow = search(">", sow, "regex")

    if (-1 == sow || -1 == eow || eow < position)
    {
        #   position is not within a word
        return ""
    } else
    {
        return get_range(sow, eow)
    }
}
- - - Schnapp - - -


Thorsten
-- 
I propose we leave math to the machines and go play outside.
    - Calvin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.nedit.org/pipermail/discuss/attachments/20070122/01a7669d/attachment.bin


More information about the Discuss mailing list