]> code.delx.au - gnu-emacs/blobdiff - src/fileio.c
(Vloads_in_progress): New variable.
[gnu-emacs] / src / fileio.c
index 19d80a9d2f0df72d382f03f25369765ed6331935..b5b9213d8957fbe919b7be63d5285154ebf83707 100644 (file)
@@ -65,8 +65,10 @@ Boston, MA 02111-1307, USA.  */
 #include <errno.h>
 
 #ifndef vax11c
+#ifndef USE_CRT_DLL
 extern int errno;
 #endif
+#endif
 
 #ifdef APOLLO
 #include <sys/time.h>
@@ -950,7 +952,7 @@ make_temp_name (prefix, base64_p)
               in looping through 225307 stat's, which is not only
               dog-slow, but also useless since it will fallback to
               the errow below, anyway.  */
-           report_file_error ("Cannot create temporary name for prefix `%s'",
+           report_file_error ("Cannot create temporary name for prefix",
                               Fcons (prefix, Qnil));
          /* not reached */
        }
@@ -2546,6 +2548,12 @@ This is what happens in interactive use with M-x.")
   encoded_file = ENCODE_FILE (file);
   encoded_newname = ENCODE_FILE (newname);
 
+#ifdef DOS_NT
+  /* If the file names are identical but for the case, don't ask for
+     confirmation: they simply want to change the letter-case of the
+     file name.  */
+  if (NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname))))
+#endif
   if (NILP (ok_if_already_exists)
       || INTEGERP (ok_if_already_exists))
     barf_or_query_if_file_exists (encoded_newname, "rename to it",
@@ -3643,6 +3651,8 @@ actually used.")
        }
 
       setup_coding_system (Fcheck_coding_system (val), &coding);
+      /* Ensure we set Vlast_coding_system_used.  */
+      set_coding_system = 1;
 
       if (NILP (current_buffer->enable_multibyte_characters)
          && ! NILP (val))
@@ -3656,9 +3666,6 @@ actually used.")
       coding_system_decided = 1;
     }
 
-  /* Ensure we always set Vlast_coding_system_used.  */
-  set_coding_system = 1;
-
   /* If requested, replace the accessible part of the buffer
      with the file contents.  Avoid replacing text at the
      beginning or end of the buffer that matches the file contents;
@@ -4034,7 +4041,7 @@ actually used.")
       /* Set `inserted' to the number of inserted characters.  */
       inserted = PT - temp;
 
-      free (conversion_buffer);
+      xfree (conversion_buffer);
       emacs_close (fd);
       specpdl_ptr--;
 
@@ -4133,6 +4140,8 @@ actually used.")
     error ("IO error reading %s: %s",
           XSTRING (orig_filename)->data, emacs_strerror (errno));
 
+ notfound:
+
   if (! coding_system_decided)
     {
       /* The coding system is not yet decided.  Decide it by an
@@ -4195,12 +4204,17 @@ actually used.")
        setup_coding_system (val, &temp_coding);
        bcopy (&temp_coding, &coding, sizeof coding);
       }
+      /* Ensure we set Vlast_coding_system_used.  */
+      set_coding_system = 1;
 
       if (NILP (current_buffer->enable_multibyte_characters)
          && ! NILP (val))
        /* We must suppress all character code conversion except for
           end-of-line conversion.  */
        setup_raw_text_coding_system (&coding);
+      coding.src_multibyte = 0;
+      coding.dst_multibyte
+       = !NILP (current_buffer->enable_multibyte_characters);
     }
 
   if (!NILP (visit)
@@ -4238,7 +4252,6 @@ actually used.")
     current_buffer->buffer_file_type = Qnil;
 #endif
 
- notfound:
  handled:
 
   if (!NILP (visit))
@@ -4270,10 +4283,6 @@ actually used.")
        Fsignal (Qfile_error,
                 Fcons (build_string ("not a regular file"),
                        Fcons (orig_filename, Qnil)));
-
-      /* If visiting nonexistent file, return nil.  */
-      if (current_buffer->modtime == -1)
-       report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
     }
 
   /* Decode file format */
