Subject: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice

From: Gustavo Barros <[email-masked]>
Date: Fri, 28 Oct 2022 13:06:14 -0300

Hi Stefan,

On Fri, 28 Oct 2022 at 12:26, Stefan Kangas <[email-masked]> wrote:

> I get the same result.  But I think this is expected, as the
> `rename-file' docstring says:
>
>     For NEWNAME to be recognized as a directory name, it should
>     end in a slash.
>
> So this function seems to be working as documented.

Thanks for trying! I'm glad I'm not mad. :-)

I had missed this bit of the docstring, and you're right, of course.
So, it seems we are back to `move-file-to-trash', and how it calls
`rename-file'.

I've redefined `move-file-to-trash' to message `new-fn` right before
`rename-file' is being called. And tested both:

    (move-file-to-trash "/path/to/orig/barbaz")
    (move-file-to-trash "/path/to/orig/barbaz/")

And both cases output things like:

Back to top level
/home/<username>/.local/share/Trash/files/barbazOfwLav
Entering debugger...
Back to top level
/home/<username>/.local/share/Trash/files/barbazVICScf
Entering debugger...
Back to top level
/home/<username>/.local/share/Trash/files/barbazVd4241
Entering debugger...
Back to top level
/home/<username>/.local/share/Trash/files/barbaz04EjUm
Entering debugger...
Back to top level

That is, no end slash appended to the directory at
`move-file-to-trash'. So, it appears we have a good suspect. Why it
works when the filesystem is the same still beats me.