On Tue, Oct 26, 2010 at 12:03 AM, Richard Heck <rgh...@comcast.net> wrote:
> I think this was added a while ago, because we were leaving emergency files
> lying around. We only ask about this if an attempt to recover the file has
> been made, either successfully or not. So either the document is now loaded
> in the buffer or else we couldn't load it.

Again, I'd personally put this in ::save(). Leaving an emergency file
around until the user next saves doesn't sound too bad to me. If
everything goes well the user will continue working on the file and
save it soon enough. If it doesn't go well, keeping the file around is
probably a good idea. (The user might not know whether everything will
go well at the point we ask them)

>> Otherwise I'd add a "Keep All" option.
>
> What does this mean?

Once you click "Keep All", we keep all the saves without prompting the user.

>> +                        e.checksum() != s.checksum()) {
>>
>> There are a number of ways to get a dirty buffer without actually
>> changing the file. E.g we can add two spaces that get converted to a
>> single space, or we can add a character and then remove it by
>> backspacing. This seems to happen fairly regularly to me, so it seems
>> worth checking for.
>
> I'm not sure where this code is. I'd want to see the context before deciding
> whether this is worth it.

It occurs immediately prior to prompting the user whether we want to
open the original or the emergency file. I consider it worthwhile
since even IO is cheap compared to user time (and user concentration).

This is now like:
--------------
Buffer::ReadStatus Buffer::readEmergency(FileName const & fn)
{
   FileName const emergencyFile = getEmergencyFileNameFor(fn);
        if (!emergencyFile.exists()
                  || emergencyFile.lastModified() <= fn.lastModified() ||
+                   emergencyFile.checksum() ==  fn.checksum())
                return ReadFileNotFound;

        docstring const file = makeDisplayPath(fn.absFileName(), 20);
----

(and similar for autosave files)

>> This is the code for the "Recover All" emergency save.
>
> Can you redo this, separately, given the recent changes?

Sure (attached), but note that without having an e.g. "Keep All"
option, if you open several files you'll still have several windows
popping up asking you if you want to keep the emergency saves.

-- 
John C. McCabe-Dansted
Index: Buffer.cpp
===================================================================
--- Buffer.cpp	(revision 35834)
+++ Buffer.cpp	(working copy)
@@ -3617,6 +3627,8 @@
 
 Buffer::ReadStatus Buffer::readEmergency(FileName const & fn)
 {
+	static bool recover_all = false;
+
 	FileName const emergencyFile = getEmergencyFileNameFor(fn);
 	if (!emergencyFile.exists() 
 		  || emergencyFile.lastModified() <= fn.lastModified())
@@ -3626,9 +3638,20 @@
 	docstring const text = bformat(_("An emergency save of the document "
 		"%1$s exists.\n\nRecover emergency save?"), file);
 	
-	int const load_emerg = Alert::prompt(_("Load emergency save?"), text,
-		0, 2, _("&Recover"), _("&Load Original"), _("&Cancel"));
+	int load_emerg;
 
+	if (recover_all) {
+		load_emerg = 0;
+	} else {
+		load_emerg = Alert::prompt(_("Load emergency save?"), text,
+			0, 2, _("&Recover"), _("&Load Original"),
+			_("&Cancel"), _("Recover &All"));
+		if (load_emerg == 3) {
+			load_emerg = 0;
+			recover_all = true;
+		}
+	}
+
 	switch (load_emerg)
 	{
 	case 0: {

Reply via email to