changeset 109207:4c39d84b5d9a

Merge from mainline.
author Katsumi Yamaoka <katsumi@flagship2>
date Sat, 29 May 2010 09:39:12 +0000
parents 922942081399 (current diff) 988b3f9a342a (diff)
children 0d144b53fe59
files
diffstat 12 files changed, 159 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/ChangeLog	Sat May 29 09:39:12 2010 +0000
@@ -1,3 +1,61 @@
+2010-05-29  Eli Zaretskii  <eliz@gnu.org>
+
+	* ls-lisp.el (ls-lisp-classify-file): New function.
+	(ls-lisp-insert-directory): Call it if switches include -F (bug#6294).
+	(ls-lisp-classify): Call ls-lisp-classify-file.
+	(insert-directory): Remove blanks from switches.
+
+2010-05-28  Juri Linkov  <juri@jurta.org>
+
+	* image-dired.el (image-dired-dired-toggle-marked-thumbs):
+	Replace LOCALP arg of `dired-get-filename' 'no-dir with nil.
+	(Bug#5270)
+
+2010-05-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-debug-message): Add `tramp-compat-funcall'
+	to ignored backtrace functions.
+	(with-progress-reporter): Expand docstring.
+	(tramp-handle-delete-file): Implement TRASH argument.
+	(tramp-get-remote-trash): New defun.
+
+2010-05-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp-compat.el (tramp-compat-delete-file): Use
+	`symbol-value' for backward compatibility.
+
+	* net/tramp.el (tramp-handle-make-symbolic-link)
+	(tramp-handle-load)
+	(tramp-do-copy-or-rename-file-via-buffer)
+	(tramp-do-copy-or-rename-file-directly)
+	(tramp-do-copy-or-rename-file-out-of-band)
+	(tramp-handle-process-file, tramp-handle-call-process-region)
+	(tramp-handle-shell-command, tramp-handle-file-local-copy)
+	(tramp-handle-insert-file-contents, tramp-handle-write-region)
+	(tramp-delete-temp-file-function): Use `delete-file' instead
+	of `tramp-compat-delete-file'.
+
+	* net/tramp-fish.el (tramp-fish-handle-delete-directory)
+	(tramp-fish-handle-make-symbolic-link)
+	(tramp-fish-handle-process-file): Use `delete-file' instead
+	of `tramp-compat-delete-file'.
+
+	* net/tramp-ftp.el (tramp-ftp-file-name-handler): Use
+	`delete-file' instead of `tramp-compat-delete-file'.
+
+	* net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Rename arg.
+	(tramp-gvfs-handle-write-region): Use `delete-file' instead of
+	`tramp-compat-delete-file'.
+
+	* net/tramp-imap.el (tramp-imap-do-copy-or-rename-file): Use
+	`delete-file' instead of `tramp-compat-delete-file'.
+
+	* net/tramp-smb.el (tramp-smb-handle-copy-file)
+	(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
+	(tramp-smb-handle-write-region): Use `delete-file' instead of
+	`tramp-compat-delete-file'.
+	(tramp-smb-handle-delete-directory): Use 'trash as arg.
+
 2010-05-27  Chong Yidong  <cyd@stupidchicken.com>
 
 	* dired.el (dired-delete-file): New arg TRASH.
--- a/lisp/image-dired.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/image-dired.el	Sat May 29 09:39:12 2010 +0000
@@ -642,7 +642,7 @@
   (interactive "P")
   (dired-map-over-marks
    (let* ((image-pos  (dired-move-to-filename))
-          (image-file (dired-get-filename 'no-dir t))
+          (image-file (dired-get-filename nil t))
           thumb-file
           overlay)
      (when (and image-file (string-match-p (image-file-name-regexp) image-file))
--- a/lisp/ls-lisp.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/ls-lisp.el	Sat May 29 09:39:12 2010 +0000
@@ -235,7 +235,7 @@
 	(if (string-match "--dired " switches)
 	    (setq switches (replace-match "" nil nil switches)))
 	;; Convert SWITCHES to a list of characters.
-	(setq switches (delete ?- (append switches nil)))
+	(setq switches (delete ?\  (delete ?- (append switches nil))))
 	;; Sometimes we get ".../foo*/" as FILE.  While the shell and
 	;; `ls' don't mind, we certainly do, because it makes us think
 	;; there is no wildcard, only a directory name.
@@ -405,7 +405,11 @@
 	(setq file (substring file 0 -1)))
     (let ((fattr (file-attributes file 'string)))
       (if fattr
-	  (insert (ls-lisp-format file fattr (nth 7 fattr)
+	  (insert (ls-lisp-format
+		   (if (memq ?F switches)
+		       (ls-lisp-classify-file file fattr)
+		     file)
+		   fattr (nth 7 fattr)
 				  switches time-index (current-time)))
 	(message "%s: doesn't exist or is inaccessible" file)
 	(ding) (sit-for 2)))))		; to show user the message!
@@ -522,29 +526,40 @@
       (nreverse file-alist)
     file-alist))
 
-(defun ls-lisp-classify (filedata)
-  "Append a character to each file name indicating the file type.
-Also, for regular files that are executable, append `*'.
+(defun ls-lisp-classify-file (filename fattr)
+  "Append a character to FILENAME indicating the file type.
+
+FATTR is the file attributes returned by `file-attributes' for the file.
 The file type indicators are `/' for directories, `@' for symbolic
-links, `|' for FIFOs, `=' for sockets, and nothing for regular files.
-\[But FIFOs and sockets are not recognized.]
-FILEDATA has the form (filename . `file-attributes').  Its `cadr' is t
-for directory, string (name linked to) for symbolic link, or nil."
+links, `|' for FIFOs, `=' for sockets, `*' for regular files that
+are executable, and nothing for other types of files."
+  (let* ((type (car fattr))
+	 (modestr (nth 8 fattr))
+	 (typestr (substring modestr 0 1)))
+    (cond
+     (type
+      (concat filename (if (eq type t) "/" "@")))
+     ((string-match "x" modestr)
+      (concat filename "*"))
+     ((string= "p" typestr)
+      (concat filename "|"))
+     ((string= "s" typestr)
+      (concat filename "="))
+     (t filename))))
+
+(defun ls-lisp-classify (filedata)
+  "Append a character to file name in FILEDATA indicating the file type.
+
+FILEDATA has the form (FILENAME . ATTRIBUTES), where ATTRIBUTES is the
+structure returned by `file-attributes' for that file.
+
+The file type indicators are `/' for directories, `@' for symbolic
+links, `|' for FIFOs, `=' for sockets, `*' for regular files that
+are executable, and nothing for other types of files."
   (let ((file-name (car filedata))
-        (type (cadr filedata)))
-    (cond (type
-	   (cons
-	    (concat (propertize file-name 'dired-filename t)
-		    (if (eq type t) "/" "@"))
-	    (cdr filedata)))
-	  ((string-match "x" (nth 9 filedata))
-	   (cons
-	    (concat (propertize file-name 'dired-filename t) "*")
-	    (cdr filedata)))
-	  (t
-	   (cons
-	    (propertize file-name 'dired-filename t)
-	    (cdr filedata))))))
+        (fattr (cdr filedata)))
+    (setq file-name (propertize file-name 'dired-filename t))
+    (cons (ls-lisp-classify-file file-name fattr) fattr)))
 
 (defun ls-lisp-extension (filename)
   "Return extension of FILENAME (ignoring any version extension)
--- a/lisp/net/tramp-compat.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/net/tramp-compat.el	Sat May 29 09:39:12 2010 +0000
@@ -343,7 +343,7 @@
     (wrong-number-of-arguments
      (let ((delete-by-moving-to-trash
 	    (and (boundp 'delete-by-moving-to-trash)
-		 delete-by-moving-to-trash
+		 (symbol-value 'delete-by-moving-to-trash)
 		 trash)))
        (delete-file filename)))))
 
--- a/lisp/net/tramp-fish.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/net/tramp-fish.el	Sat May 29 09:39:12 2010 +0000
@@ -326,14 +326,14 @@
 	 (lambda (file)
 	   (if (file-directory-p file)
 	       (tramp-compat-delete-directory file recursive)
-	     (tramp-compat-delete-file file)))
+	     (delete-file file)))
 	 ;; We do not want to delete "." and "..".
 	 (directory-files
 	  directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
     (with-parsed-tramp-file-name
-     (directory-file-name (expand-file-name directory)) nil
-     (tramp-flush-directory-property v localname)
-     (tramp-fish-send-command-and-check v (format "#RMD %s" localname)))))
+	(directory-file-name (expand-file-name directory)) nil
+      (tramp-flush-directory-property v localname)
+      (tramp-fish-send-command-and-check v (format "#RMD %s" localname)))))
 
 (defun tramp-fish-handle-delete-file (filename &optional trash)
   "Like `delete-file' for Tramp files."
@@ -660,7 +660,7 @@
 			  localname)))))
 	  (tramp-error
 	   v 'file-already-exists "File %s already exists" localname)
-	(tramp-compat-delete-file linkname)))
+	(delete-file linkname)))
 
     ;; If FILENAME is a Tramp name, use just the localname component.
     (when (tramp-tramp-file-p filename)
@@ -839,8 +839,8 @@
       ;; Provide error file.
       (when tmpstderr (rename-file tmpstderr (cadr destination) t))
       ;; Cleanup.
-      (when tmpinput (tramp-compat-delete-file tmpinput))
-      (when tmpoutput (tramp-compat-delete-file tmpoutput))
+      (when tmpinput (delete-file tmpinput))
+      (when tmpoutput (delete-file tmpoutput))
       ;; Return exit status.
       ret)))
 
