[HAVE_UNISTD_H]: Include unistd.h.
[bpt/emacs.git] / src / fileio.c
index c462c27..cda8807 100644 (file)
@@ -22,6 +22,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 #if !defined (S_ISLNK) && defined (S_IFLNK)
 #  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
 #endif
@@ -44,7 +48,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <ctype.h>
 
 #ifdef VMS
-#include "dir.h"
+#include "vmsdir.h"
 #include <perror.h>
 #include <stddef.h>
 #include <string.h>
@@ -125,6 +129,8 @@ int insert_default_directory;
    Zero means use var format.  */
 int vms_stmlf_recfm;
 
+static Lisp_Object Vinhibit_file_name_handlers;
+
 Lisp_Object Qfile_error, Qfile_already_exists;
 
 Lisp_Object Qfile_name_history;
@@ -154,6 +160,15 @@ close_file_unwind (fd)
 {
   close (XFASTINT (fd));
 }
+
+/* Restore point, having saved it as a marker.  */
+
+restore_point_unwind (location)
+     Lisp_Object location; 
+{
+  SET_PT (marker_position (location));
+  Fset_marker (location, Qnil, Qnil);
+}
 \f
 Lisp_Object Qexpand_file_name;
 Lisp_Object Qdirectory_file_name;
@@ -187,7 +202,10 @@ DEFUN ("find-file-name-handler", Ffind_file_name_handler, Sfind_file_name_handle
   "Return FILENAME's handler function, if its syntax is handled specially.\n\
 Otherwise, return nil.\n\
 A file name is handled if one of the regular expressions in\n\
-`file-name-handler-alist' matches it.")
+`file-name-handler-alist' matches it.\n\n\
+If FILENAME is a member of `inhibit-file-name-handlers',\n\
+then its handler is not run.  This is lets handlers\n\
+use the standard functions without calling themselves recursively.")
   (filename)
     Lisp_Object filename;
 {
@@ -196,6 +214,19 @@ A file name is handled if one of the regular expressions in\n\
 
   CHECK_STRING (filename, 0);
 
+  if (! NILP (Vinhibit_file_name_handlers))
+    {
+      Lisp_Object tail;
+      for (tail = Vinhibit_file_name_handlers; CONSP (tail);
+          tail = XCONS (tail)->cdr)
+       {
+         Lisp_Object tem;
+         tem = Fstring_equal (tail, filename);
+         if (!NILP (tem))
+           return Qnil;
+       }
+    }
+
   for (chain = Vfile_name_handler_alist; XTYPE (chain) == Lisp_Cons;
        chain = XCONS (chain)->cdr)
     {
@@ -1527,13 +1558,6 @@ duplicates what `expand-file-name' does.")
 
        /* Get variable value */
        o = (unsigned char *) egetenv (target);
-/* The presence of this code makes vax 5.0 crash, for reasons yet unknown */
-#if 0
-#ifdef USG
-       if (!o && !strcmp (target, "USER"))
-         o = egetenv ("LOGNAME");
-#endif /* USG */
-#endif /* 0 */
        if (!o) goto badvar;
        total += strlen (o);
        substituted = 1;
@@ -1585,13 +1609,6 @@ duplicates what `expand-file-name' does.")
 
        /* Get variable value */
        o = (unsigned char *) egetenv (target);
-/* The presence of this code makes vax 5.0 crash, for reasons yet unknown */
-#if 0
-#ifdef USG
-       if (!o && !strcmp (target, "USER"))
-         o = egetenv ("LOGNAME");
-#endif /* USG */
-#endif /* 0 */
        if (!o)
          goto badvar;
 
@@ -1720,8 +1737,8 @@ A prefix arg makes KEEP-TIME non-nil.")
   if (NILP (handler))
     handler = Ffind_file_name_handler (newname);
   if (!NILP (handler))
-    return call5 (handler, Qcopy_file, filename, newname,
-                 ok_if_already_exists, keep_date);
+    RETURN_UNGCPRO (call5 (handler, Qcopy_file, filename, newname,
+                          ok_if_already_exists, keep_date));
 
   if (NILP (ok_if_already_exists)
       || XTYPE (ok_if_already_exists) == Lisp_Int)
@@ -1895,8 +1912,8 @@ This is what happens in interactive use with M-x.")
   if (NILP (handler))
     handler = Ffind_file_name_handler (newname);
   if (!NILP (handler))
-    return call4 (handler, Qrename_file,
-                 filename, newname, ok_if_already_exists);
+    RETURN_UNGCPRO (call4 (handler, Qrename_file,
+                          filename, newname, ok_if_already_exists));
 
   if (NILP (ok_if_already_exists)
       || XTYPE (ok_if_already_exists) == Lisp_Int)
@@ -1958,8 +1975,8 @@ This is what happens in interactive use with M-x.")
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (filename);
   if (!NILP (handler))
-    return call4 (handler, Qadd_name_to_file, filename, newname,
-                 ok_if_already_exists);
+    RETURN_UNGCPRO (call4 (handler, Qadd_name_to_file, filename,
+                          newname, ok_if_already_exists));
 
   if (NILP (ok_if_already_exists)
       || XTYPE (ok_if_already_exists) == Lisp_Int)
@@ -2012,8 +2029,8 @@ This happens for interactive use with M-x.")
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (filename);
   if (!NILP (handler))
-    return call4 (handler, Qmake_symbolic_link, filename, linkname,
-                 ok_if_already_exists);
+    RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename,
+                          linkname, ok_if_already_exists));
 
   if (NILP (ok_if_already_exists)
       || XTYPE (ok_if_already_exists) == Lisp_Int)
