1

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.)

Community
  • 1
  • 1
Nathan Basanese
  • 8,475
  • 10
  • 37
  • 66
  • // , It seems like a fairly common (https://www.reddit.com/r/emacs/comments/1cec8q/packageel_cant_install_creating_directory/) problem, with an obvious solution (https://www.gnu.org/software/emacs/manual/html_node/elisp/Testing-Accessibility.html). I wonder what I'm missing, here. – Nathan Basanese Mar 23 '16 at 20:19
  • 1
    Here is a related thread entitled **Delete files to Trash on OS X**: http://emacs.stackexchange.com/questions/15009/delete-files-to-trash-on-os-x/15012 – lawlist Mar 23 '16 at 20:56
  • // , // , That's definitely related. Doesn't say _why_ it's done this way, in *module management*, no less, in the first place, though. – Nathan Basanese Mar 23 '16 at 21:13
  • 1
    Why is ~/.local/share/Trash owned by root on your system? Sounds like a misconfiguration to me. – Stefan Mar 24 '16 at 13:55
  • // , @Stefan I thought so too, at first, but I did some reading. I own `~/.Trash`, and `root` owns `~/.local/share/Trash`. It's not a misconfiguration according to http://stackoverflow.com/questions/33349369/what-is-local-share-trash-unix. I guess it keeps things organized when `root` trashes things from my home directory? – Nathan Basanese Mar 24 '16 at 17:52
  • 1
    @NathanBasanese: I see no reason why we should believe this "Reacher Gilt" guy on this matter. The link he provides as supporting evidence is completely unrelated. It seems this askubuntu question is just one of the many cases of "the blind leading the blind". It's **very odd** to have root owned files anywhere under `~/`, so if `.local/share/Trash` was an exception, we'd know about it. – Stefan Mar 24 '16 at 19:12
  • // , Well, I, at least, live in the blind category, here, then. My `$ stat .local` gives me a response of `drwxr-xr-x 4 root staff`. I have compiled myself Emacs 25 and I use http://brew.sh. Would you care to go in and comment on that "Reacher Gilt" guy's answer, then? – Nathan Basanese Mar 30 '16 at 20:04
  • // , My `$ ls -laF | grep local/` gives me a response of `drwxr-xr-x 4 root staff 136 Feb 10 11:25 .local/`. – Nathan Basanese Mar 30 '16 at 20:12

0 Answers0