Menu

Remember last line

Help
2005-05-10
2013-05-02
  • Nobody/Anonymous

    Is it possible for joe to remember the last line you where on in a file?

    This way when I go back into a file I start on the line I exited at.

     
    • Nobody/Anonymous

      Here I show a pure-joe solution. 
      This approach has so many problems that I don't
      recommend using it.  If you really want
      this feature, you have to implement
      (at least part of) it in C and include in your
      version of joe.

      Here are some of the problems:
      It can cause disatorous behaiviour if you edit files with unusual names. 
      It works only if you load files with the edit command, not from command line.
      It saves the line number only when you save the file, just viewing it isn't enough.
      It works only under unix systems.

      There migth be even worse problems, making this solution insecure.  I include this solution as-is, without any warranty.

      So here's my solution.  First, create the directory
      ~/.joe-line.  Then prepend these lines to the "default local options" section in your joerc (do not try this with the system-wide joerc please):

      :def basename_1 save,bol,"/",eol,rsrch,"/\x03",rtarw,markb,eol,markk,blkdel,prevw
      :def basename_2 nextw,abort
      :def saveline psh,basename_1,dnarw,markk,bof,markb,blksave,"!wc -l >~/.joe-line/l\'",yank,"\'",rtn,tomarkk,uparw,pop,basename_2
      :def restoreline basename_1,line,insf,"!cat ~/.joe-line/l\'",yank,"\'||echo 1",rtn,rtn,basename_2
      :def mold restoreline
      :def msnew saveline
      :def msold saveline

      -mold mold
      -msnew msnew
      -msold msold

       
    • Nobody/Anonymous

      Continuing my previous answer, the above code
      runs with joe 3.1.  Scheme on me, I haven't installed joe 3.2 yet.

      The solution can probably be done much easier with joe 3.2, because of its improvements in macro language (thanks, jhallen).  For example, I had to do circles because the abort command currently stops a macro (but still closes the window), so you can onyl put it at the end of the macro.  Version 3.2 has cancel as an alternative (I haven't tried it yet).

       

Log in to post a comment.