(Frename_file): Avoid copying to trash if a rename involves a delete. (Bug#964).
authorGlenn Morris <rgm@gnu.org>
Sat, 20 Sep 2008 21:41:05 +0000 (21:41 +0000)
committerGlenn Morris <rgm@gnu.org>
Sat, 20 Sep 2008 21:41:05 +0000 (21:41 +0000)
src/ChangeLog
src/fileio.c

index c924125..55d4ce2 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-20  Glenn Morris  <rgm@gnu.org>
+
+       * fileio.c (Frename_file): Avoid copying to trash if a rename involves
+       a delete.  (Bug#964).
+
 2008-09-20  Eli Zaretskii  <eliz@gnu.org>
 
        * keyboard.c (Fset_quit_char, Fset_input_meta_mode)
index a5541d5..6a9364d 100644 (file)
@@ -2231,6 +2231,7 @@ This is what happens in interactive use with M-x.  */)
     {
       if (errno == EXDEV)
        {
+          int count;
 #ifdef S_IFLNK
           symlink_target = Ffile_symlink_p (file);
           if (! NILP (symlink_target))
@@ -2244,7 +2245,10 @@ This is what happens in interactive use with M-x.  */)
                        NILP (ok_if_already_exists) ? Qnil : Qt,
                        Qt, Qt);
 
+         count = SPECPDL_INDEX ();
+         specbind (intern ("delete-by-moving-to-trash"), Qnil);
          Fdelete_file (file);
+         unbind_to (count, Qnil);
        }
       else
        report_file_error ("Renaming", list2 (file, newname));