--- a/lisp/net/tramp-ftp.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/net/tramp-ftp.el	Sat May 29 09:39:12 2010 +0000
@@ -182,7 +182,7 @@
 	  (unwind-protect
 	      (rename-file tmpfile newname (car args))
 	    ;; Cleanup.
-	    (ignore-errors (tramp-compat-delete-file tmpfile)))))
+	    (ignore-errors (delete-file tmpfile)))))
 
        ;; Normally, the handlers must be discarded.
        ;; `inhibit-file-name-handlers' isn't sufficient, because the
--- a/lisp/net/tramp-gvfs.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/net/tramp-gvfs.el	Sat May 29 09:39:12 2010 +0000
@@ -533,9 +533,9 @@
   (tramp-compat-delete-directory
    (tramp-gvfs-fuse-file-name directory) recursive))
 
-(defun tramp-gvfs-handle-delete-file (filename &optional tramp)
+(defun tramp-gvfs-handle-delete-file (filename &optional trash)
   "Like `delete-file' for Tramp files."
-  (tramp-compat-delete-file (tramp-gvfs-fuse-file-name filename) tramp))
+  (tramp-compat-delete-file (tramp-gvfs-fuse-file-name filename) trash))
 
 (defun tramp-gvfs-handle-directory-files
   (directory &optional full match nosort)
@@ -742,7 +742,7 @@
 		   "gvfs-save" tmpfile (tramp-get-buffer v) nil
 		   (tramp-gvfs-url-file-name filename)))
 	       (signal (car err) (cdr err)))
