jed-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: next_word/prev_word


On Mon, Apr 26, 2004 at 08:06:07AM +0200, G. Milde wrote:
> On 25.04.04, Dave Kuhlman wrote:
> > I'd like to write a script that enables me to put the cursor on a
> > word (or variable name), then press a key, and have it search for
> > the next (or previous) occurance of that word.  Some questions:
> > 
> > 1. Is it there already?  Or, is it implemented somewhere?
> 
> Not that I know of. However, you will find building blocks in 
> http://jedmodes.sf.net/mode/txtutils/
> 
> autoload("get_word", "txtutils");
> 
> % for me, next_word implies the neighbour, not the next occurence of the
> % same word...
> define fsearch_current_word() 
> {
>    () = fsearch(get_word());
> }   
>     
> define bsearch_current_word()
> { 
>    () = bsearch(get_word());
> }       

Günter -

Thanks for the pointer to txtutils.sl.  get_word() was one of the
things I was looking for.  Also, your code above and the code in
txtutils.sl gave me a few additional hints.

In case it could be useful to someone else, here is my current
version.  It works great, or at least it works the way I like it:


    define search_current_word(direction)
    {
        variable word;
        variable mark;
        variable result;
        mark = create_user_mark();
        skip_word();
        bskip_word();
        word = get_word();
        if (direction == 1)
        {
            go_right_1();
            result = fsearch(word);
        }
        else
        {
            result = bsearch(word);
        }
        if (result == 0)
        {
            goto_user_mark(mark);
            message(word + " not found");
        }
    }

    setkey ("search_current_word(-1)", "\ez<");
    setkey ("search_current_word(1)", "\ez>");


Thanks again for the help.

Dave

-- 
Dave Kuhlman
dkuhlman@xxxxxxxx
http://www.rexx.com/~dkuhlman


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]