@@ -2182,9 +2199,9 @@ See also `file-exists-p' and `file-attributes'.")
 }
 
 DEFUN ("file-symlink-p", Ffile_symlink_p, Sfile_symlink_p, 1, 1, 0,
-  "If file FILENAME is the name of a symbolic link\n\
-returns the name of the file to which it is linked.\n\
-Otherwise returns NIL.")
+  "Return non-nil if file FILENAME is the name of a symbolic link.\n\
+The value is the name of the file to which it is linked.\n\
+Otherwise returns nil.")
   (filename)
      Lisp_Object filename;
 {
@@ -2357,6 +2374,19 @@ DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0,
 
   if (stat (XSTRING (abspath)->data, &st) < 0)
     return Qnil;
+#ifdef MSDOS
+  {
+    int len;
+    char *suffix;
+    if (S_ISREG (st.st_mode)
+       && (len = XSTRING (abspath)->size) >= 5
+       && (stricmp ((suffix = XSTRING (abspath)->data + len-4), ".com") == 0
+           || stricmp (suffix, ".exe") == 0
+           || stricmp (suffix, ".bat") == 0))
+      st.st_mode |= S_IEXEC;
+  }
+#endif /* MSDOS */
+
   return make_number (st.st_mode & 07777);
 }
 
@@ -2499,7 +2529,7 @@ Lisp_Object Qfind_buffer_file_type;
 #endif
 
 DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents,
-  1, 4, 0,
+  1, 5, 0,
   "Insert contents of file FILENAME after point.\n\
 Returns list of absolute file name and length of data inserted.\n\
 If second argument VISIT is non-nil, the buffer's visited filename\n\
@@ -2508,9 +2538,14 @@ If visiting and the file does not exist, visiting is completed\n\
 before the error is signaled.\n\n\
 The optional third and fourth arguments BEG and END\n\
 specify what portion of the file to insert.\n\
-If VISIT is non-nil, BEG and END must be nil.")
-  (filename, visit, beg, end)
-     Lisp_Object filename, visit, beg, end;
+If VISIT is non-nil, BEG and END must be nil.\n\
+If optional fifth argument REPLACE is non-nil,\n\
+it means replace the current buffer contents (in the accessible portion)\n\
+with the file contents.  This is better than simply deleting and inserting\n\
+the whole thing because (1) it preserves some marker positions\n\
+and (2) it puts less data in the undo list.")
+  (filename, visit, beg, end, replace)
+     Lisp_Object filename, visit, beg, end, replace;
 {
   struct stat st;
   register int fd;
@@ -2537,7 +2572,8 @@ If VISIT is non-nil, BEG and END must be nil.")
   handler = Ffind_file_name_handler (filename);
   if (!NILP (handler))
     {
-      val = call5 (handler, Qinsert_file_contents, filename, visit, beg, end);
+      val = call6 (handler, Qinsert_file_contents, filename,
+                  visit, beg, end, replace);
       goto handled;
     }
 
@@ -2559,6 +2595,10 @@ If VISIT is non-nil, BEG and END must be nil.")
       goto notfound;
     }
 