-	   (tramp-compat-delete-file tmpfile)))))
+	   (delete-file tmpfile)))))
 
     ;; Set file modification time.
     (when (or (eq visit t) (stringp visit))
--- a/lisp/net/tramp-imap.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/net/tramp-imap.el	Sat May 29 09:39:12 2010 +0000
@@ -267,8 +267,7 @@
 	    (insert-file-contents filename)
 	    (write-region (point-min) (point-max) newname)))))
 
-    (when (eq op 'rename)
-      (tramp-compat-delete-file filename))))
+    (when (eq op 'rename) (delete-file filename))))
 
 ;; TODO: revise this much
 (defun tramp-imap-handle-expand-file-name (name &optional dir)
--- a/lisp/net/tramp-smb.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/net/tramp-smb.el	Sat May 29 09:39:12 2010 +0000
@@ -345,7 +345,7 @@
 	  (condition-case err
 	      (rename-file tmpfile newname ok-if-already-exists)
 	    ((error quit)
-	     (tramp-compat-delete-file tmpfile)
+	     (delete-file tmpfile)
 	     (signal (car err) (cdr err))))
 
 	;; Remote newname.
@@ -382,7 +382,7 @@
 	 (lambda (file)
 	   (if (file-directory-p file)
 	       (tramp-compat-delete-directory file recursive)
-	     (tramp-compat-delete-file file t)))
+	     (tramp-compat-delete-file file 'trash)))
 	 ;; We do not want to delete "." and "..".
 	 (directory-files
 	  directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
@@ -611,7 +611,7 @@
 		 v (format "get \"%s\" \"%s\""
 			   (tramp-smb-get-localname v) tmpfile))
 	  ;; Oops, an error.  We shall cleanup.
-	  (tramp-compat-delete-file tmpfile)
+	  (delete-file tmpfile)
 	  (tramp-error
 	   v 'file-error "Cannot make local copy of file `%s'" filename)))
       tmpfile)))
@@ -861,7 +861,7 @@
 	  (condition-case err
 	      (rename-file tmpfile newname ok-if-already-exists)
 	    ((error quit)
-	     (tramp-compat-delete-file tmpfile)
+	     (delete-file tmpfile)
 	     (signal (car err) (cdr err))))
 
 	;; Remote newname.
@@ -882,7 +882,7 @@
 			     filename (tramp-smb-get-localname v)))
 	    (tramp-error v 'file-error "Cannot rename `%s'" filename)))))
 
-    (tramp-compat-delete-file filename)))
+    (delete-file filename)))
 
 (defun tramp-smb-handle-set-file-modes (filename mode)
   "Like `set-file-modes' for Tramp files."
@@ -946,7 +946,7 @@
 		     v (format "put %s \"%s\""
 			       tmpfile (tramp-smb-get-localname v)))
 	      (tramp-error v 'file-error "Cannot write `%s'" filename))
-	  (tramp-compat-delete-file tmpfile)))
+	  (delete-file tmpfile)))
 
       (unless (equal curbuf (current-buffer))
 	(tramp-error
--- a/lisp/net/tramp.el	Fri May 28 11:27:13 2010 +0000
+++ b/lisp/net/tramp.el	Sat May 29 09:39:12 2010 +0000
@@ -2121,7 +2121,7 @@
 	      (setq fn (symbol-name btf))
 	      (unless (and (string-match "^tramp" fn)
 			   (not (string-match
-				 "^tramp\\(-debug\\)?\\(-message\\|-error\\)$"
+				 "^tramp\\(-debug\\)?\\(-message\\|-error\\|-compat-funcall\\)$"
 				 fn)))
 		(setq fn nil)))
 	    (setq btn (1+ btn))))
