Menu

#596 #501 Auto-save untitled buffers - patch

None
closed-accepted
5
2017-07-17
2017-02-17
No

I created a patch for the feature request: "#501 Auto-save untitled buffers".
Altough the settings "Autosave untitled buffers" exists, but not working like described in the feature request.
My patch extends this feature, when "Autosave untitled buffers" checked (default):
- the untitled buffers will be autosaved when closing jedit, without a question prompt
- the autosave for an untitled buffer saved to <jedit_settings_dir>/autosave, and reloaded after a restart (the state persisted to the perspective.xml)
- closing an untitled buffer by hand removes the autosave file

Tested on windows7 and linux also.
The patch is against revision 24609.
Please review.
Thanks!

1 Attachments

Discussion

1 2 3 > >> (Page 1 of 3)
  • Alan Ezust

    Alan Ezust - 2017-03-19
    • assigned_to: Alan Ezust
    • Group: -->
     
  • Alan Ezust

    Alan Ezust - 2017-03-27
    • status: open --> pending-rejected
     
  • Alan Ezust

    Alan Ezust - 2017-03-27

    I tried applying the patch to the svn trunk but it did not apply cleanly for MiscUtilities.java.
    Can you please try to freshen the patch to the latest SVN? I like your ideas.

     
  • Hrotkó Gábor

    Hrotkó Gábor - 2017-03-31

    Please find the updated patch against rev. 24670 attached.

     
    • Alan Ezust

      Alan Ezust - 2017-05-08

      Just tried this verison of the patch. it does not apply cleanly either :-(

       
  • Hrotkó Gábor

    Hrotkó Gábor - 2017-05-05

    Hi Alan,

    can you review my patch? I could promote jedit with more success by this feature.
    By the way, I use the version with this path for months without any issue.

    Thanx!

     
    • Alan Ezust

      Alan Ezust - 2017-05-05

      I am so sorry for not getting around to this!! I do plan to put it into
      jEdit but I've been away from my home development box for a couple of
      weeks. I will be home next week and then I am away for 2 more weeks.
      I will try extra hard to get it into the svn trunk next week.

      thanks again for your contribution!!

      On Fri, May 5, 2017 at 3:44 PM, "Hrotkó Gábor" roti@users.sf.net wrote:

      Hi Alan,

      can you review my patch? I could promote jedit with more success by this
      feature.
      By the way, I use the version with this path for months without any issue.

      Thanx!


      [patches:#596] #501 Auto-save untitled buffers - patch

      Status: pending-rejected
      Group:
      Labels: untitled autosave
      Created: Fri Feb 17, 2017 05:34 PM UTC by Hrotkó Gábor
      Last Updated: Fri Mar 31, 2017 03:28 PM UTC
      Owner: Alan Ezust
      Attachments:

      I created a patch for the feature request: "#501 Auto-save untitled
      buffers".
      Altough the settings "Autosave untitled buffers" exists, but not working
      like described in the feature request.
      My patch extends this feature, when "Autosave untitled buffers" checked
      (default):
      - the untitled buffers will be autosaved when closing jedit, without a
      question prompt
      - the autosave for an untitled buffer saved to
      <jedit_settings_dir>/autosave, and reloaded after a restart (the state
      persisted to the perspective.xml)
      - closing an untitled buffer by hand removes the autosave file

      Tested on windows7 and linux also.
      The patch is against revision 24609.
      Please review.
      Thanks!


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/jedit/patches/596/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

       
  • Alan Ezust

    Alan Ezust - 2017-05-08
    • status: pending-rejected --> open
     
  • Hrotkó Gábor

    Hrotkó Gábor - 2017-05-09

    This is against 24674, and I tested it also.

     
    • Alan Ezust

      Alan Ezust - 2017-05-09

      That applies cleanly and I am testing it now.

       
  • Alan Ezust

    Alan Ezust - 2017-05-09

    Testing it with Editpane Scope Buffersets, there is an inconsistency. It bugs me, so I am hesitant to commit the patch as-is.

    If I close the dirty untitled-1 buffer from view#1, the only view that has it open, I am asked if i want to save the untitled buffer.
    But if I close view#2 with an untitled-2 buffer that is not open in view#1, it does not ask me to save, and the contents are lost. If later, I create a new untitled-2 buffer, it is empty.

    I think the behavior of closing a dirty untitled buffer or closing a view with a dirty untitled buffer should be the same - either it should save it and restore it when you bring the buffer back, or it should ask you to confirm if you want to close without saving.

     

    Last edit: Alan Ezust 2017-05-11
  • Hrotkó Gábor

    Hrotkó Gábor - 2017-05-13

    I added a simple solution for this:
    When you have more than one view opened, and close a view with untitled buffers:
    all of it's untitled buffers will be moved to the first or last opened view's active editpane's bufferset.
    Works fine, no untitled buffer will be lost. Also for EditPane and View scopes.
    I think the help also should be updated with these infos.

     
    • Alan Ezust

      Alan Ezust - 2017-05-13

      Oh I like your solution very much. Elegant.

       
  • Alan Ezust

    Alan Ezust - 2017-05-13
    • status: open --> closed-accepted
     
  • Alan Ezust

    Alan Ezust - 2017-05-13

    Committed revision 24675.
    Thanks for your contribution!

     
  • Alan Ezust

    Alan Ezust - 2017-05-31

    Hrotkó,

    I just made some changes to where autosave files are saved, and I broke and then fixed the restoring of dirty untitled buffers. However, the restoring process is not 100% correct yet - the path of the untitled buffer after restoring it, points to a location in the backup directory when we want it to point to the original path of the untitled buffer. Please update to the latest svn or daily build and test it. I will keep testing and working on it too, but if you notice something you can fix, please let me know.

    --Alan

     
  • Hrotkó Gábor

    Hrotkó Gábor - 2017-06-01

    Are you testing it with a clean new settings dir? I tested with new settings dir, and it works. I think it should work like this, because this feature is not released yet.

     
  • Alan Ezust

    Alan Ezust - 2017-06-01

    The problem is the location of new untitled buffers is not being set correctly anymore.
    When I create a new untitled buffer, it should create it at the location of the current buffer's directory.

    This is caused by your patch, and is a regression of previous behavior.

    What I want is for the autosaves of untitled buffers to go in the same place as the backup directory, which is the current directory OR the backup directory if specified in properties.

    When the untitled buffer is restored, it must restore the correct path also.

    I will see if I can fix this, but I am also not 100% happy with some of the other changes I see now that I am looking at this patch more closely.

     

    Last edit: Alan Ezust 2017-06-03
  • Alan Ezust

    Alan Ezust - 2017-06-03
    • status: closed-accepted --> pending-remind
     
  • Hrotkó Gábor

    Hrotkó Gábor - 2017-06-06

    I think, the untitled buffers should all go into one directory by default, even if we do not set the autosave/backup dir explicitly. For example in this way one can easily find them after a long time, even without using jEdit.
    Imagine by the default behaviour, that if one would have many untitled buffers lying around the filesystem.
    Attached a small patch to make it work again, it fixes the following problem: when I edited a real file without saving, and have untitled buffers, the close question also listed the untitled buffers.

     
    • Alan Ezust

      Alan Ezust - 2017-06-07

      ok I committed that and the change will be in the next daily build.
      But we still need to fix the initial path issue.

      as for leaving behind autosaves of untitled buffers, the user has 2 options.
      1. uncheck autosave untitled buffers
      2. set the autosave/backup directory to somewhere else.

       
    • Alan Ezust

      Alan Ezust - 2017-07-02

      The default behavior could be set to have the backup location pre-set to something sensible, such as the jEditSettingsDirectory/backups, but that is just a simple value/1-liner we add to the jedit.props file. Then the default behavior won't leave behind autosaves or backups everywhere.

       
  • Alan Ezust

    Alan Ezust - 2017-06-06

    The problem is that I want to be able to create a new file in the same directory as the currenly editing file, and my workflow looks like this:
    File - New
    type stuff
    "save as" and I want the FSB to already have the correct location I want.

    Since i have the Console plugin also chdir-ing to the location of the currently open buffer, it changes into the wrong directory also.

     
  • Hrotkó Gábor

    Hrotkó Gábor - 2017-06-12

    I created a patch, that works exactly as you described:

    • if the backup, autosave dir set:
    • new untitled buffers will be saved to that location
    • newly opened files will be autosaved to that dir, prefixed with their path

    • if the backup, autosave dir is NOT set:

    • new untitled buffers will be saved to the currently opened buffer's dir
      or for the very first start: to jedit's dir
    • newly opened files will be autosaved next to the original

    Note: The autosave path will be set when a buffer is created/opened.
    When we change the backup, autosave path from/to empty value, already opened buffers will preserve the path until jedit closed.

    Fixed other problems like:
    - press save for an untitled buffer saved without question
    - after changing the autosave path, at next start the untitled buffer was not laoded.

    Please test.

     
    • Alan Ezust

      Alan Ezust - 2017-06-12

      This is almost what I meant, so thank you for addressing my issues.

      I made a small change to your patch, so that
      If backup, autosave dir is set:
      new untitled buffers should go into the same place as if it is not set - same place as the currently opened buffer.
      I don't want that setting to change jEdit's behavior when creating new untitled buffers.

      And the final touch is that when an autosave untitled is restored from backup, its path should be restored too. Perhaps you can look into that?

      Committing transaction...
      Committed revision 24705.

       

      Last edit: Alan Ezust 2017-06-12
1 2 3 > >> (Page 1 of 3)

Log in to post a comment.