]> code.delx.au - gnu-emacs/blobdiff - src/fileio.c
*** empty log message ***
[gnu-emacs] / src / fileio.c
index aa37c296eb35248fe21127b9a31b6f5631f52270..7f73a55bce906abc742a6fc75bf176634b62e9c4 100644 (file)
@@ -148,6 +148,10 @@ extern int use_file_dialog;
 #  define lstat stat
 #endif
 
+#ifndef FILE_SYSTEM_CASE
+#define FILE_SYSTEM_CASE(filename)  (filename)
+#endif
+
 /* Nonzero during writing of auto-save files */
 int auto_saving;
 
@@ -228,6 +232,8 @@ extern int minibuf_level;
 
 extern int minibuffer_auto_raise;
 
+extern int history_delete_duplicates;
+
 /* These variables describe handlers that have "already" had a chance
    to handle the current operation.
 
@@ -411,9 +417,7 @@ on VMS, perhaps instead a string ending in `:', `]' or `>'.  */)
   if (!NILP (handler))
     return call2 (handler, Qfile_name_directory, filename);
 
-#ifdef FILE_SYSTEM_CASE
   filename = FILE_SYSTEM_CASE (filename);
-#endif
   beg = SDATA (filename);
 #ifdef DOS_NT
   beg = strcpy (alloca (strlen (beg) + 1), beg);
@@ -1118,14 +1122,7 @@ See also the function `substitute-in-file-name'.  */)
       UNGCPRO;
     }
 
-#ifdef VMS
-  /* Filenames on VMS are always upper case.  */
-  name = Fupcase (name);
-#endif
-#ifdef FILE_SYSTEM_CASE
   name = FILE_SYSTEM_CASE (name);
-#endif
-
   nm = SDATA (name);
 
 #ifdef DOS_NT
@@ -1225,23 +1222,23 @@ See also the function `substitute-in-file-name'.  */)
            slash = p;
          }
          if (p[0] == '-')
-#ifndef VMS4_4
-           /* VMS pre V4.4,convert '-'s in filenames. */
+#ifdef NO_HYPHENS_IN_FILENAMES
            if (lbrack == rbrack)
              {
-               if (dots < 2)   /* this is to allow negative version numbers */
+                /* Avoid clobbering negative version numbers.  */
+                if (dots < 2)
                  p[0] = '_';
              }
            else
-#endif /* VMS4_4 */
+#endif /* NO_HYPHENS_IN_FILENAMES */
              if (lbrack > rbrack &&
                  ((p[-1] == '.' || p[-1] == '[' || p[-1] == '<') &&
                   (p[1] == '.' || p[1] == ']' || p[1] == '>')))
                lose = 1;
-#ifndef VMS4_4
+#ifdef NO_HYPHENS_IN_FILENAMES
              else
                p[0] = '_';
-#endif /* VMS4_4 */
+#endif /* NO_HYPHENS_IN_FILENAMES */
          /* count open brackets, reset close bracket pointer */
          if (p[0] == '[' || p[0] == '<')
            lbrack++, brack = 0;
@@ -1621,12 +1618,12 @@ See also the function `substitute-in-file-name'.  */)
        }
       else
        {
-#ifndef VMS4_4
+#ifdef NO_HYPHENS_IN_FILENAMES
          if (*p == '-' &&
              o[-1] != '[' && o[-1] != '<' && o[-1] != '.' &&
              p[1] != ']' && p[1] != '>' && p[1] != '.')
            *p = '_';
-#endif /* VMS4_4 */
+#endif /* NO_HYPHENS_IN_FILENAMES */
          *o++ = *p++;
        }
 #else /* not VMS */
@@ -2388,10 +2385,10 @@ Signals a `file-already-exists' error if file NEWNAME already exists,
 unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil.
 A number as third arg means request confirmation if NEWNAME already exists.
 This is what happens in interactive use with M-x.
-Fourth arg KEEP-TIME non-nil means give the new file the same
+Always sets the file modes of the output file to match the input file.
+Fourth arg KEEP-TIME non-nil means give the output file the same
 last-modified time as the old one.  (This works on only some systems.)
-A prefix arg makes KEEP-TIME non-nil.
-Also set the file modes of the target file to match the source file.  */)
+A prefix arg makes KEEP-TIME non-nil.  */)
      (file, newname, ok_if_already_exists, keep_time)
      Lisp_Object file, newname, ok_if_already_exists, keep_time;
 {
@@ -3859,10 +3856,6 @@ actually used.  */)
 
       if (!NILP (Vcoding_system_for_read))
        val = Vcoding_system_for_read;
-      else if (! NILP (replace))
-       /* In REPLACE mode, we can use the same coding system
-          that was used to visit the file.  */
-       val = current_buffer->buffer_file_coding_system;
       else
        {
          /* Don't try looking inside a file for a coding system
@@ -4641,7 +4634,8 @@ actually used.  */)
 
   if (! NILP (Ffboundp (Qafter_insert_file_set_coding)))
     {
-      insval = call1 (Qafter_insert_file_set_coding, make_number (inserted));
+      insval = call2 (Qafter_insert_file_set_coding, make_number (inserted),
+                     visit);
       if (! NILP (insval))
        {
          CHECK_NUMBER (insval);
@@ -6186,7 +6180,7 @@ The return value is only relevant for a call to `read-file-name' that happens
 before any other event (mouse or keypress) is handeled.  */)
   ()
 {
-#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (TARGET_API_MAC_CARBON)
+#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (HAVE_CARBON)
   if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
       && use_dialog_box
       && use_file_dialog
@@ -6327,7 +6321,7 @@ and `read-file-name-function'.  */)
 
   GCPRO2 (insdef, default_filename);
 
-#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (TARGET_API_MAC_CARBON)
+#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (HAVE_CARBON)
   if (! NILP (Fnext_read_file_uses_dialog_p ()))
     {
       /* If DIR contains a file name, split it.  */
@@ -6383,7 +6377,13 @@ and `read-file-name-function'.  */)
   if (replace_in_history)
     /* Replace what Fcompleting_read added to the history
        with what we will actually return.  */
-    XSETCAR (Fsymbol_value (Qfile_name_history), double_dollars (val));
+    {
+       Lisp_Object val1 = double_dollars (val);
+       tem = Fsymbol_value (Qfile_name_history);
+       if (history_delete_duplicates)
+        XSETCDR (tem, Fdelete (val1, XCDR(tem)));
+       XSETCAR (tem, val1);
+    }
   else if (add_to_history)
     {
       /* Add the value to the history--but not if it matches
@@ -6391,8 +6391,10 @@ and `read-file-name-function'.  */)
       Lisp_Object val1 = double_dollars (val);
       tem = Fsymbol_value (Qfile_name_history);
       if (! CONSP (tem) || NILP (Fequal (XCAR (tem), val1)))
-       Fset (Qfile_name_history,
-             Fcons (val1, tem));
+       {
+         if (history_delete_duplicates) tem = Fdelete (val1, tem);
+         Fset (Qfile_name_history, Fcons (val1, tem));
+       }
     }
 
   return val;