@@ -2290,7 +2290,10 @@
       (funcall 'progress-reporter-update reporter value))))
 
 (defmacro with-progress-reporter (vec level message &rest body)
-  "Executes BODY, spinning a progress reporter with MESSAGE."
+  "Executes BODY, spinning a progress reporter with MESSAGE.
+If LEVEL does not fit for visible messages, or if this is a
+nested call of the macro, there are only traces without a visible
+progress reporter."
   `(let (pr tm)
      (tramp-message ,vec ,level "%s..." ,message)
      ;; We start a pulsing progress reporter after 3 seconds.  Feature
@@ -2304,7 +2307,9 @@
 		      (run-at-time 3 0.1 'tramp-progress-reporter-update pr)))
 	 (error nil)))
      (unwind-protect
-	 ;; Execute the body.
+	 ;; Execute the body.  Unset `tramp-message-show-message' when
+	 ;; the timer object is created, in order to suppress
+	 ;; concurrent timers.
 	 (let ((tramp-message-show-message
 		(and tramp-message-show-message (not tm))))
 	   ,@body)
@@ -2544,7 +2549,7 @@
 			    l-localname)))))
 	    (tramp-error
 	     l 'file-already-exists "File %s already exists" l-localname)
-	  (tramp-compat-delete-file linkname)))
+	  (delete-file linkname)))
 
       ;; If FILENAME is a Tramp name, use just the localname component.
       (when (tramp-tramp-file-p filename)
@@ -2593,7 +2598,7 @@
 	    ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
 	    (unwind-protect
 		(load local-copy noerror t t)
-	      (tramp-compat-delete-file local-copy)))))
+	      (delete-file local-copy)))))
       t)))
 
 ;; Localname manipulation functions that grok Tramp localnames...
