From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#28797: 26.0.90; Improve printing of error on catching file-error in dired Date: Wed, 25 Oct 2017 00:41:23 +0900 (JST) Message-ID: References: <87a80vbuur.fsf@users.sourceforge.net> <83y3ofjuer.fsf@gnu.org> <871sm7b356.fsf@users.sourceforge.net> <83o9pbjh8b.fsf@gnu.org> <87o9ozcfl0.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1508859747 388 195.159.176.226 (24 Oct 2017 15:42:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 24 Oct 2017 15:42:27 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: kaushal.modi@gmail.com, 28797@debbugs.gnu.org, Tino Calancha To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 24 17:42:23 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e71LL-0006kW-CE for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 Oct 2017 17:42:15 +0200 Original-Received: from localhost ([::1]:44350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e71LP-00086f-La for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 Oct 2017 11:42:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e71LH-00086N-QX for bug-gnu-emacs@gnu.org; Tue, 24 Oct 2017 11:42:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e71L9-0005ho-2e for bug-gnu-emacs@gnu.org; Tue, 24 Oct 2017 11:42:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51369) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e71L8-0005hX-Ul for bug-gnu-emacs@gnu.org; Tue, 24 Oct 2017 11:42:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e71L8-0001Jp-8S for bug-gnu-emacs@gnu.org; Tue, 24 Oct 2017 11:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Oct 2017 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28797 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28797-submit@debbugs.gnu.org id=B28797.15088596965027 (code B ref 28797); Tue, 24 Oct 2017 15:42:02 +0000 Original-Received: (at 28797) by debbugs.gnu.org; 24 Oct 2017 15:41:36 +0000 Original-Received: from localhost ([127.0.0.1]:60050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e71Ki-0001J1-1N for submit@debbugs.gnu.org; Tue, 24 Oct 2017 11:41:36 -0400 Original-Received: from mail-wm0-f50.google.com ([74.125.82.50]:56486) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e71Kf-0001In-Je for 28797@debbugs.gnu.org; Tue, 24 Oct 2017 11:41:33 -0400 Original-Received: by mail-wm0-f50.google.com with SMTP id z3so10229237wme.5 for <28797@debbugs.gnu.org>; Tue, 24 Oct 2017 08:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=R8VeUir9hUh3ECgpwa7EWS2DMDeJHgk2gqErf2fP2Oc=; b=uOdCgkRKn2EuYZh4Co7U4qZloCJT5P8bbxQHk3weB1Otd7jF1JUfB4DrmIJj4ct5jI MiVq2/v8HigKzGsMPRRcW82oXTrTNBQ2krqZkyTb/JwlDgDoXOAo89TC4cwgurtP/OMD e2Z8KQDhTDZQDIYqPgOezlEqAisKfPrgmkXKQBi8WvTQ31mBWUiWDClxuDPnr6xPCN66 3zutQaT7bSJwHe9k8CPJ0J/9l0XSQtdCnoanG0OUeboz1zdd90LJ4RU23WrG5Ru58YmW PCoJceQy4UYt7WLYOvK+mJGlNpMUirYCBgEzietLZ4NpuU5KZPV0THZP0L23UvsgkP4i ozOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=R8VeUir9hUh3ECgpwa7EWS2DMDeJHgk2gqErf2fP2Oc=; b=EGImE5k+5LB1/QPxxRcqHx6W9/sfXLwYftUKOOrv2FmtJKHSl6taR0xBKgFJA2sqnt vKwzS+yewQM7F33vnVaaG34zRZzVad9B2rnLQ9JC58N8WXrXRJp/B/FgPuvgmE7fHdeI 4PtNyxGI5wZpww+z6WhAmDVHY6Vkx0QMtY6km+kfU19zzA7XB1zOyo0yGDraJ1juvWRH vBWNrS31lRsg0w/owbBLHbso5SYAWrjFW294OAtANdrnD5Id/tHdXUpMlzpbkC1rnzHp j25iU4aOKGi2hKjogLfYCmugSjxG10vIW4tIPVeLyGXupzYXvxneC0EFCR3eBMgaikte x70w== X-Gm-Message-State: AMCzsaU0yjqItCSWY6leJr8rry0FLV1+QN9BzmquzjvdV7FRwpFYIOd6 fUd0EmbfCWJNgjJHTmBZ9I4= X-Google-Smtp-Source: ABhQp+Q0X95/H67i9Y1HseMBkAiu1ot4LwB7emZzQ5HZ3coBESYLVjJr2eSCxNT4YaDAAuiGWLlrcg== X-Received: by 10.28.19.130 with SMTP id 124mr8158163wmt.108.1508859687604; Tue, 24 Oct 2017 08:41:27 -0700 (PDT) Original-Received: from calancha-pc (44.red-79-159-65.dynamicip.rima-tde.net. [79.159.65.44]) by smtp.gmail.com with ESMTPSA id s67sm479690wmd.23.2017.10.24.08.41.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 08:41:25 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <87o9ozcfl0.fsf@users.sourceforge.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:138921 Archived-At: On Sun, 22 Oct 2017, Noam Postavsky wrote: >> Let's wait to hear what others think about this part. > > Not seeing any opinions, so here is a fact: due to bug#11218, changing > this breaks dired-test-bug27940 [1]. Fixing #11218 would involve some > major changes to ert internals. > > [1]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27940#65 >The "no" case of dired-test-bug27940 is failing now. I guess if >RECURSIVE is set to nil, we should not try to delete non-empty >directories, or maybe just catch the error if it happens? I think that might be OK. Following add that change on top of your original patch: --8<-----------------------------cut here---------------start------------->8--- commit 36c924fca0b4cde3a320b10d40e9453e55170a0f Author: Tino Calancha Date: Wed Oct 25 00:38:56 2017 +0900 Improve dired deletion error handling (Bug#28797) * lisp/dired (dired-delete-file): If the dir is non-empty and RECURSIVE is nil then return 'skip and don't try to delete the dir (Bug#28797). * lisp/dired.el (dired-internal-do-deletions): Use condition-case-unless-debug. Use `error-message-string' to produce a human readable error message. Don't call dired-fun-in-all-buffers if `dired-delete-file' returns 'skip. diff --git a/lisp/dired.el b/lisp/dired.el index 1ec3ac4f99..74a37da992 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3062,7 +3062,10 @@ dired-delete-file ('"no" (setq recursive nil)) ('"quit" (keyboard-quit))))) (setq recursive nil)) ; Empty dir or recursive is nil. - (delete-directory file recursive trash)))) + ;; Don't delete non-empty dirs when recursive is nil. + (if (and (not empty-dir-p) (not recursive)) + 'skip + (delete-directory file recursive trash))))) (defun dired-do-flagged-delete (&optional nomessage) "In Dired, delete the files flagged for deletion. @@ -3134,18 +3137,19 @@ dired-internal-do-deletions (while l (goto-char (cdr (car l))) (let ((inhibit-read-only t)) - (condition-case err + (condition-case-unless-debug err (let ((fn (car (car l)))) - (dired-delete-file fn dired-recursive-deletes trash) - ;; if we get here, removing worked - (setq succ (1+ succ)) - (progress-reporter-update progress-reporter succ) - (dired-fun-in-all-buffers - (file-name-directory fn) (file-name-nondirectory fn) - #'dired-delete-entry fn)) + (if (eq 'skip (dired-delete-file fn dired-recursive-deletes trash)) + nil + ;; if we get here, removing worked + (setq succ (1+ succ)) + (progress-reporter-update progress-reporter succ) + (dired-fun-in-all-buffers + (file-name-directory fn) (file-name-nondirectory fn) + #'dired-delete-entry fn))) (quit (throw '--delete-cancel (message "OK, canceled"))) (error ;; catch errors from failed deletions - (dired-log "%s\n" err) + (dired-log "%s: %s\n" (car err) (error-message-string err)) (setq failures (cons (car (car l)) failures))))) (setq l (cdr l))) (if (not failures) --8<-----------------------------cut here---------------end--------------->8---