@@ -4298,20 +4307,24 @@ actually used.")
       update_compositions (PT, PT, CHECK_BORDER);
     }
 
-  if (inserted > 0)
+  p = Vafter_insert_file_functions;
+  while (!NILP (p))
     {
-      p = Vafter_insert_file_functions;
-      while (!NILP (p))
+      insval = call1 (Fcar (p), make_number (inserted));
+      if (!NILP (insval))
        {
-         insval = call1 (Fcar (p), make_number (inserted));
-         if (!NILP (insval))
-           {
-             CHECK_NUMBER (insval, 0);
-             inserted = XFASTINT (insval);
-           }
-         QUIT;
-         p = Fcdr (p);
+         CHECK_NUMBER (insval, 0);
+         inserted = XFASTINT (insval);
        }
+      QUIT;
+      p = Fcdr (p);
+    }
+
+  if (!NILP (visit)
+      && current_buffer->modtime == -1)
+    {
+      /* If visiting nonexistent file, return nil.  */
+      report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
     }
 
   /* ??? Retval needs to be dealt with in all cases consistently.  */
@@ -4878,6 +4891,7 @@ build_annotations (start, end, pre_write_conversion)
   Lisp_Object p, res;
   struct gcpro gcpro1, gcpro2;
   Lisp_Object original_buffer;
+  int i;
 
   XSETBUFFER (original_buffer, current_buffer);
 
@@ -4910,21 +4924,26 @@ build_annotations (start, end, pre_write_conversion)
     p = Vauto_save_file_format;
   else
     p = current_buffer->file_format;
-  while (!NILP (p))
+  for (i = 0; !NILP (p); p = Fcdr (p), ++i)
     {
       struct buffer *given_buffer = current_buffer;
+      
       Vwrite_region_annotations_so_far = annotations;
-      res = call4 (Qformat_annotate_function, Fcar (p), start, end,
-                  original_buffer);
+
+      /* Value is either a list of annotations or nil if the function
+         has written annotations to a temporary buffer, which is now
+         current.  */
+      res = call5 (Qformat_annotate_function, Fcar (p), start, end,
+                  original_buffer, make_number (i));
       if (current_buffer != given_buffer)
        {
          XSETFASTINT (start, BEGV);
          XSETFASTINT (end, ZV);
          annotations = Qnil;
        }
-      Flength (res);
-      annotations = merge (annotations, res, Qcar_less_than_car);
-      p = Fcdr (p);
+      
+      if (CONSP (res))
+       annotations = merge (annotations, res, Qcar_less_than_car);
     }
 
   /* At last, do the same for the function PRE_WRITE_CONVERSION
@@ -5082,6 +5101,10 @@ e_write (desc, string, start, end, coding)
       if (coding->cmp_data)
        coding_adjust_composition_offset (coding, start);
     }
+
+  if (coding->cmp_data)
+    coding_free_composition_data (coding);
+
   return return_val;
 }
 \f
@@ -5660,7 +5683,7 @@ DIR defaults to current buffer's directory default.")
 
   GCPRO2 (insdef, default_filename);
   
-#ifdef USE_MOTIF
+#if defined (USE_MOTIF) || defined (HAVE_NTGUI)
   if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
       && use_dialog_box
       && have_menus_p ())
@@ -5673,7 +5696,8 @@ DIR defaults to current buffer's directory default.")
          default_filename = file;
          dir = Ffile_name_directory (dir);
        }
-      default_filename = Fexpand_file_name (default_filename, dir);
+      if (!NILP(default_filename))
+        default_filename = Fexpand_file_name (default_filename, dir);
       val = Fx_file_dialog (prompt, dir, default_filename, mustmatch);
       add_to_history = 1;
     }