@@ -3769,7 +3774,7 @@
   ;; Set the mode.
   (set-file-modes newname (tramp-default-file-modes filename))
   ;; If the operation was `rename', delete the original file.
-  (unless (eq op 'copy) (tramp-compat-delete-file filename)))
+  (unless (eq op 'copy) (delete-file filename)))
 
 (defun tramp-do-copy-or-rename-file-directly
  (op filename newname ok-if-already-exists keep-date preserve-uid-gid)
@@ -3924,7 +3929,7 @@
 
 		;; Save exit.
 		(condition-case nil
-		    (tramp-compat-delete-file tmpfile)
+		    (delete-file tmpfile)
 		  (error)))))))))
 
       ;; Set the time and mode. Mask possible errors.
@@ -3964,7 +3969,7 @@
 		  (if dir-flag
 		      (tramp-compat-delete-directory
 		       (expand-file-name ".." tmpfile) 'recursive)
-		    (tramp-compat-delete-file tmpfile))
+		    (delete-file tmpfile))
 		(error))))
 
 	;; Expand hops.  Might be necessary for gateway methods.
@@ -4082,7 +4087,7 @@
       ;; If the operation was `rename', delete the original file.
       (unless (eq op 'copy)
 	(if (file-regular-p filename)
-	    (tramp-compat-delete-file filename)
+	    (delete-file filename)
 	  (tramp-compat-delete-directory filename 'recursive))))))
 
 (defun tramp-handle-make-directory (dir &optional parents)
@@ -4118,10 +4123,12 @@
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-property v (file-name-directory localname))
     (tramp-flush-file-property v localname)
-    (unless (zerop (tramp-send-command-and-check
-		    v
-		    (format "rm -f %s"
-			    (tramp-shell-quote-argument localname))))
+    (unless
+	(zerop
+	 (tramp-send-command-and-check
+	  v (format "%s %s"
+		    (or (and trash (tramp-get-remote-trash v)) "rm -f")
+		    (tramp-shell-quote-argument localname))))
       (tramp-error v 'file-error "Couldn't delete %s" filename))))
 
 ;; Dired.
@@ -4629,7 +4636,7 @@
 
       ;; Cleanup.  We remove all file cache values for the connection,
       ;; because the remote process could have changed them.
-      (when tmpinput (tramp-compat-delete-file tmpinput))
+      (when tmpinput (delete-file tmpinput))
 
       ;; `process-file-side-effects' has been introduced with GNU
       ;; Emacs 23.2.  If set to `nil', no remote file will be changed
@@ -4666,7 +4673,7 @@
     (when delete (delete-region start end))
     (unwind-protect
 	(apply 'call-process program tmpfile buffer display args)
-      (tramp-compat-delete-file tmpfile))))
+      (delete-file tmpfile))))
 
 (defun tramp-handle-shell-command
   (command &optional output-buffer error-buffer)
@@ -4731,7 +4738,7 @@
 	(when (listp buffer)
 	  (with-current-buffer error-buffer
 	    (insert-file-contents (cadr buffer)))
-	  (tramp-compat-delete-file (cadr buffer)))
+	  (delete-file (cadr buffer)))
 	(if current-buffer-p
 	    ;; This is like exchange-point-and-mark, but doesn't
 	    ;; activate the mark.  It is cleaner to avoid activation,
@@ -4813,7 +4820,7 @@
 		    (unwind-protect
 			(tramp-call-local-coding-command
 			 loc-dec tmpfile2 tmpfile)
-		      (tramp-compat-delete-file tmpfile2)))))
+		      (delete-file tmpfile2)))))
 
 	      ;; Set proper permissions.
 	      (set-file-modes tmpfile (tramp-default-file-modes filename))
@@ -4826,7 +4833,7 @@
 
 	;; Error handling.
 	((error quit)
-	 (tramp-compat-delete-file tmpfile)
+	 (delete-file tmpfile)
 	 (signal (car err) (cdr err))))
 
       (run-hooks 'tramp-handle-file-local-copy-hook)
@@ -4961,9 +4968,9 @@
 	    (set-buffer-modified-p nil))
 	  (when (and (stringp local-copy)
 		     (or remote-copy (null tramp-temp-buffer-file-name)))
-	    (tramp-compat-delete-file local-copy))
+	    (delete-file local-copy))
 	  (when (stringp remote-copy)
-	    (tramp-compat-delete-file
+	    (delete-file
 	     (tramp-make-tramp-file-name method user host remote-copy))))))
 
     ;; Result.
