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.
This commit is contained in:
parent
f44a59e61a
commit
f1a5d776c4
22 changed files with 237 additions and 135 deletions
18
etc/NEWS
18
etc/NEWS
|
@ -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.
|
||||
|
||||
|
|
|
@ -1,3 +1,70 @@
|
|||
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))))))
|
||||
|
||||
(defun tramp-handle-make-directory (dir &optional parents)
|
||||
|
@ -4112,7 +4112,7 @@ The method used must be an out-of-band method."
|
|||
(tramp-shell-quote-argument localname))))
|
||||
(tramp-error v 'file-error "Couldn't delete %s" directory))))
|
||||
|
||||
(defun tramp-handle-delete-file (filename &optional force)
|
||||
(defun tramp-handle-delete-file (filename &optional trash)
|
||||
"Like `delete-file' for Tramp files."
|
||||
(setq filename (expand-file-name filename))
|
||||
(with-parsed-tramp-file-name filename nil
|
||||
|
@ -4629,7 +4629,7 @@ beginning of local filename are not substituted."
|
|||
|
||||
;; 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 'force))
|
||||
(when tmpinput (tramp-compat-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 +4666,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
|
|||
(when delete (delete-region start end))
|
||||
(unwind-protect
|
||||
(apply 'call-process program tmpfile buffer display args)
|
||||
(tramp-compat-delete-file tmpfile 'force))))
|
||||
(tramp-compat-delete-file tmpfile))))
|
||||
|
||||
(defun tramp-handle-shell-command
|
||||
(command &optional output-buffer error-buffer)
|
||||
|
@ -4731,7 +4731,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
|
|||
(when (listp buffer)
|
||||
(with-current-buffer error-buffer
|
||||
(insert-file-contents (cadr buffer)))
|
||||
(tramp-compat-delete-file (cadr buffer) 'force))
|
||||
(tramp-compat-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 +4813,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
|
|||
(unwind-protect
|
||||
(tramp-call-local-coding-command
|
||||
loc-dec tmpfile2 tmpfile)
|
||||
(tramp-compat-delete-file tmpfile2 'force)))))
|
||||
(tramp-compat-delete-file tmpfile2)))))
|
||||
|
||||
;; Set proper permissions.
|
||||
(set-file-modes tmpfile (tramp-default-file-modes filename))
|
||||
|
@ -4826,7 +4826,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
|
|||
|
||||
;; Error handling.
|
||||
((error quit)
|
||||
(tramp-compat-delete-file tmpfile 'force)
|
||||
(tramp-compat-delete-file tmpfile)
|
||||
(signal (car err) (cdr err))))
|
||||
|
||||
(run-hooks 'tramp-handle-file-local-copy-hook)
|
||||
|
@ -4961,11 +4961,10 @@ coding system might not be determined. This function repairs it."
|
|||
(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 'force))
|
||||
(tramp-compat-delete-file local-copy))
|
||||
(when (stringp remote-copy)
|
||||
(tramp-compat-delete-file
|
||||
(tramp-make-tramp-file-name method user host remote-copy)
|
||||
'force)))))
|
||||
(tramp-make-tramp-file-name method user host remote-copy))))))
|
||||
|
||||
;; Result.
|
||||
(list (expand-file-name filename)
|
||||
|
@ -5155,7 +5154,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
|
|||
(list start end tmpfile append 'no-message lockname confirm))
|
||||
((error quit)
|
||||
(setq tramp-temp-buffer-file-name nil)
|
||||
(tramp-compat-delete-file tmpfile 'force)
|
||||
(tramp-compat-delete-file tmpfile)
|
||||
(signal (car err) (cdr err))))
|
||||
|
||||
;; Now, `last-coding-system-used' has the right value. Remember it.
|
||||
|
@ -5199,13 +5198,13 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
|
|||
(copy-file tmpfile filename t)
|
||||
((error quit)
|
||||
(setq tramp-temp-buffer-file-name nil)
|
||||
(tramp-compat-delete-file tmpfile 'force)
|
||||
(tramp-compat-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 'force))))
|
||||
(tramp-compat-delete-file tmpfile))))
|
||||
|
||||
;; Use inline file transfer.
|
||||
(rem-dec
|
||||
|
@ -5290,7 +5289,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
|
|||
filename rem-dec)))))
|
||||
|
||||
;; Save exit.
|
||||
(tramp-compat-delete-file tmpfile 'force)))
|
||||
(tramp-compat-delete-file tmpfile)))
|
||||
|
||||
;; That's not expected.
|
||||
(t
|
||||
|
@ -6373,7 +6372,7 @@ hosts, or files, disagree."
|
|||
"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 'force)
|
||||
(tramp-compat-delete-file tramp-temp-buffer-file-name)
|
||||
(error nil))))
|
||||
|
||||
(add-hook 'kill-buffer-hook 'tramp-delete-temp-file-function)
|
||||
|
|
|
@ -345,7 +345,7 @@ If CLIENT is non-nil, add a description of it to the logged message."
|
|||
(and (process-contact proc :server)
|
||||
(eq (process-status proc) 'closed)
|
||||
(ignore-errors
|
||||
(delete-file (process-get proc :server-file) t)))
|
||||
(delete-file (process-get proc :server-file))))
|
||||
(server-log (format "Status changed to %s: %s" (process-status proc) msg) proc)
|
||||
(server-delete-client proc))
|
||||
|
||||
|
|
|
@ -1644,8 +1644,8 @@ Files can be renamed to new names or moved to new directories."
|
|||
(if (speedbar-y-or-n-p (format "Delete %s? " f) t)
|
||||
(progn
|
||||
(if (file-directory-p f)
|
||||
(delete-directory f)
|
||||
(delete-file f))
|
||||
(delete-directory f t t)
|
||||
(delete-file f t))
|
||||
(speedbar-message "Okie dokie.")
|
||||
(let ((p (point)))
|
||||
(speedbar-refresh)
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
2010-05-27 Chong Yidong <cyd@stupidchicken.com>
|
||||
|
||||
* 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.
|
||||
|
||||
* callproc.c (delete_temp_file):
|
||||
* buffer.c (Fkill_buffer): Callers changed.
|
||||
|
||||
* lisp.h: Update prototype.
|
||||
|
||||
2010-05-27 Chong Yidong <cyd@stupidchicken.com>
|
||||
|
||||
* xdisp.c (redisplay_window): After redisplay, check if point is
|
||||
|
|
|
@ -1547,7 +1547,7 @@ with SIGHUP. */)
|
|||
Lisp_Object tem;
|
||||
tem = Fsymbol_value (intern ("delete-auto-save-files"));
|
||||
if (! NILP (tem))
|
||||
internal_delete_file (b->auto_save_file_name, Qt);
|
||||
internal_delete_file (b->auto_save_file_name);
|
||||
}
|
||||
|
||||
if (b->base_buffer)
|
||||
|
|
|
@ -856,7 +856,7 @@ delete_temp_file (name)
|
|||
/* Suppress jka-compr handling, etc. */
|
||||
int count = SPECPDL_INDEX ();
|
||||
specbind (intern ("file-name-handler-alist"), Qnil);
|
||||
internal_delete_file (name, Qt);
|
||||
internal_delete_file (name);
|
||||
unbind_to (count, Qnil);
|
||||
return Qnil;
|
||||
}
|
||||
|
|
41
src/fileio.c
41
src/fileio.c
|
@ -2180,12 +2180,7 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal,
|
|||
|
||||
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-directory-internal", Fdelete_directory_internal,
|
|||
}
|
||||
|
||||
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.
|
||||
TRASH non-nil means to trash the file instead of deleting, provided
|
||||
`delete-by-moving-to-trash' is non-nil.
|
||||
|
||||
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)
|
||||
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 @@ Interactively, FORCE is non-nil if called with a prefix arg. */)
|
|||
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 @@ internal_delete_file_1 (ignore)
|
|||
}
|
||||
|
||||
/* 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 @@ This is what happens in interactive use with M-x. */)
|
|||
)
|
||||
call2 (Qdelete_directory, file, Qt);
|
||||
else
|
||||
Fdelete_file (file, Qt);
|
||||
Fdelete_file (file, Qnil);
|
||||
unbind_to (count, Qnil);
|
||||
}
|
||||
else
|
||||
|
@ -5917,8 +5914,10 @@ A non-nil value may result in data loss! */);
|
|||
|
||||
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");
|
||||
|
|
|
@ -3060,7 +3060,7 @@ EXFUN (Fread_file_name, 6);
|
|||
extern Lisp_Object close_file_unwind P_ ((Lisp_Object));
|
||||
extern Lisp_Object restore_point_unwind P_ ((Lisp_Object));
|
||||
extern void report_file_error P_ ((const char *, Lisp_Object)) NO_RETURN;
|
||||
extern int internal_delete_file P_ ((Lisp_Object, Lisp_Object));
|
||||
extern int internal_delete_file P_ ((Lisp_Object));
|
||||
extern void syms_of_fileio P_ ((void));
|
||||
extern Lisp_Object make_temp_name P_ ((Lisp_Object, int));
|
||||
EXFUN (Fmake_symbolic_link, 3);
|
||||
|
|
Loading…
Add table
Reference in a new issue