+  /* Replacement should preserve point as it preserves markers.  */
+  if (!NILP (replace))
+    record_unwind_protect (restore_point_unwind, Fpoint_marker ());
+
   record_unwind_protect (close_file_unwind, make_number (fd));
 
 #ifdef S_IFSOCK
@@ -2593,6 +2633,103 @@ If VISIT is non-nil, BEG and END must be nil.")
        error ("maximum buffer size exceeded");
     }
 
+  /* 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;
+     that preserves markers pointing to the unchanged parts.  */
+  if (!NILP (replace))
+    {
+      char buffer[1 << 14];
+      int same_at_start = BEGV;
+      int same_at_end = ZV;
+      int overlap;
+
+      immediate_quit = 1;
+      QUIT;
+      /* Count how many chars at the start of the file
+        match the text at the beginning of the buffer.  */
+      while (1)
+       {
+         int nread, bufpos;
+
+         nread = read (fd, buffer, sizeof buffer);
+         if (nread < 0)
+           error ("IO error reading %s: %s",
+                  XSTRING (filename)->data, strerror (errno));
+         else if (nread == 0)
+           break;
+         bufpos = 0;
+         while (bufpos < nread && same_at_start < ZV
+                && FETCH_CHAR (same_at_start) == buffer[bufpos])
+           same_at_start++, bufpos++;
+         /* If we found a discrepancy, stop the scan.
+            Otherwise loop around and scan the next bufferfull.  */
+         if (bufpos != nread)
+           break;
+       }
+      immediate_quit = 0;
+      /* If the file matches the buffer completely,
+        there's no need to replace anything.  */
+      if (same_at_start == ZV)
+       {
+         close (fd);
+         specpdl_ptr--;
+         goto handled;
+       }
+      immediate_quit = 1;
+      QUIT;
+      /* Count how many chars at the end of the file
+        match the text at the end of the buffer.  */
+      while (1)
+       {
+         int total_read, nread, bufpos, curpos, trial;
+
+         /* At what file position are we now scanning?  */
+         curpos = st.st_size - (ZV - same_at_end);
+         /* How much can we scan in the next step?  */
+         trial = min (curpos, sizeof buffer);
+         if (lseek (fd, curpos - trial, 0) < 0)
+           report_file_error ("Setting file position",
+                              Fcons (filename, Qnil));
+
+         total_read = 0;
+         while (total_read < trial)
+           {
+             nread = read (fd, buffer + total_read, trial - total_read);
+             if (nread <= 0)
+               error ("IO error reading %s: %s",
+                      XSTRING (filename)->data, strerror (errno));
+             total_read += nread;
+           }
+         /* Scan this bufferfull from the end, comparing with
+            the Emacs buffer.  */
+         bufpos = total_read;
+         /* Compare with same_at_start to avoid counting some buffer text
+            as matching both at the file's beginning and at the end.  */
+         while (bufpos > 0 && same_at_end > same_at_start
+                && FETCH_CHAR (same_at_end - 1) == buffer[bufpos - 1])
+           same_at_end--, bufpos--;
+         /* If we found a discrepancy, stop the scan.
+            Otherwise loop around and scan the preceding bufferfull.  */
+         if (bufpos != 0)
+           break;
+       }
+      immediate_quit = 0;
+
+      /* Don't try to reuse the same piece of text twice.  */
+      overlap = same_at_start - BEGV - (same_at_end + st.st_size - ZV);
+      if (overlap > 0)
+       same_at_end += overlap;
+
+      /* Arrange to read only the nonmatching middle part of the file.  */
+      XFASTINT (beg) = same_at_start - BEGV;
+      XFASTINT (end) = st.st_size - (ZV - same_at_end);
+
+      del_range_1 (same_at_start, same_at_end, 0);
+      /* Insert from the file at the proper position.  */
+      SET_PT (same_at_start);
+    }
+
   total = XINT (end) - XINT (beg);
 
   {
@@ -2611,13 +2748,14 @@ If VISIT is non-nil, BEG and END must be nil.")
   if (GAP_SIZE < total)
     make_gap (total - GAP_SIZE);
 
-  if (XINT (beg) != 0)
+  if (XINT (beg) != 0 || !NILP (replace))
     {
       if (lseek (fd, XINT (beg), 0) < 0)
        report_file_error ("Setting file position", Fcons (filename, Qnil));
     }
 
-  while (1)
+  how_much = 0;
+  while (inserted < total)
     {
       int try = min (total - inserted, 64 << 10);
       int this;
@@ -2647,7 +2785,8 @@ If VISIT is non-nil, BEG and END must be nil.")
      is deemed to be a text file.  */
   {
     struct gcpro gcpro1;
-    Lisp_Object code = Qnil;
+    Lisp_Object code;
+    code = Qnil;
     GCPRO1 (filename);
     code = call1 (Qfind_buffer_file_type, filename);
     UNGCPRO;
@@ -2655,8 +2794,8 @@ If VISIT is non-nil, BEG and END must be nil.")
       XFASTINT (current_buffer->buffer_file_type) = XFASTINT (code);
     if (XFASTINT (current_buffer->buffer_file_type) == 0)
       {
-       int reduced_size = 
-         inserted - crlf_to_lf (inserted, &FETCH_CHAR (point - 1) + 1);
+       int reduced_size
+         inserted - crlf_to_lf (inserted, &FETCH_CHAR (point - 1) + 1);
        ZV -= reduced_size;
        Z -= reduced_size;
        GPT -= reduced_size;
@@ -2677,8 +2816,8 @@ If VISIT is non-nil, BEG and END must be nil.")
 
   close (fd);
 
-  /* Discard the unwind protect */
-  specpdl_ptr = specpdl + count;
+  /* Discard the unwind protect for closing the file.  */
+  specpdl_ptr--;
 
   if (how_much < 0)
     error ("IO error reading %s: %s",
@@ -2689,7 +2828,8 @@ If VISIT is non-nil, BEG and END must be nil.")
 
   if (!NILP (visit))
     {
-      current_buffer->undo_list = Qnil;
+      if (!EQ (current_buffer->undo_list, Qt))
+       current_buffer->undo_list = Qnil;
 #ifdef APOLLO
       stat (XSTRING (filename)->data, &st);
 #endif
@@ -2735,11 +2875,12 @@ If VISIT is non-nil, BEG and END must be nil.")
        }
     }
 
-  if (!NILP (val))
-    RETURN_UNGCPRO (val);
-  RETURN_UNGCPRO (Fcons (filename,
-                        Fcons (make_number (inserted),
-                               Qnil)));
+  if (NILP (val))
+    val = Fcons (filename,
+                Fcons (make_number (inserted),
+                       Qnil));
+
+  RETURN_UNGCPRO (unbind_to (count, val));
 }
 \f
 static Lisp_Object build_annotations ();
@@ -2803,6 +2944,9 @@ to the file, instead of any buffer contents, and END is ignored.")
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (filename);
+  /* If FILENAME has no handler, see if VISIT has one.  */
+  if (NILP (handler) && XTYPE (visit) == Lisp_String)
+    handler = Ffind_file_name_handler (visit);    
 
   if (!NILP (handler))
     {
@@ -3311,7 +3455,8 @@ This is all buffers that have auto-saving enabled\n\
 and are changed since last auto-saved.\n\
 Auto-saving writes the buffer into a file\n\
 so that your editing is not lost if the system crashes.\n\
-This file is not the file you visited; that changes only when you save.\n\n\
+This file is not the file you visited; that changes only when you save.\n\
+Normally we run the normal hook `auto-save-hook' before saving.\n\n\
 Non-nil first argument means do not print any message if successful.\n\
 Non-nil second argument means save only current buffer.")
   (no_message, current_only)
@@ -3321,6 +3466,7 @@ Non-nil second argument means save only current buffer.")
   Lisp_Object tail, buf;
   int auto_saved = 0;
   char *omessage = echo_area_glyphs;
+  int omessage_length = echo_area_glyphs_length;
   extern int minibuf_level;
   int do_handled_files;
   Lisp_Object oquit;
@@ -3337,8 +3483,6 @@ Non-nil second argument means save only current buffer.")
   if (minibuf_level)
     no_message = Qt;
 
-  /* Vrun_hooks is nil before emacs is dumped, and inc-vers.el will
-     eventually call do-auto-save, so don't err here in that case. */
   if (!NILP (Vrun_hooks))
     call1 (Vrun_hooks, intern ("auto-save-hook"));
 
@@ -3364,9 +3508,20 @@ Non-nil second argument means save only current buffer.")
        if (XTYPE (b->auto_save_file_name) == Lisp_String
            && b->save_modified < BUF_MODIFF (b)
            && b->auto_save_modified < BUF_MODIFF (b)
+           /* -1 means we've turned off autosaving for a while--see below.  */
+           && XINT (b->save_length) >= 0
            && (do_handled_files
                || NILP (Ffind_file_name_handler (b->auto_save_file_name))))
          {
+           EMACS_TIME before_time, after_time;
+
+           EMACS_GET_TIME (before_time);
+
+           /* If we had a failure, don't try again for 20 minutes.  */
+           if (b->auto_save_failure_time >= 0
+               && EMACS_SECS (before_time) - b->auto_save_failure_time < 1200)
+             continue;
+
            if ((XFASTINT (b->save_length) * 10
                 > (BUF_Z (b) - BUF_BEG (b)) * 13)
                /* A short file is likely to change a large fraction;
@@ -3379,10 +3534,9 @@ Non-nil second argument means save only current buffer.")
                /* It has shrunk too much; turn off auto-saving here.  */
                message ("Buffer %s has shrunk a lot; auto save turned off there",
                         XSTRING (b->name)->data);
-               /* User can reenable saving with M-x auto-save.  */
-               b->auto_save_file_name = Qnil;
-               /* Prevent warning from repeating if user does so.  */
-               XFASTINT (b->save_length) = 0;
+               /* Turn off auto-saving until there's a real save,
+                  and prevent any more warnings.  */
+               XSET (b->save_length, Lisp_Int, -1);
                Fsleep_for (make_number (1), Qnil);
                continue;
              }
@@ -3394,6 +3548,13 @@ Non-nil second argument means save only current buffer.")
            b->auto_save_modified = BUF_MODIFF (b);
            XFASTINT (current_buffer->save_length) = Z - BEG;
            set_buffer_internal (old);
+
+           EMACS_GET_TIME (after_time);
+
+           /* If auto-save took more than 60 seconds,
+              assume it was an NFS failure that got a timeout.  */
+           if (EMACS_SECS (after_time) - EMACS_SECS (before_time) > 60)
+             b->auto_save_failure_time = EMACS_SECS (after_time);
          }
       }
 
@@ -3401,7 +3562,12 @@ Non-nil second argument means save only current buffer.")
   record_auto_save ();
 
   if (auto_saved && NILP (no_message))
-    message1 (omessage ? omessage : "Auto-saving...done");
+    {
+      if (omessage)
+       message2 (omessage, omessage_length);
+      else
+       message1 ("Auto-saving...done");
+    }
 
   Vquit_flag = oquit;
 
@@ -3417,6 +3583,16 @@ No auto-save file will be written until the buffer changes again.")
 {
   current_buffer->auto_save_modified = MODIFF;
   XFASTINT (current_buffer->save_length) = Z - BEG;
+  current_buffer->auto_save_failure_time = -1;
+  return Qnil;
+}
+
+DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure,
+  Sclear_buffer_auto_save_failure, 0, 0, 0,
+  "Clear any record of a recent auto-save failure in the current buffer.")
+  ()
+{
+  current_buffer->auto_save_failure_time = -1;
   return Qnil;
 }
 
@@ -3431,6 +3607,38 @@ DEFUN ("recent-auto-save-p", Frecent_auto_save_p, Srecent_auto_save_p,
 /* Reading and completing file names */
 extern Lisp_Object Ffile_name_completion (), Ffile_name_all_completions ();
 
+/* In the string VAL, change each $ to $$ and return the result.  */
+
+static Lisp_Object
+double_dollars (val)
+     Lisp_Object val;
+{
+  register unsigned char *old, *new;
+  register int n;
+  int osize, count;
+
+  osize = XSTRING (val)->size;
+  /* Quote "$" as "$$" to get it past substitute-in-file-name */
+  for (n = osize, count = 0, old = XSTRING (val)->data; n > 0; n--)
+    if (*old++ == '$') count++;
+  if (count > 0)
+    {
+      old = XSTRING (val)->data;
+      val = Fmake_string (make_number (osize + count), make_number (0));
+      new = XSTRING (val)->data;
+      for (n = osize; n > 0; n--)
+       if (*old != '$')
+         *new++ = *old++;
+       else
+         {
+           *new++ = '$';
+           *new++ = '$';
+           old++;
+         }
+    }
+  return val;
+}
+
 DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_internal,
   3, 3, 0,
   "Internal subroutine for read-file-name.  Do not call this.")
@@ -3485,33 +3693,10 @@ DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_inte
       if (!NILP (specdir))
        val = concat2 (specdir, val);
 #ifndef VMS
-      {
-       register unsigned char *old, *new;
-       register int n;
-       int osize, count;
-
-       osize = XSTRING (val)->size;
-       /* Quote "$" as "$$" to get it past substitute-in-file-name */
-       for (n = osize, count = 0, old = XSTRING (val)->data; n > 0; n--)
-         if (*old++ == '$') count++;
-       if (count > 0)
-         {
-           old = XSTRING (val)->data;
-           val = Fmake_string (make_number (osize + count), make_number (0));
-           new = XSTRING (val)->data;
-           for (n = osize; n > 0; n--)
-             if (*old != '$')
-               *new++ = *old++;
-             else
-               {
-                 *new++ = '$';
-                 *new++ = '$';
-                 old++;
-               }
-         }
-      }
-#endif /* Not VMS */
+      return double_dollars (val);
+#else /* not VMS */
       return val;
+#endif /* not VMS */
     }
   UNGCPRO;
 
@@ -3564,7 +3749,6 @@ DIR defaults to current buffer's directory default.")
   if (insert_default_directory)
     {
       insdef = dir;
-      insdef1 = dir;
       if (!NILP (initial))
        {
          Lisp_Object args[2], pos;
@@ -3572,9 +3756,16 @@ DIR defaults to current buffer's directory default.")
          args[0] = insdef;
          args[1] = initial;
          insdef = Fconcat (2, args);
-         pos = make_number (XSTRING (dir)->size);
-         insdef1 = Fcons (insdef, pos);
+         pos = make_number (XSTRING (double_dollars (dir))->size);
+         insdef1 = Fcons (double_dollars (insdef), pos);
        }
+      else
+       insdef1 = double_dollars (insdef);
+    }
+  else if (!NILP (initial))
+    {
+      insdef = initial;
+      insdef1 = Fcons (double_dollars (insdef), 0);
     }
   else
     insdef = Qnil, insdef1 = Qnil;
@@ -3611,14 +3802,9 @@ DIR defaults to current buffer's directory default.")
 
 #if 0                          /* Old version */
 DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 5, 0,
-  "Read file name, prompting with PROMPT and completing in directory DIR.\n\
-Value is not expanded---you must call `expand-file-name' yourself.\n\
-Default name to DEFAULT if user enters a null string.\n\
- (If DEFAULT is omitted, the visited file name is used.)\n\
-Fourth arg MUSTMATCH non-nil means require existing file's name.\n\
- Non-nil and non-t means also require confirmation after completion.\n\
-Fifth arg INITIAL specifies text to start with.\n\
-DIR defaults to current buffer's directory default.")
+  /* Don't confuse make-docfile by having two doc strings for this function.
+     make-docfile does not pay attention to #if, for good reason!  */
+  0)
   (prompt, dir, defalt, mustmatch, initial)
      Lisp_Object prompt, dir, defalt, mustmatch, initial;
 {
@@ -3803,6 +3989,10 @@ increasing order.  If there are several functions in the list, the several\n\
 lists are merged destructively.");
   Vwrite_region_annotate_functions = Qnil;
 
+  DEFVAR_LISP ("inhibit-file-name-handlers", &Vinhibit_file_name_handlers,
+    "A list of file names for which handlers should not be used.");
+  Vinhibit_file_name_handlers = Qnil;
+
   defsubr (&Sfind_file_name_handler);
   defsubr (&Sfile_name_directory);
   defsubr (&Sfile_name_nondirectory);
@@ -3849,6 +4039,7 @@ lists are merged destructively.");
   defsubr (&Sset_visited_file_modtime);
   defsubr (&Sdo_auto_save);
   defsubr (&Sset_buffer_auto_saved);
+  defsubr (&Sclear_buffer_auto_save_failure);
   defsubr (&Srecent_auto_save_p);
 
   defsubr (&Sread_file_name_internal);