jed-users mailing list

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

Re: how to remember last editing point?


On Fri 2007-08-10 (15:25), G. Milde wrote:

> I currently use the workaround to undo and redo the last change, this resets
> the point to the position of the last edit.
> You could even bind this to a key like e.g. ::
> 
>    setkey("call(\"undo\"); redo()", "^KZ");

Nice trick! :-)
But it will not work when there was no editing before, like edt_findnxt.


> > I could write such a return_to_last_point() function, if there would be a
> > enter_key_hook : a hook that is called after *any* key input. But this is
> > missing, too.
> 
> Actually, there are "*_key_hooks". Have a look at Help>Browse_Docs>hooks
> for more details and see e.g.  http://jedmodes.sf.net/cuamark/) or
> wmark.sl for a usage example.

This was the hint I needed!
I have found _jed_before_key_hooks which is I was looking for.

I have now these functions:
   
    variable last_line, last_column;

    define remember_last_point_hook(f) {
      if (f != "goto_last_point") {
        last_line = what_line();
        last_column = what_column();
        % message(sprintf("%d:%d (%s)",last_line,last_column,f));
      }
    }

    define goto_last_point() {
      variable l = what_line();
      variable c = what_column();
    
      goto_line(last_line);
      goto_column(last_column);
      last_line = l;
      last_column = c;
    }

    add_to_hook("_jed_before_key_hooks", &remember_last_point_hook);

calling goto_last_point (bound to key of course) sets me to my last
editing point. I can even switch between the last points. Great. 

-- 
Ullrich Horlacher              Informationssysteme und Serverbetrieb
Rechenzentrum                  E-Mail: horlacher@xxxxxxxxxxxxxxxxxxxx
Universitaet Stuttgart         Tel:    ++49-711-685-65868
Allmandring 30                 Fax:    ++49-711-682357
70550 Stuttgart (Germany)      WWW:    http://www.rus.uni-stuttgart.de/

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


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