diff options
| author | Chong Yidong | 2010-05-27 19:30:11 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-05-27 19:30:11 -0400 |
| commit | f1a5d776c4985b3ff1a2c6c17dd71dedf5d726e8 (patch) | |
| tree | 64e61e6b8ea6b3a2f10bb090d26823dfcef4b4d0 /src | |
| parent | f44a59e61a98543d4ce8b6952f1946dd955ce988 (diff) | |
| download | emacs-f1a5d776c4985b3ff1a2c6c17dd71dedf5d726e8.tar.gz emacs-f1a5d776c4985b3ff1a2c6c17dd71dedf5d726e8.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/buffer.c | 2 | ||||
| -rw-r--r-- | src/callproc.c | 2 | ||||
| -rw-r--r-- | src/fileio.c | 41 | ||||
| -rw-r--r-- | src/lisp.h | 2 |
5 files changed, 36 insertions, 24 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 883d603bf35..8c9e1568008 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,18 @@ | |||
| 1 | 2010-05-27 Chong Yidong <cyd@stupidchicken.com> | 1 | 2010-05-27 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 2 | ||
| 3 | * fileio.c (Fdelete_file): Change meaning of optional arg to mean | ||
| 4 | whether to trash. | ||
| 5 | (internal_delete_file, Frename_file): Callers changed. | ||
| 6 | (delete_by_moving_to_trash): Doc fix. | ||
| 7 | (Fdelete_directory_internal): Don't move to trash. | ||
| 8 | |||
| 9 | * callproc.c (delete_temp_file): | ||
| 10 | * buffer.c (Fkill_buffer): Callers changed. | ||
| 11 | |||
| 12 | * lisp.h: Update prototype. | ||
| 13 | |||
| 14 | 2010-05-27 Chong Yidong <cyd@stupidchicken.com> | ||
| 15 | |||
| 3 | * xdisp.c (redisplay_window): After redisplay, check if point is | 16 | * xdisp.c (redisplay_window): After redisplay, check if point is |
| 4 | still valid before setting it (Bug#6177). | 17 | still valid before setting it (Bug#6177). |
| 5 | 18 | ||
diff --git a/src/buffer.c b/src/buffer.c index 339bc99dcb1..b19286c6ea9 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1547,7 +1547,7 @@ with SIGHUP. */) | |||
| 1547 | Lisp_Object tem; | 1547 | Lisp_Object tem; |
| 1548 | tem = Fsymbol_value (intern ("delete-auto-save-files")); | 1548 | tem = Fsymbol_value (intern ("delete-auto-save-files")); |
| 1549 | if (! NILP (tem)) | 1549 | if (! NILP (tem)) |
| 1550 | internal_delete_file (b->auto_save_file_name, Qt); | 1550 | internal_delete_file (b->auto_save_file_name); |
| 1551 | } | 1551 | } |
| 1552 | 1552 | ||
| 1553 | if (b->base_buffer) | 1553 | if (b->base_buffer) |
diff --git a/src/callproc.c b/src/callproc.c index 44dd6ed7764..f922433eb42 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -856,7 +856,7 @@ delete_temp_file (name) | |||
| 856 | /* Suppress jka-compr handling, etc. */ | 856 | /* Suppress jka-compr handling, etc. */ |
| 857 | int count = SPECPDL_INDEX (); | 857 | int count = SPECPDL_INDEX (); |
| 858 | specbind (intern ("file-name-handler-alist"), Qnil); | 858 | specbind (intern ("file-name-handler-alist"), Qnil); |
| 859 | internal_delete_file (name, Qt); | 859 | internal_delete_file (name); |
| 860 | unbind_to (count, Qnil); | 860 | unbind_to (count, Qnil); |
| 861 | return Qnil; | 861 | return Qnil; |
| 862 | } | 862 | } |
diff --git a/src/fileio.c b/src/fileio.c index de32bfecd34..d3aea0f1e91 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2180,12 +2180,7 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal, | |||
| 2180 | 2180 | ||
| 2181 | CHECK_STRING (directory); | 2181 | CHECK_STRING (directory); |
| 2182 | directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil)); | 2182 | directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil)); |
| 2183 | |||
| 2184 | if (delete_by_moving_to_trash) | ||
| 2185 | return call1 (Qmove_file_to_trash, directory); | ||
| 2186 | |||
| 2187 | encoded_dir = ENCODE_FILE (directory); | 2183 | encoded_dir = ENCODE_FILE (directory); |
| 2188 | |||
| 2189 | dir = SDATA (encoded_dir); | 2184 | dir = SDATA (encoded_dir); |
| 2190 | 2185 | ||
| 2191 | if (rmdir (dir) != 0) | 2186 | if (rmdir (dir) != 0) |
| @@ -2195,19 +2190,21 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal, | |||
| 2195 | } | 2190 | } |
| 2196 | 2191 | ||
| 2197 | DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, | 2192 | DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, |
| 2198 | "(list (read-file-name \"Delete file: \" nil default-directory \ | 2193 | "(list (read-file-name \ |
| 2199 | (confirm-nonexistent-file-or-buffer)) \ | 2194 | (if (and delete-by-moving-to-trash (null current-prefix-arg)) \ |
| 2200 | current-prefix-arg)", | 2195 | \"Move file to trash: \" \"Delete file: \") \ |
| 2196 | nil default-directory (confirm-nonexistent-file-or-buffer)) \ | ||
| 2197 | (null current-prefix-arg))", | ||
| 2201 | doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. | 2198 | doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. |
| 2202 | If file has multiple names, it continues to exist with the other names. | 2199 | If file has multiple names, it continues to exist with the other names. |
| 2200 | TRASH non-nil means to trash the file instead of deleting, provided | ||
| 2201 | `delete-by-moving-to-trash' is non-nil. | ||
| 2203 | 2202 | ||
| 2204 | If optional arg FORCE is non-nil, really delete the file regardless of | 2203 | When called interactively, TRASH is t if no prefix argument is given. |
| 2205 | `delete-by-moving-to-trash'. Otherwise, \"deleting\" actually moves | 2204 | With a prefix argument, TRASH is nil. */) |
| 2206 | it to the system's trash can if `delete-by-moving-to-trash' is non-nil. | 2205 | (filename, trash) |
| 2207 | Interactively, FORCE is non-nil if called with a prefix arg. */) | ||
| 2208 | (filename, force) | ||
| 2209 | Lisp_Object filename; | 2206 | Lisp_Object filename; |
| 2210 | Lisp_Object force; | 2207 | Lisp_Object trash; |
| 2211 | { | 2208 | { |
| 2212 | Lisp_Object handler; | 2209 | Lisp_Object handler; |
| 2213 | Lisp_Object encoded_file; | 2210 | Lisp_Object encoded_file; |
| @@ -2226,7 +2223,7 @@ Interactively, FORCE is non-nil if called with a prefix arg. */) | |||
| 2226 | if (!NILP (handler)) | 2223 | if (!NILP (handler)) |
| 2227 | return call2 (handler, Qdelete_file, filename); | 2224 | return call2 (handler, Qdelete_file, filename); |
| 2228 | 2225 | ||
| 2229 | if (delete_by_moving_to_trash && NILP (force)) | 2226 | if (delete_by_moving_to_trash && !NILP (trash)) |
| 2230 | return call1 (Qmove_file_to_trash, filename); | 2227 | return call1 (Qmove_file_to_trash, filename); |
| 2231 | 2228 | ||
| 2232 | encoded_file = ENCODE_FILE (filename); | 2229 | encoded_file = ENCODE_FILE (filename); |
| @@ -2244,14 +2241,14 @@ internal_delete_file_1 (ignore) | |||
| 2244 | } | 2241 | } |
| 2245 | 2242 | ||
| 2246 | /* Delete file FILENAME, returning 1 if successful and 0 if failed. | 2243 | /* Delete file FILENAME, returning 1 if successful and 0 if failed. |
| 2247 | FORCE means to ignore `delete-by-moving-to-trash'. */ | 2244 | This ignores `delete-by-moving-to-trash'. */ |
| 2248 | 2245 | ||
| 2249 | int | 2246 | int |
| 2250 | internal_delete_file (Lisp_Object filename, Lisp_Object force) | 2247 | internal_delete_file (Lisp_Object filename) |
| 2251 | { | 2248 | { |
| 2252 | Lisp_Object tem; | 2249 | Lisp_Object tem; |
| 2253 | 2250 | ||
| 2254 | tem = internal_condition_case_2 (Fdelete_file, filename, force, | 2251 | tem = internal_condition_case_2 (Fdelete_file, filename, Qnil, |
| 2255 | Qt, internal_delete_file_1); | 2252 | Qt, internal_delete_file_1); |
| 2256 | return NILP (tem); | 2253 | return NILP (tem); |
| 2257 | } | 2254 | } |
| @@ -2345,7 +2342,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2345 | ) | 2342 | ) |
| 2346 | call2 (Qdelete_directory, file, Qt); | 2343 | call2 (Qdelete_directory, file, Qt); |
| 2347 | else | 2344 | else |
| 2348 | Fdelete_file (file, Qt); | 2345 | Fdelete_file (file, Qnil); |
| 2349 | unbind_to (count, Qnil); | 2346 | unbind_to (count, Qnil); |
| 2350 | } | 2347 | } |
| 2351 | else | 2348 | else |
| @@ -5917,8 +5914,10 @@ A non-nil value may result in data loss! */); | |||
| 5917 | 5914 | ||
| 5918 | DEFVAR_BOOL ("delete-by-moving-to-trash", &delete_by_moving_to_trash, | 5915 | DEFVAR_BOOL ("delete-by-moving-to-trash", &delete_by_moving_to_trash, |
| 5919 | doc: /* Specifies whether to use the system's trash can. | 5916 | doc: /* Specifies whether to use the system's trash can. |
| 5920 | When non-nil, the function `move-file-to-trash' will be used by | 5917 | When non-nil, certain file deletion commands use the function |
| 5921 | `delete-file' and `delete-directory'. */); | 5918 | `move-file-to-trash' instead of deleting files outright. |
| 5919 | This includes interactive calls to `delete-file' and | ||
| 5920 | `delete-directory' and the Dired deletion commands. */); | ||
| 5922 | delete_by_moving_to_trash = 0; | 5921 | delete_by_moving_to_trash = 0; |
| 5923 | Qdelete_by_moving_to_trash = intern_c_string ("delete-by-moving-to-trash"); | 5922 | Qdelete_by_moving_to_trash = intern_c_string ("delete-by-moving-to-trash"); |
| 5924 | Qmove_file_to_trash = intern_c_string ("move-file-to-trash"); | 5923 | Qmove_file_to_trash = intern_c_string ("move-file-to-trash"); |
diff --git a/src/lisp.h b/src/lisp.h index b4ff446b064..e17931ca366 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3060,7 +3060,7 @@ EXFUN (Fread_file_name, 6); | |||
| 3060 | extern Lisp_Object close_file_unwind P_ ((Lisp_Object)); | 3060 | extern Lisp_Object close_file_unwind P_ ((Lisp_Object)); |
| 3061 | extern Lisp_Object restore_point_unwind P_ ((Lisp_Object)); | 3061 | extern Lisp_Object restore_point_unwind P_ ((Lisp_Object)); |
| 3062 | extern void report_file_error P_ ((const char *, Lisp_Object)) NO_RETURN; | 3062 | extern void report_file_error P_ ((const char *, Lisp_Object)) NO_RETURN; |
| 3063 | extern int internal_delete_file P_ ((Lisp_Object, Lisp_Object)); | 3063 | extern int internal_delete_file P_ ((Lisp_Object)); |
| 3064 | extern void syms_of_fileio P_ ((void)); | 3064 | extern void syms_of_fileio P_ ((void)); |
| 3065 | extern Lisp_Object make_temp_name P_ ((Lisp_Object, int)); | 3065 | extern Lisp_Object make_temp_name P_ ((Lisp_Object, int)); |
| 3066 | EXFUN (Fmake_symbolic_link, 3); | 3066 | EXFUN (Fmake_symbolic_link, 3); |