changed label, Put and backup name

  • From: Tommy Pettersson <ptp@xxxxxxxxxxxxxx>
  • To: wilyfans@xxxxxxxxxxxxx
  • Date: Tue, 5 Oct 2004 00:49:13 +0200

In my pursue for a clean way to integrate autosave, and at
the same time getting familiar with the source code, I think
I may have find a glitch in the backup engine.

If I edit a label so I can Put the buffer contents in a
different file, the backup name is not changed along.

Example: If I B2 New, replace New with foo in the label,
write and Put, than write some more and Del, the backup will
be for a file named New in the backup guide.

The perhaps most correct way would be to backup the contents
with the old name when I first make changes to the contents
after changing the label if the buffer was dirty when I
changed the label, and at the same time update the backup
name according to the new label.  Did you get that?

Well, it would require some heavy state machinery, and the
feature-creature-rate-something probably rules it out.

I have made a much simpler improvement.  I update the backup
name if needed whenever the file is successfully Put to its
current label name.

(patch for wily 0.13.41 at end of e-mail)

I check that backup is enabled first, and don't turn it on if
it isn't.  It could be better to always turn backup on because
of the successful file write, if I for example decide to make
the output in an +Error buffer the contents of a new file.
Any thoughts?

Tommy Pettersson <ptp@xxxxxxxxxxxxxx>

--- old/wily-9libs/wily/data.c  Mon Oct  4 23:39:32 2004
+++ new/wily-9libs/wily/data.c  Mon Oct  4 22:56:08 2004
@@ -89,6 +89,8 @@
                if(!d->names) {
                        tag_rmtool(d->tag, "Put");
+                       if (d->backupto && strcmp(d->backupto, path))
+                               data_setbackup(d, path);
                return 0;

Other related posts: