Commit f1a5d776 authored by Chong Yidong's avatar Chong Yidong

Change delete-by-moving-to-trash so Lisp calls explicitly request trashing.

* src/fileio.c (Fdelete_file): Change meaning of optional arg to mean
whether to trash.
(internal_delete_file, Frename_file): Callers changed.
(delete_by_moving_to_trash): Doc fix.
(Fdelete_directory_internal): Don't move to trash.

* src/callproc.c (delete_temp_file):
* src/buffer.c (Fkill_buffer): Callers changed.

* src/lisp.h: Update prototype.

* lisp/diff.el (diff-sentinel):
* lisp/epg.el (epg--make-temp-file, epg-decrypt-string)
(epg-verify-string, epg-sign-string, epg-encrypt-string):
* lisp/jka-compr.el (jka-compr-partial-uncompress)
(jka-compr-call-process, jka-compr-write-region):
* lisp/server.el (server-sentinel): Remove optional arg from
delete-file, reverting 2010-05-03 change.

* lisp/dired.el (dired-delete-file): New arg TRASH.
(dired-internal-do-deletions): New arg TRASH.  Use progress
reporter.
(dired-do-flagged-delete, dired-do-delete): Use trash.

* lisp/files.el (delete-directory): New arg TRASH.

* lisp/speedbar.el (speedbar-item-delete): Allow trashing.

* lisp/net/ange-ftp.el (ange-ftp-del-tmp-name, ange-ftp-delete-file)
(ange-ftp-rename-remote-to-remote)
(ange-ftp-rename-local-to-remote)
(ange-ftp-rename-remote-to-local, ange-ftp-load)
(ange-ftp-compress, ange-ftp-uncompress): Remove optional arg from
`delete-file'.
(ange-ftp-delete-directory): Add optional arg to `delete-file', to
allow trashing.

* lisp/net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.

* lisp/net/tramp-fish.el (tramp-fish-handle-delete-directory)
(tramp-fish-handle-delete-file)
(tramp-fish-handle-make-symbolic-link)
(tramp-fish-handle-process-file): Use null TRASH arg in
`tramp-compat-delete-file' call.

* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler): Use null TRASH
arg in `tramp-compat-delete-file' call.

* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Rename arg.
(tramp-gvfs-handle-write-region): Use null TRASH arg in
`tramp-compat-delete-file' call.

* lisp/net/tramp-imap.el (tramp-imap-handle-delete-file): Rename arg.
(tramp-imap-do-copy-or-rename-file): Use null TRASH arg in
`tramp-compat-delete-file' call.

* lisp/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 null TRASH arg in
tramp-compat-delete-file call.
(tramp-smb-handle-delete-directory): Use tramp-compat-delete-file.
(tramp-smb-handle-delete-file): Rename arg.

