changeset 57955:4d54b75d8567

(Ffile_modes): Doc fix. (auto_save_1): Check for Ffile_modes nil value.
author Kim F. Storm <storm@cua.dk>
date Fri, 05 Nov 2004 12:32:41 +0000
parents 328dc625a959
children e0f275e4488a
files src/fileio.c
diffstat 1 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Fri Nov 05 11:31:03 2004 +0000
+++ b/src/fileio.c	Fri Nov 05 12:32:41 2004 +0000
@@ -3366,7 +3366,8 @@
 }
 
 DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0,
-       doc: /* Return mode bits of file named FILENAME, as an integer.  */)
+       doc: /* Return mode bits of file named FILENAME, as an integer.
+Return nil, if file does not exist or is not accessible.  */)
      (filename)
      Lisp_Object filename;
 {
@@ -5712,17 +5713,21 @@
 auto_save_1 ()
 {
   struct stat st;
+  Lisp_Object modes;
+
+  auto_save_mode_bits = 0666;
 
   /* Get visited file's mode to become the auto save file's mode.  */
-  if (! NILP (current_buffer->filename)
-      && stat (SDATA (current_buffer->filename), &st) >= 0)
-    /* But make sure we can overwrite it later!  */
-    auto_save_mode_bits = st.st_mode | 0600;
-  else if (! NILP (current_buffer->filename))
-    /* Remote files don't cooperate with stat.  */
-    auto_save_mode_bits = XINT (Ffile_modes (current_buffer->filename)) | 0600;
-  else
-    auto_save_mode_bits = 0666;
+  if (! NILP (current_buffer->filename))
+    {
+      if (stat (SDATA (current_buffer->filename), &st) >= 0)
+	/* But make sure we can overwrite it later!  */
+	auto_save_mode_bits = st.st_mode | 0600;
+      else if ((modes = Ffile_modes (current_buffer->filename),
+		INTEGERP (modes)))
+	/* Remote files don't cooperate with stat.  */
+	auto_save_mode_bits = XINT (modes) | 0600;
+    }
 
   return
     Fwrite_region (Qnil, Qnil,
@@ -6190,7 +6195,7 @@
 #endif
   return Qnil;
 }
-       
+
 DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0,
        doc: /* Read file name, prompting with PROMPT and completing in directory DIR.
 Value is not expanded---you must call `expand-file-name' yourself.