From: Eli Zaretskii Date: Sun, 6 Aug 2023 14:03:26 +0000 (+0300) Subject: Fix last change of 'delete-file' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=400df210ce0cc1ee0113b14a5ad92764d148c620;p=emacs.git Fix last change of 'delete-file' * src/fileio.c (Fdelete_file_internal): Expand file name here, as all primitives must. (internal_delete_file): Adjust to the fact that Fdelete_file was renamed. * lisp/files.el (delete-file): Don't expand-file-name here, as the called primitives already do. Fix typo in doc string. --- diff --git a/lisp/files.el b/lisp/files.el index 84a8c308b09..cc6e860319e 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6354,7 +6354,7 @@ non-nil and if FN fails due to a missing file or directory." (defun delete-file (filename &optional trash) "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.q +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. @@ -6367,7 +6367,7 @@ With a prefix argument, TRASH is nil." (null current-prefix-arg))) (if (and (file-directory-p filename) (not (file-symlink-p filename))) (signal 'file-error (list "Removing old name: is a directory" filename))) - (let* ((filename (expand-file-name filename)) (handler (find-file-name-handler filename 'delete-file))) + (let* ((handler (find-file-name-handler filename 'delete-file))) (cond (handler (funcall handler 'delete-file filename trash)) ((and delete-by-moving-to-trash trash) (move-file-to-trash filename)) (t (delete-file-internal filename))))) diff --git a/src/fileio.c b/src/fileio.c index e49a4a3836b..18879aa8fa3 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2463,12 +2463,14 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal, } DEFUN ("delete-file-internal", Fdelete_file_internal, Sdelete_file_internal, 1, 1, 0, - doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. + doc: /* Delete file named FILENAME; internal use only. +If it is a symlink, remove the symlink. If file has multiple names, it continues to exist with the other names. */) (Lisp_Object filename) { Lisp_Object encoded_file; + filename = Fexpand_file_name (filename, Qnil); encoded_file = ENCODE_FILE (filename); if (unlink (SSDATA (encoded_file)) != 0 && errno != ENOENT) @@ -2492,7 +2494,7 @@ internal_delete_file (Lisp_Object filename) { Lisp_Object tem; - tem = internal_condition_case_2 (Fdelete_file, filename, Qnil, + tem = internal_condition_case_2 (Fdelete_file_internal, filename, Qt, internal_delete_file_1); return NILP (tem); }