* lisp/net/tramp.el (tramp-handle-delete-file): Change FORCE arg to TRASH.
(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 null TRASH arg in
tramp-compat-delete-file call.
parent f44a59e6
......@@ -109,16 +109,20 @@ scroll a line instead of full screen.
** New property `scroll-command' should be set on a command's symbol to
define it as a scroll command affected by `scroll-preserve-screen-position.
** Trash changes
*** `delete-by-moving-to-trash' now only affects commands that specify
trashing. This avoids inadvertently trashing temporary files.
*** Calling `delete-file' or `delete-directory' with a prefix argument
now forces true deletion, regardless of `delete-by-moving-to-trash'.
* Editing Changes in Emacs 24.1
** completion-at-point is now an alias for complete-symbol.
** mouse-region-delete-keys has been deleted.
** If delete-file is called with a prefix argument, it really deletes,
regardless of the value of `delete-by-moving-to-trash'.
* Changes in Specialized Modes and Packages in Emacs 24.1
......@@ -237,8 +241,10 @@ secrets.
** prog-mode is a new major-mode meant to be the parent of programming mode.
** define-minor-mode accepts a new keyword :variable.
** delete-file now accepts an optional second arg, FORCE, which says
to always delete and ignore the value of delete-by-moving-to-trash.
** `delete-file' and `delete-directory now accept optional arg TRASH.
Trashing is performed if TRASH and `delete-by-moving-to-trash' are
both non-nil. Interactively, TRASH defaults to t, unless a prefix
argument is supplied (see Trash changes, above).
** buffer-substring-filters is obsoleted by filter-buffer-substring-functions.
......
2010-05-27 Chong Yidong <cyd@stupidchicken.com>
* dired.el (dired-delete-file): New arg TRASH.
(dired-internal-do-deletions): New arg TRASH. Use progress
reporter.
(dired-do-flagged-delete, dired-do-delete): Use trash.
* speedbar.el (speedbar-item-delete): Allow trashing.
* files.el (delete-directory): New arg TRASH.
* net/ange-ftp.el (ange-ftp-del-tmp-name, ange-ftp-delete-file)
(ange-ftp-rename-remote-to-remote)
(ange-ftp-rename-local-to-remote)
(ange-ftp-rename-remote-to-local, ange-ftp-load)
(ange-ftp-compress, ange-ftp-uncompress): Remove optional arg from
`delete-file'.
(ange-ftp-delete-directory): Add optional arg to `delete-file', to
allow trashing.
* net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.
* net/tramp.el (tramp-handle-delete-file): Change FORCE arg to
TRASH.
(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 null TRASH arg in
tramp-compat-delete-file call.
* net/tramp-fish.el (tramp-fish-handle-delete-directory)
(tramp-fish-handle-delete-file)
(tramp-fish-handle-make-symbolic-link)
(tramp-fish-handle-process-file): Use null TRASH arg in
`tramp-compat-delete-file' call.
* net/tramp-ftp.el (tramp-ftp-file-name-handler): Use null TRASH
arg in `tramp-compat-delete-file' call.
* net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Rename arg.
(tramp-gvfs-handle-write-region): Use null TRASH arg in
`tramp-compat-delete-file' call.
* net/tramp-imap.el (tramp-imap-handle-delete-file): Rename arg.
(tramp-imap-do-copy-or-rename-file): Use null TRASH arg in
`tramp-compat-delete-file' call.
* 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 null TRASH arg in
tramp-compat-delete-file call.
(tramp-smb-handle-delete-directory): Use tramp-compat-delete-file.
(tramp-smb-handle-delete-file): Rename arg.
* diff.el (diff-sentinel):
* epg.el (epg--make-temp-file, epg-decrypt-string)
(epg-verify-string, epg-sign-string, epg-encrypt-string):
* jka-compr.el (jka-compr-partial-uncompress)
(jka-compr-call-process, jka-compr-write-region):
* server.el (server-sentinel): Remove optional arg from
delete-file, reverting 2010-05-03 change.
2010-05-27 Chong Yidong <cyd@stupidchicken.com>
* progmodes/verilog-mode.el (verilog-type-font-keywords): Use
......
......@@ -64,8 +64,8 @@
"Code run when the diff process exits.
CODE is the exit code of the process. It should be 0 only if no diffs
were found."
(if diff-old-temp-file (delete-file diff-old-temp-file t))
(if diff-new-temp-file (delete-file diff-new-temp-file t))
(if diff-old-temp-file (delete-file diff-old-temp-file))
(if diff-new-temp-file (delete-file diff-new-temp-file))
(save-excursion
(goto-char (point-max))
(let ((inhibit-read-only t))
......
......@@ -2579,7 +2579,7 @@ Anything else means ask for each directory."
;; Delete file, possibly delete a directory and all its files.
;; This function is usefull outside of dired. One could change it's name
;; to e.g. recursive-delete-file and put it somewhere else.
(defun dired-delete-file (file &optional recursive) "\
(defun dired-delete-file (file &optional recursive trash) "\
Delete FILE or directory (possibly recursively if optional RECURSIVE is true.)
RECURSIVE determines what to do with a non-empty directory. If RECURSIVE is:
nil, do not delete.
......@@ -2590,15 +2590,19 @@ Anything else, ask for each sub-directory."
;; (and (file-directory-p fn) (not (file-symlink-p fn)))
;; but more efficient
(if (not (eq t (car (file-attributes file))))
(delete-file file)
(delete-file file trash)
(if (and recursive
(directory-files file t dired-re-no-dot) ; Not empty.
(or (eq recursive 'always)
(yes-or-no-p (format "Recursive delete of %s? "
(yes-or-no-p (format "Recursively %s %s? "
(if (and trash
delete-by-moving-to-trash)
"trash"
"delete")
(dired-make-relative file)))))
(if (eq recursive 'top) (setq recursive 'always)) ; Don't ask again.
(setq recursive nil))
(delete-directory file recursive)))
(delete-directory file recursive trash)))
(defun dired-do-flagged-delete (&optional nomessage)
"In Dired, delete the files flagged for deletion.
......@@ -2616,7 +2620,7 @@ non-empty directories is allowed."
;; this can't move point since ARG is nil
(dired-map-over-marks (cons (dired-get-filename) (point))
nil)
nil)
nil t)
(or nomessage
(message "(No deletions requested)")))))
......@@ -2631,11 +2635,11 @@ non-empty directories is allowed."
;; this may move point if ARG is an integer
(dired-map-over-marks (cons (dired-get-filename) (point))
arg)
arg))
arg t))
(defvar dired-deletion-confirmer 'yes-or-no-p) ; or y-or-n-p?
(defun dired-internal-do-deletions (l arg)
(defun dired-internal-do-deletions (l arg &optional trash)
;; L is an alist of files to delete, with their buffer positions.
;; ARG is the prefix arg.
;; Filenames are absolute.
......@@ -2644,14 +2648,21 @@ non-empty directories is allowed."
;; lines still to be changed, so the (point) values in L stay valid.
;; Also, for subdirs in natural order, a subdir's files are deleted
;; before the subdir itself - the other way around would not work.
(let ((files (mapcar (function car) l))
(count (length l))
(succ 0))
(let* ((files (mapcar (function car) l))
(count (length l))
(succ 0)
(trashing (and trash delete-by-moving-to-trash))
(progress-reporter
(make-progress-reporter
(if trashing "Trashing..." "Deleting...")
succ count)))
;; canonicalize file list for pop up
(setq files (nreverse (mapcar (function dired-make-relative) files)))
(if (dired-mark-pop-up
" *Deletions*" 'delete files dired-deletion-confirmer
(format "Delete %s " (dired-mark-prompt arg files)))
(format "%s %s "
(if trashing "Trash" "Delete")
(dired-mark-prompt arg files)))
(save-excursion
(let (failures);; files better be in reverse order for this loop!
(while l
......@@ -2659,10 +2670,10 @@ non-empty directories is allowed."
(let ((inhibit-read-only t))
(condition-case err
(let ((fn (car (car l))))
(dired-delete-file fn dired-recursive-deletes)
(dired-delete-file fn dired-recursive-deletes trash)
;; if we get here, removing worked
(setq succ (1+ succ))
(message "%s of %s deletions" succ count)
(progress-reporter-update progress-reporter succ)
(dired-fun-in-all-buffers
(file-name-directory fn) (file-name-nondirectory fn)
(function dired-delete-entry) fn))
......@@ -2671,7 +2682,7 @@ non-empty directories is allowed."
(setq failures (cons (car (car l)) failures)))))
(setq l (cdr l)))
(if (not failures)
(message "%d deletion%s done" count (dired-plural-s count))
(progress-reporter-done progress-reporter)
(dired-log-summary
(format "%d of %d deletion%s failed"
(length failures) count
......
......@@ -1899,7 +1899,7 @@ You can then use `write-region' to write new data into the file."
;; Cleanup the tempfile.
(and tempfile
(file-exists-p tempfile)
(delete-file tempfile t))
(delete-file tempfile))
;; Cleanup the tempdir.
(and tempdir
(file-directory-p tempdir)
......@@ -1999,7 +1999,7 @@ If PLAIN is nil, it returns the result as a string."
(epg-read-output context))
(epg-delete-output-file context)
(if (file-exists-p input-file)
(delete-file input-file t))
(delete-file input-file))
(epg-reset context))))
(defun epg-start-verify (context signature &optional signed-text)
......@@ -2203,7 +2203,7 @@ Otherwise, it makes a cleartext signature."
(epg-read-output context))
(epg-delete-output-file context)
(if input-file
(delete-file input-file t))
(delete-file input-file))
(epg-reset context))))
(defun epg-start-encrypt (context plain recipients
......@@ -2323,7 +2323,7 @@ If RECIPIENTS is nil, it performs symmetric encryption."
(epg-read-output context))
(epg-delete-output-file context)
(if input-file
(delete-file input-file t))
(delete-file input-file))
(epg-reset context))))
(defun epg-start-export-keys (context keys)
......
......@@ -4675,19 +4675,30 @@ this happens by default."
"^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"
"Regexp of file names excluging \".\" an \"..\".")
(defun delete-directory (directory &optional recursive)
(defun delete-directory (directory &optional recursive trash)
"Delete the directory named DIRECTORY. Does not follow symlinks.
If RECURSIVE is non-nil, all files in DIRECTORY are deleted as well."
If RECURSIVE is non-nil, all files in DIRECTORY are deleted as well.
TRASH non-nil means to trash the directory instead, provided
`delete-by-moving-to-trash' is non-nil.
When called interactively, TRASH is t if no prefix argument is
given. With a prefix argument, TRASH is nil."
(interactive
(let ((dir (expand-file-name
(read-file-name
"Delete directory: "
default-directory default-directory nil nil))))
(let* ((trashing (and delete-by-moving-to-trash
(null current-prefix-arg)))
(dir (expand-file-name
(read-file-name
(if trashing
"Move directory to trash: "
"Delete directory: ")
default-directory default-directory nil nil))))
(list dir
(if (directory-files dir nil directory-files-no-dot-files-regexp)
(y-or-n-p
(format "Directory `%s' is not empty, really delete? " dir))
nil))))
(format "Directory `%s' is not empty, really %s? "
dir (if trashing "trash" "delete")))
nil)
(null current-prefix-arg))))
;; If default-directory is a remote directory, make sure we find its
;; delete-directory handler.
(setq directory (directory-file-name (expand-file-name directory)))
......@@ -4695,7 +4706,7 @@ If RECURSIVE is non-nil, all files in DIRECTORY are deleted as well."
(cond
(handler
(funcall handler 'delete-directory directory recursive))
(delete-by-moving-to-trash
((and delete-by-moving-to-trash trash)
;; Only move non-empty dir to trash if recursive deletion was
;; requested. This mimics the non-`delete-by-moving-to-trash'
;; case, where the operation fails in delete-directory-internal.
......@@ -4715,8 +4726,8 @@ If RECURSIVE is non-nil, all files in DIRECTORY are deleted as well."
;; (and (file-directory-p fn) (not (file-symlink-p fn)))
;; but more efficient
(if (eq t (car (file-attributes file)))
(delete-directory file recursive)
(delete-file file)))
(delete-directory file recursive nil)
(delete-file file nil)))
;; We do not want to delete "." and "..".
(directory-files
directory 'full directory-files-no-dot-files-regexp)))
......
......@@ -181,7 +181,7 @@ to keep: LEN chars starting BEG chars from the beginning."
null-device))
jka-compr-acceptable-retval-list)
(jka-compr-error prog args infile message err-file))
(delete-file err-file t)))
(delete-file err-file)))
;; Run the uncompression program directly.
;; We get the whole file and must delete what we don't want.
......@@ -223,7 +223,7 @@ to keep: LEN chars starting BEG chars from the beginning."
"")))
jka-compr-acceptable-retval-list)
(jka-compr-error prog args infile message err-file))
(delete-file err-file t)))
(delete-file err-file)))
(or (eq 0
(apply 'call-process
prog infile (if (stringp output) temp output)
......@@ -335,7 +335,7 @@ There should be no more than seven characters after the final `/'."
(and append can-append) 'dont))
(erase-buffer)) )
(delete-file temp-file t)
(delete-file temp-file)
(and
compress-message
......
......@@ -1736,7 +1736,7 @@ good, skip, fatal, or unknown."
(defun ange-ftp-del-tmp-name (filename)
"Force to delete temporary file."
(delete-file filename 'force))
(delete-file filename))
;;;; ------------------------------------------------------------
......@@ -3507,8 +3507,9 @@ system TYPE.")
(file-exists-p file)
(ange-ftp-real-file-executable-p file))))
(defun ange-ftp-delete-file (file &optional force)
(interactive "fDelete file: ")
(defun ange-ftp-delete-file (file &optional trash)
(interactive (list (read-file-name "Delete file: " nil default-directory)
(null current-prefix-arg)))
(setq file (expand-file-name file))
(let ((parsed (ange-ftp-ftp-name file)))
(if parsed
......@@ -3526,7 +3527,7 @@ system TYPE.")
(format "FTP Error: \"%s\"" (cdr result))
file)))
(ange-ftp-delete-file-entry file))
(ange-ftp-real-delete-file file force))))
(ange-ftp-real-delete-file file trash))))
(defun ange-ftp-file-modtime (file)
"Return the modification time of remote file FILE.
......@@ -3897,7 +3898,7 @@ E.g.,
(ange-ftp-add-file-entry newname)
(ange-ftp-delete-file-entry filename))
(ange-ftp-copy-file-internal filename newname t nil)
(delete-file filename 'force))))
(delete-file filename))))
(defun ange-ftp-rename-local-to-remote (filename newname)
"Rename local file FILENAME to remote file NEWNAME."
......@@ -3906,7 +3907,7 @@ E.g.,
(msg (format "Renaming %s to %s" fabbr nabbr)))
(ange-ftp-copy-file-internal filename newname t nil msg)
(let (ange-ftp-process-verbose)
(delete-file filename 'force))))
(delete-file filename))))
(defun ange-ftp-rename-remote-to-local (filename newname)
"Rename remote file FILENAME to local file NEWNAME."
......@@ -3915,7 +3916,7 @@ E.g.,
(msg (format "Renaming %s to %s" fabbr nabbr)))
(ange-ftp-copy-file-internal filename newname t nil msg)
(let (ange-ftp-process-verbose)
(delete-file filename 'force))))
(delete-file filename))))
(defun ange-ftp-rename-file (filename newname &optional ok-if-already-exists)
(interactive "fRename file: \nFRename %s to file: \np")
......@@ -4196,7 +4197,7 @@ directory, so that Emacs will know its current contents."
(if copy
(unwind-protect
(funcall 'load copy noerror nomessage nosuffix)
(delete-file copy 'force))
(delete-file copy))
(or noerror
(signal 'file-error (list "Cannot open load file" file)))
nil))
......@@ -4267,7 +4268,7 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
(if (zerop (buffer-size))
(progn
(let (ange-ftp-process-verbose)
(delete-file file 'force))
(delete-file file))
(ange-ftp-copy-file-internal tmp2 nfile t nil msg2))))
(ange-ftp-del-tmp-name tmp1)
(ange-ftp-del-tmp-name tmp2))))
......@@ -4303,7 +4304,7 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
(if (zerop (buffer-size))
(progn
(let (ange-ftp-process-verbose)
(delete-file file 'force))
(delete-file file))
(ange-ftp-copy-file-internal tmp2 nfile t nil msg2))))
(ange-ftp-del-tmp-name tmp1)
(ange-ftp-del-tmp-name tmp2))))
......
......@@ -334,23 +334,18 @@ Add the extension of FILENAME, if existing."
(if keep-time
(set-file-times newname (nth 5 (file-attributes directory))))))))
;; FORCE has been introduced with Emacs 24.1.
(defun tramp-compat-delete-file (filename &optional force)
;; TRASH has been introduced with Emacs 24.1.
(defun tramp-compat-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files (compat function)."
(if (null force)
(delete-file filename)
(condition-case nil
(tramp-compat-funcall 'delete-file filename force)
;; This Emacs version does not support the FORCE flag. Setting
;; `delete-by-moving-to-trash' shall give us the same effect.
(wrong-number-of-arguments
(let ((delete-by-moving-to-trash
(cond
((null force) t)
((boundp 'delete-by-moving-to-trash)
(symbol-value 'delete-by-moving-to-trash))
(t nil))))
(delete-file filename))))))
(condition-case nil
(tramp-compat-funcall 'delete-file filename trash)
;; This Emacs version does not support the TRASH flag.
(wrong-number-of-arguments
(let ((delete-by-moving-to-trash
(and (boundp 'delete-by-moving-to-trash)
delete-by-moving-to-trash
trash)))
(delete-file filename)))))
;; RECURSIVE has been introduced with Emacs 23.2.
(defun tramp-compat-delete-directory (directory &optional recursive)
......
......@@ -326,16 +326,16 @@ pass to the OPERATION."
(lambda (file)
(if (file-directory-p file)
(tramp-compat-delete-directory file recursive)
(delete-file file)))
(tramp-compat-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)))))
(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)))))
(defun tramp-fish-handle-delete-file (filename &optional force)
(defun tramp-fish-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(when (file-exists-p filename)
(with-parsed-tramp-file-name (expand-file-name filename) nil
......@@ -660,7 +660,7 @@ target of the symlink differ."
localname)))))
(tramp-error
v 'file-already-exists "File %s already exists" localname)
(tramp-compat-delete-file linkname 'force)))
(tramp-compat-delete-file linkname)))
;; If FILENAME is a Tramp name, use just the localname component.
(when (tramp-tramp-file-p filename)
......@@ -839,8 +839,8 @@ target of the symlink differ."
;; Provide error file.
(when tmpstderr (rename-file tmpstderr (cadr destination) t))
;; Cleanup.
(when tmpinput (tramp-compat-delete-file tmpinput 'force))
(when tmpoutput (tramp-compat-delete-file tmpoutput 'force))
(when tmpinput (tramp-compat-delete-file tmpinput))
(when tmpoutput (tramp-compat-delete-file tmpoutput))
;; Return exit status.
ret)))
......
......@@ -182,7 +182,7 @@ pass to the OPERATION."
(unwind-protect
(rename-file tmpfile newname (car args))
;; Cleanup.
(ignore-errors (tramp-compat-delete-file tmpfile 'force)))))
(ignore-errors (tramp-compat-delete-file tmpfile)))))
;; Normally, the handlers must be discarded.
;; `inhibit-file-name-handlers' isn't sufficient, because the
......
......@@ -533,9 +533,9 @@ is no information where to trace the message.")
(tramp-compat-delete-directory
(tramp-gvfs-fuse-file-name directory) recursive))
(defun tramp-gvfs-handle-delete-file (filename &optional force)
(defun tramp-gvfs-handle-delete-file (filename &optional tramp)
"Like `delete-file' for Tramp files."
(tramp-compat-delete-file (tramp-gvfs-fuse-file-name filename) force))
(tramp-compat-delete-file (tramp-gvfs-fuse-file-name filename) tramp))
(defun tramp-gvfs-handle-directory-files
(directory &optional full match nosort)
......@@ -742,7 +742,7 @@ is no information where to trace the message.")
"gvfs-save" tmpfile (tramp-get-buffer v) nil
(tramp-gvfs-url-file-name filename)))
(signal (car err) (cdr err)))
(tramp-compat-delete-file tmpfile 'force)))))
(tramp-compat-delete-file tmpfile)))))
;; Set file modification time.
(when (or (eq visit t) (stringp visit))
......
......@@ -268,7 +268,7 @@ of `copy' and `rename'."
(write-region (point-min) (point-max) newname)))))
(when (eq op 'rename)
(tramp-compat-delete-file filename 'force))))
(tramp-compat-delete-file filename))))
;; TODO: revise this much
(defun tramp-imap-handle-expand-file-name (name &optional dir)
......@@ -552,7 +552,7 @@ SIZE MODE WEIRD INODE DEVICE)."
;; (file-exists-p (file-name-directory filename)))
(file-directory-p (file-name-directory filename)))
(defun tramp-imap-handle-delete-file (filename &optional force)
(defun tramp-imap-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(cond
((not (file-exists-p filename)) nil)
......
......@@ -345,7 +345,7 @@ PRESERVE-UID-GID is completely ignored."
(condition-case err
(rename-file tmpfile newname ok-if-already-exists)
((error quit)
(tramp-compat-delete-file tmpfile 'force)
(tramp-compat-delete-file tmpfile)
(signal (car err) (cdr err))))
;; Remote newname.
......@@ -382,7 +382,7 @@ PRESERVE-UID-GID is completely ignored."
(lambda (file)
(if (file-directory-p file)
(tramp-compat-delete-directory file recursive)
(delete-file file)))
(tramp-compat-delete-file file t)))
;; We do not want to delete "." and "..".
(directory-files
directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
......@@ -404,7 +404,7 @@ PRESERVE-UID-GID is completely ignored."
(tramp-error
v 'file-error "%s `%s'" (match-string 0) directory))))))
(defun tramp-smb-handle-delete-file (filename &optional force)
(defun tramp-smb-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(setq filename (expand-file-name filename))
(when (file-exists-p filename)
......@@ -611,7 +611,7 @@ PRESERVE-UID-GID is completely ignored."
v (format "get \"%s\" \"%s\""
(tramp-smb-get-localname v) tmpfile))
;; Oops, an error. We shall cleanup.
(tramp-compat-delete-file tmpfile 'force)
(tramp-compat-delete-file tmpfile)
(tramp-error
v 'file-error "Cannot make local copy of file `%s'" filename)))
tmpfile)))
......@@ -861,7 +861,7 @@ target of the symlink differ."
(condition-case err
(rename-file tmpfile newname ok-if-already-exists)
((error quit)
(tramp-compat-delete-file tmpfile 'force)
(tramp-compat-delete-file tmpfile)
(signal (car err) (cdr err))))
;; Remote newname.
......@@ -882,7 +882,7 @@ target of the symlink differ."
filename (tramp-smb-get-localname v)))
(tramp-error v 'file-error "Cannot rename `%s'" filename)))))
(tramp-compat-delete-file filename 'force)))
(tramp-compat-delete-file filename)))
(defun tramp-smb-handle-set-file-modes (filename mode)
"Like `set-file-modes' for Tramp files."
......@@ -946,7 +946,7 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
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 'force)))
(tramp-compat-delete-file tmpfile)))
(unless (equal curbuf (current-buffer))
(tramp-error
......
......@@ -2544,7 +2544,7 @@ target of the symlink differ."
l-localname)))))
(tramp-error
l 'file-already-exists "File %s already exists" l-localname)
(tramp-compat-delete-file linkname 'force)))
(tramp-compat-delete-file linkname)))
;; If FILENAME is a Tramp name, use just the localname component.
(when (tramp-tramp-file-p filename)
......@@ -2593,7 +2593,7 @@ target of the symlink differ."
;; 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 'force)))))
(tramp-compat-delete-file local-copy)))))
t)))
;; Localname manipulation functions that grok Tramp localnames...
......@@ -3769,7 +3769,7 @@ KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME."
;; 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 'force)))
(unless (eq op 'copy) (tramp-compat-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 +3924,7 @@ the uid and gid from FILENAME."
;; Save exit.
(condition-case nil
(tramp-compat-delete-file tmpfile 'force)
(tramp-compat-delete-file tmpfile)
(error)))))))))
;; Set the time and mode. Mask possible errors.
......@@ -3964,7 +3964,7 @@ The method used must be an out-of-band method."
(if dir-flag
(tramp-compat-delete-directory
(expand-file-name ".." tmpfile) 'recursive)
(tramp-compat-delete-file tmpfile 'force))
(tramp-compat-delete-file tmpfile))
(error))))
;; Expand hops. Might be necessary for gateway methods.
......@@ -4082,7 +4082,7 @@ The method used must be an out-of-band method."
;; If the operation was `rename', delete the original file.
(unless (eq op 'copy)
(if (file-regular-p filename)
(tramp-compat-delete-file filename 'force)
(tramp-compat-delete-file filename)
(tramp-compat-delete-directory filename 'recursive))))))