GNU bug report logs - #58721
28.2; dired with delete-by-moving-to-trash can't trash directory twice

Previous Next

Package: emacs;

Reported by: Gustavo Barros <gusbrs.2016 <at> gmail.com>

Date: Sat, 22 Oct 2022 18:24:01 UTC

Severity: normal

Found in version 28.2

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mike Kupfer <mkupfer <at> alum.berkeley.edu>
To: Eli Zaretskii <eliz <at> gnu.org>, 58721 <at> debbugs.gnu.org, Gustavo Barros <gusbrs.2016 <at> gmail.com>
Subject: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice
Date: Sat, 29 Oct 2022 08:24:53 -0700
Mike Kupfer wrote:

> * copy-directory("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files/emacs-gitH0l..." t nil)
>   rename-file("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files/emacs-gitH0l..." t)
>   move-file-to-trash("/tmp/emacs-git")
>   delete-directory("/tmp/emacs-git" always t)
>   dired-delete-file("/tmp/emacs-git" top t)
>   dired-internal-do-deletions((("/tmp/emacs-git" . #<marker at 233 in tmp<>>)) nil t)
>   dired-do-flagged-delete()
>   funcall-interactively(dired-do-flagged-delete)
>   call-interactively(dired-do-flagged-delete nil nil)
>   command-execute(dired-do-flagged-delete)
[...]
> Hrm.  Shouldn't the call to copy-directory look like
> 
>   copy-directory("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files/emacs-gitH0l..." t nil t)
>                ^^^

I played with this some more this morning, this time on Emacs 29.  It
looks like rename-file should have called copy-directory as

copy-directory("/tmp/emacs-git"
  "/home/kupfer/.local/share/Trash/files/emacs-gitH0lx1e/" t nil t)

That is, 2 changes from current behavior are needed: append a "/" to the
target name, and specify copy-contents as t.

The test case that I used to emulate the current behavior is

1. mkdir a; touch a/b

2. mkdir /tmp/newa
(This assumes that /tmp is a different filesystem than the filesystem
where "a" was created.)

3. M-: (copy-directory "a" "/tmp/newa" t nil) RET

That gives the already-exists error.

With (copy-directory "a" "/tmp/newa/" t nil), I get /tmp/newa/a/b, which
isn't what's wanted for the Trash directory.

With (copy-directory "a" "/tmp/newa/" t nil t), I get /tmp/newa/b, which
is what's desired.

mike




This bug report was last modified 2 years and 182 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.