From 8aa1e9c9e55d4d3c857048b2bc5f52066d953ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Codru=C8=9B=20Constantin=20Gu=C8=99oi?= Date: Fri, 7 May 2021 19:20:45 +0100 Subject: Fix moving directories with the same name to trash Refs: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47135 To reproduce, save this to a `bug.el` file: ```elisp (setq delete-by-moving-to-trash t) (let ((test-dir "~/test123")) (progn (message "Creating directory: 1") (make-directory test-dir) (message "Deleting directory: 1") (delete-directory test-dir t t) (message "Creating directory: 2") (make-directory test-dir) (message "Deleting directory: 2") (delete-directory test-dir t t) (message "Success!"))) ``` And execute with: `emacs -nw -Q -l ./bug.el`. Expected: "Success!" Actual: "Renaming: Not a directory, /home/me/test123, /home/me/.local/share/Trash/files/test123Wiibmk" Looks like the code was creating a temp file in the trash bin and then trying to move the directory overwriting it. I assume the intent was to only get a unique file name, and not actually create a file, reason why I canged the function call to be `make-temp-name`. --- lisp/files.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/files.el b/lisp/files.el index 93a0e07aba..da33ee815f 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -7932,7 +7932,7 @@ move-file-to-trash (expand-file-name files-base trash-files-dir)) (setq overwrite t files-base (file-name-nondirectory - (make-temp-file + (make-temp-name (expand-file-name files-base trash-files-dir))))) (setq info-fn (expand-file-name -- 2.31.1