Matthieu Moy <[EMAIL PROTECTED]> writes:
> Everything is in the title.
>
> Can this function be safely replaced by a simple `delete-file'?
No.
I have the follwing functions on:
GNU Emacs 21.3.1 (i386-pc-linux-gnu, X toolkit) of 2003-09-13 on raven,
modified by Debian
delete-file is an interactive built-in function.
(delete-file FILENAME)
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.
dired-delete-file is a compiled Lisp function in `dired'.
(dired-delete-file FILE &optional RECURSIVE)
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.
`always', delete recursively without asking.
`top', ask for each directory at top level.
Anything else, ask for each sub-directory.
We should add the following to xtla-emacs.el, if dired-delete-file is
not bound:
;; 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) "\
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.
`always', delete recursively without asking.
`top', ask for each directory at top level.
Anything else, ask for each sub-directory."
(let (files)
;; This test is equivalent to
;; (and (file-directory-p fn) (not (file-symlink-p fn)))
;; but more efficient
(if (not (eq t (car (file-attributes file))))
(delete-file file)
(when (and recursive
(setq files
(directory-files file t dired-re-no-dot)) ; Not empty.
(or (eq recursive 'always)
(yes-or-no-p (format "Recursive delete of %s "
(dired-make-relative file)))))
(if (eq recursive 'top) (setq recursive 'always)) ; Don't ask again.
(while files ; Recursively delete (possibly asking).
(dired-delete-file (car files) recursive)
(setq files (cdr files))))
(delete-directory file))))
Stefan.