Macro get_word()?
Bert Wesarg
wesarg at informatik.uni-halle.de
Mon Jan 22 20:25:50 CET 2007
Hi,
btw, is ther a simple method to determine if a given position is either an
"<" or ">" anchor?
Bert
Thorsten Haude wrote:
> 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
>
More information about the Discuss
mailing list