Mercurial > emacs
diff src/fileio.c @ 108806:511da81b16c5
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.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 27 May 2010 19:30:11 -0400 |
parents | 0f1244b4539c |
children | 6515310887ec |
line wrap: on
line diff
--- a/src/fileio.c Thu May 27 11:49:01 2010 -0400 +++ b/src/fileio.c Thu May 27 19:30:11 2010 -0400 @@ -2180,12 +2180,7 @@ CHECK_STRING (directory); directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil)); - - if (delete_by_moving_to_trash) - return call1 (Qmove_file_to_trash, directory); - encoded_dir = ENCODE_FILE (directory); - dir = SDATA (encoded_dir); if (rmdir (dir) != 0) @@ -2195,19 +2190,21 @@ } DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, - "(list (read-file-name \"Delete file: \" nil default-directory \ - (confirm-nonexistent-file-or-buffer)) \ - current-prefix-arg)", + "(list (read-file-name \ + (if (and delete-by-moving-to-trash (null current-prefix-arg)) \ + \"Move file to trash: \" \"Delete file: \") \ + nil default-directory (confirm-nonexistent-file-or-buffer)) \ + (null current-prefix-arg))", doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. If file has multiple names, it continues to exist with the other names. - -If optional arg FORCE is non-nil, really delete the file regardless of -`delete-by-moving-to-trash'. Otherwise, \"deleting\" actually moves -it to the system's trash can if `delete-by-moving-to-trash' is non-nil. -Interactively, FORCE is non-nil if called with a prefix arg. */) - (filename, force) +TRASH non-nil means to trash the file instead of deleting, 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. */) + (filename, trash) Lisp_Object filename; - Lisp_Object force; + Lisp_Object trash; { Lisp_Object handler; Lisp_Object encoded_file; @@ -2226,7 +2223,7 @@ if (!NILP (handler)) return call2 (handler, Qdelete_file, filename); - if (delete_by_moving_to_trash && NILP (force)) + if (delete_by_moving_to_trash && !NILP (trash)) return call1 (Qmove_file_to_trash, filename); encoded_file = ENCODE_FILE (filename); @@ -2244,14 +2241,14 @@ } /* Delete file FILENAME, returning 1 if successful and 0 if failed. - FORCE means to ignore `delete-by-moving-to-trash'. */ + This ignores `delete-by-moving-to-trash'. */ int -internal_delete_file (Lisp_Object filename, Lisp_Object force) +internal_delete_file (Lisp_Object filename) { Lisp_Object tem; - tem = internal_condition_case_2 (Fdelete_file, filename, force, + tem = internal_condition_case_2 (Fdelete_file, filename, Qnil, Qt, internal_delete_file_1); return NILP (tem); } @@ -2345,7 +2342,7 @@ ) call2 (Qdelete_directory, file, Qt); else - Fdelete_file (file, Qt); + Fdelete_file (file, Qnil); unbind_to (count, Qnil); } else @@ -5917,8 +5914,10 @@ DEFVAR_BOOL ("delete-by-moving-to-trash", &delete_by_moving_to_trash, doc: /* Specifies whether to use the system's trash can. -When non-nil, the function `move-file-to-trash' will be used by -`delete-file' and `delete-directory'. */); +When non-nil, certain file deletion commands use the function +`move-file-to-trash' instead of deleting files outright. +This includes interactive calls to `delete-file' and +`delete-directory' and the Dired deletion commands. */); delete_by_moving_to_trash = 0; Qdelete_by_moving_to_trash = intern_c_string ("delete-by-moving-to-trash"); Qmove_file_to_trash = intern_c_string ("move-file-to-trash");