For programmatically managing deletion when a program does not have root access, it makes sense to move "deleted" files to a location local to the user directory.
Normally, Emacs does this using the function make-directory-internal()
.
However, my Emacs does this on a location not owned by its user, without testing for ownership, first:
make-directory-internal("~/.local/share/Trash")
According to https://www.gnu.org/software/emacs/manual/html_node/elisp/Testing-Accessibility.html, I can test for ownership pretty easily before attempting a write to a directory:
(file-accessible-directory-p "/foo")
⇒ nil
This Emacs code, instead, tries to use folders that are in my ~, but owned by root. It does not handle the exception by using a folder that it actually has access to.
For example, it's using ~/.local/share/Trash
, instead of ~/.Trash
.
Is there some reason better exception handling hasn't gotten into the code? Do I need to submit a patch, or is this a normal, accepted way to program?
In short, why does this code do this?
According to @Erlaunis' question, What is ./.local/share/Trash (Unix)?, my emacs
cannot edit ~/.local/share/Trash
because it's owned by root.
Because of this, I end up running into B.S. like the following:
Debugger entered--Lisp error: (file-error "Creating directory" "Permission denied" "/Users/myusername/.local/share/Trash")
I posted the full error output here: http://0bin.net/paste/YSQgBhxbFwBnaJer#vcTHnyC+BE-SepxK+5rLmNt73GUg9dZr1Kk6CekiqnQ [link available until 2016 04 23)
(NOTE: While I think part of this question has some general interest outside of Emacs Lisp, I would not say no to suggestions to transfer it to emacs.stackexchange.com. Please advise in comments.)