@@ -5154,7 +5161,7 @@
 		 (list start end tmpfile append 'no-message lockname confirm))
 	      ((error quit)
 	       (setq tramp-temp-buffer-file-name nil)
-	       (tramp-compat-delete-file tmpfile)
+	       (delete-file tmpfile)
 	       (signal (car err) (cdr err))))
 
 	    ;; Now, `last-coding-system-used' has the right value.  Remember it.
@@ -5198,13 +5205,13 @@
 			(copy-file tmpfile filename t)
 		      ((error quit)
 		       (setq tramp-temp-buffer-file-name nil)
-		       (tramp-compat-delete-file tmpfile)
+		       (delete-file tmpfile)
 		       (signal (car err) (cdr err)))))
 		(setq tramp-temp-buffer-file-name nil)
 		;; Don't rename, in order to keep context in SELinux.
 		(unwind-protect
 		    (copy-file tmpfile filename t)
-		  (tramp-compat-delete-file tmpfile))))
+		  (delete-file tmpfile))))
 
 	     ;; Use inline file transfer.
 	     (rem-dec
@@ -5289,7 +5296,7 @@
 			  filename rem-dec)))))
 
 		;; Save exit.
-		(tramp-compat-delete-file tmpfile)))
+		(delete-file tmpfile)))
 
 	     ;; That's not expected.
 	     (t
@@ -6372,7 +6379,7 @@
   "Remove temporary files related to current buffer."
   (when (stringp tramp-temp-buffer-file-name)
     (condition-case nil
-	(tramp-compat-delete-file tramp-temp-buffer-file-name)
+	(delete-file tramp-temp-buffer-file-name)
       (error nil))))
 
 (add-hook 'kill-buffer-hook 'tramp-delete-temp-file-function)
@@ -8416,6 +8423,11 @@
 		     (error nil))))
 	result))))
 
+(defun tramp-get-remote-trash (vec)
+  (with-connection-property vec "trash"
+    (tramp-message vec 5 "Finding a suitable `trash' command")
+    (tramp-find-executable vec "trash" (tramp-get-remote-path vec))))
+
 (defun tramp-get-remote-id (vec)
   (with-connection-property vec "id"
     (tramp-message vec 5 "Finding POSIX `id' command")
--- a/src/ChangeLog	Fri May 28 11:27:13 2010 +0000
+++ b/src/ChangeLog	Sat May 29 09:39:12 2010 +0000
@@ -1,3 +1,7 @@
+2010-05-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* fileio.c (Fdelete_file): Pass TRASH arg to handler call.
+
 2010-05-28  Kenichi Handa  <handa@m17n.org>
 
 	* font.c (font_delete_unmatched): Check Vface_ignored_fonts.
--- a/src/fileio.c	Fri May 28 11:27:13 2010 +0000
+++ b/src/fileio.c	Sat May 29 09:39:12 2010 +0000
@@ -1925,7 +1925,7 @@
 If PRESERVE-UID-GID is non-nil, we try to transfer the
 uid and gid of FILE to NEWNAME.
 
-If PRESERVE-SELINUX-CONTEXT is non-nil and SELinux is enabled 
+If PRESERVE-SELINUX-CONTEXT is non-nil and SELinux is enabled
 on the system, we copy the SELinux context of FILE to NEWNAME.  */)
      (file, newname, ok_if_already_exists, keep_time, preserve_uid_gid, preserve_selinux_context)
      Lisp_Object file, newname, ok_if_already_exists, keep_time;
@@ -2221,7 +2221,7 @@
 
   handler = Ffind_file_name_handler (filename, Qdelete_file);
   if (!NILP (handler))
-    return call2 (handler, Qdelete_file, filename);
+    return call3 (handler, Qdelete_file, filename, trash);
 
   if (delete_by_moving_to_trash && !NILP (trash))
     return call1 (Qmove_file_to_trash, filename);