all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: kaushal.modi@gmail.com, 28797@debbugs.gnu.org,
	Tino Calancha <tino.calancha@gmail.com>
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)	[thread overview]
Message-ID: <alpine.DEB.2.20.1710250033470.25693@calancha-pc> (raw)
In-Reply-To: <87o9ozcfl0.fsf@users.sourceforge.net>



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 <tino.calancha@gmail.com>
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---





  reply	other threads:[~2017-10-24 15:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12 14:56 bug#28797: 26.0.90; Improve printing of error on catching file-error in dired Kaushal Modi
2017-10-12 15:08 ` Noam Postavsky
2017-10-13  3:16 ` Noam Postavsky
2017-10-13  8:58   ` Eli Zaretskii
2017-10-13 13:15     ` Noam Postavsky
2017-10-13 13:43       ` Eli Zaretskii
2017-10-22 16:28         ` Noam Postavsky
2017-10-24 15:41           ` Tino Calancha [this message]
2017-10-24 23:33             ` Noam Postavsky
2017-11-05 17:20         ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1710250033470.25693@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=28797@debbugs.gnu.org \
    --cc=kaushal.modi@gmail.com \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.