I'd like to add that if I leave the value of trash-directory to nil, then I believe the default system trash directory is created somewhere in my /home.
Because then, based on my earlier email, CASE A (deleting directory in my emacs user dir works fine, but CASE B (deleting directory in my /tmp) gives that error.
So far, at least on my machine, it looks like if
- delete-by-moving-to-trash is t, AND
- trash-directory is in /tmp and to-be-deleted-dir in is HOME (or vice-versa)
this error occurs.
The situation unfolds further!
Turns out this has nothing to do with dired. So taking off Tino from the To: list (sorry for doing that earlier).
Here are even simpler recipes verified in emacs -Q:
1. First eval this one form to catch the error back trace
(setq debug-on-message "Non-regular")
2. Now eval the 3 forms below one by one.. the last one should fail as the trash-directory and to-be-del directory do not share the same root?/mount?
;; WORKS
;; Both trash-directory and to-be-del dirs in temporary-file-directory
(let ((trash-directory (concat temporary-file-directory
(getenv "USER") "/.trash_emacs/"))
(to-be-del (concat temporary-file-directory "foo/")))
(mkdir trash-directory :parents)
(mkdir to-be-del :parents)
(move-file-to-trash to-be-del))
;; WORKS
;; Both trash-directory and to-be-del dirs in user-emacs-directory
(let ((trash-directory (concat user-emacs-directory "/.trash_emacs/"))
(to-be-del (concat user-emacs-directory "foo/")))
(mkdir trash-directory :parents)
(mkdir to-be-del :parents)
(move-file-to-trash to-be-del))
;; FAILS!!
;; trash-directory in temporary-file-directory but to-be-del dir in
;; user-emacs-directory
(let ((trash-directory (concat user-emacs-directory "/.trash_emacs/"))
(to-be-del (concat temporary-file-directory "foo/")))
(mkdir trash-directory :parents)
(mkdir to-be-del :parents)
(move-file-to-trash to-be-del))
When I eval this 3rd form, I get this error back trace:
Debugger entered--Lisp error: (file-error "Non-regular file" "Is a directory" "/tmp/foo")
rename-file("/tmp/foo" "/home/kmodi/.emacs.d/.trash_emacs/foo.~1~")
move-file-to-trash("/tmp/foo/")
(let ((trash-directory (concat user-emacs-directory "/.trash_emacs/")) (to-be-del (concat temporary-file-directory "foo/"))) (mkdir trash-directory :parents) (mkdir to-be-del :parents) (move-file-to-trash to-be-del))
eval((let ((trash-directory (concat user-emacs-directory "/.trash_emacs/")) (to-be-del (concat temporary-file-directory "foo/"))) (mkdir trash-directory :parents) (mkdir to-be-del :parents) (move-file-to-trash to-be-del)) nil)
elisp--eval-last-sexp(nil)
eval-last-sexp(nil)
funcall-interactively(eval-last-sexp nil)
call-interactively(eval-last-sexp nil nil)
command-execute(eval-last-sexp)