changeset 47394:e48ab1d671be

(Fdo_auto_save): Catch error making directory. Only call push_message if we need to. At the same time, make an unwind-protect to pop it. Rename local message_p to old_message_p. (do_auto_save_make_dir, do_auto_save_eh): New functions. (do_auto_save_unwind): Don't call pop_message.
author Richard M. Stallman <rms@gnu.org>
date Wed, 11 Sep 2002 02:03:24 +0000
parents 38bf43c3fb05
children 97c7b4d723f9
files src/fileio.c
diffstat 1 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Wed Sep 11 01:59:33 2002 +0000
+++ b/src/fileio.c	Wed Sep 11 02:03:24 2002 +0000
@@ -5566,7 +5566,6 @@
   if (!NILP (stream))
     fclose ((FILE *) (XFASTINT (XCAR (stream)) << 16
 		      | XFASTINT (XCDR (stream))));
-  pop_message ();
   return Qnil;
 }
 
@@ -5578,6 +5577,20 @@
   return Qnil;
 }
 
+static Lisp_Object
+do_auto_save_make_dir (dir)
+     Lisp_Object dir;
+{
+  return call2 (Qmake_directory, dir, Qt);
+}
+
+static Lisp_Object
+do_auto_save_eh (ignore)
+     Lisp_Object ignore;
+{
+  return Qnil;
+}
+
 DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "",
        doc: /* Auto-save all buffers that need it.
 This is all buffers that have auto-saving enabled
@@ -5601,7 +5614,7 @@
   Lisp_Object lispstream;
   int count = SPECPDL_INDEX ();
   int orig_minibuffer_auto_raise = minibuffer_auto_raise;
-  int message_p = 0;
+  int old_message_p = 0;
 
   if (max_specpdl_size < specpdl_size + 40)
     max_specpdl_size = specpdl_size + 40;
@@ -5609,8 +5622,11 @@
   if (minibuf_level)
     no_message = Qt;
 
-  if (NILP (no_message));
-    message_p = push_message ();
+  if (NILP (no_message))
+    {
+      old_message_p = push_message ();
+      record_unwind_protect (pop_message_unwind, Qnil);
+    }
   
   /* Ordinarily don't quit within this function,
      but don't make it impossible to quit (in case we get hung in I/O).  */
@@ -5637,7 +5653,9 @@
 	  Lisp_Object dir;
 	  dir = Ffile_name_directory (listfile);
 	  if (NILP (Ffile_directory_p (dir)))
-	    call2 (Qmake_directory, dir, Qt);
+	    internal_condition_case_1 (do_auto_save_make_dir,
+				       dir, Fcons (Fcons (Qfile_error, Qnil), Qnil),
+				       do_auto_save_eh);
 	}
       
       stream = fopen (SDATA (listfile), "w");
@@ -5765,17 +5783,22 @@
 
   if (auto_saved && NILP (no_message))
     {
-      if (message_p)
+      if (old_message_p)
 	{
+	  /* If we are going to restore an old message,
+	     give time to read ours.  */
 	  sit_for (1, 0, 0, 0, 0);
 	  restore_message ();
 	}
       else
+	/* If we displayed a message and then restored a state
+	   with no message, leave a "done" message on the screen.  */
 	message1 ("Auto-saving...done");
     }
 
   Vquit_flag = oquit;
 
+  /* This restores the message-stack status.  */
   unbind_to (count, Qnil);
   return Qnil;
 }