From 6bb72cbd8b784aebbc8212dfc28bbfcfbb4b8867 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 29 Dec 2011 13:08:18 -0800 Subject: [PATCH] * files.el (move-file-to-trash): Preserve default file modes on error. --- lisp/ChangeLog | 4 ++++ lisp/files.el | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 37286d0780..d1f00198ca 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2011-12-29 Paul Eggert + + * files.el (move-file-to-trash): Preserve default file modes on error. + 2011-12-29 Michael Albinus * net/tramp-sh.el (tramp-find-shell): Set "remote-shell" property diff --git a/lisp/files.el b/lisp/files.el index 0f7386511f..4cb033617c 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6457,12 +6457,14 @@ Otherwise, trash FILENAME using the freedesktop.org conventions, ;; Ensure that the trash directory exists; otherwise, create it. (let ((saved-default-file-modes (default-file-modes))) - (set-default-file-modes ?\700) - (unless (file-exists-p trash-files-dir) - (make-directory trash-files-dir t)) - (unless (file-exists-p trash-info-dir) - (make-directory trash-info-dir t)) - (set-default-file-modes saved-default-file-modes)) + (unwind-protect + (progn + (set-default-file-modes #o700) + (unless (file-exists-p trash-files-dir) + (make-directory trash-files-dir t)) + (unless (file-exists-p trash-info-dir) + (make-directory trash-info-dir t))) + (set-default-file-modes saved-default-file-modes))) ;; Try to move to trash with .trashinfo undo information (save-excursion -- 2.20.1