all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#7011: 24.1; [PATCH] improve eshell-remove-entries
@ 2010-09-11  2:49 Leo
  2010-09-11  2:51 ` John Wiegley
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Leo @ 2010-09-11  2:49 UTC (permalink / raw
  To: 7011; +Cc: John Wiegley


eshell-remove-entries implements its own recursive delete of files in a
directory and this does not play well with the move-to-trash feature.
For example, if you use 'rm -rf' in eshell to delete a dir with hundreds
of files in it (eg .git), you will get hundreds of files at the top
level of the Trash bin.

The following patch enables eshell-remove-entries to support
move-to-trash feature and use delete-directory's RECURSIVE arg instead.


diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index 6ceb591..e12e03c 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -204,12 +204,6 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
       (if (and (file-directory-p (car files))
 	       (not (file-symlink-p (car files))))
 	  (let ((dir (file-name-as-directory (car files))))
-	    (eshell-remove-entries dir
-				   (mapcar
-				    (function
-				     (lambda (file)
-				       (concat dir file)))
-				    (directory-files dir)))
 	    (if verbose
 		(eshell-printn (format "rm: removing directory `%s'"
 				       (car files))))
@@ -219,7 +213,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
 			 (not (y-or-n-p
 			       (format "rm: remove directory `%s'? "
 				       (car files))))))
-	      (eshell-funcalln 'delete-directory (car files))))
+	      (eshell-funcalln 'delete-directory (car files) t t)))
 	(if verbose
 	    (eshell-printn (format "rm: removing file `%s'"
 				   (car files))))
@@ -228,7 +222,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
 			 (not (y-or-n-p
 			       (format "rm: remove `%s'? "
 				       (car files))))))
-	  (eshell-funcalln 'delete-file (car files)))))
+	  (eshell-funcalln 'delete-file (car files) t))))
     (setq files (cdr files))))
 
 (defun eshell/rm (&rest args)


Leo





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#7011: 24.1; [PATCH] improve eshell-remove-entries
  2010-09-11  2:49 bug#7011: 24.1; [PATCH] improve eshell-remove-entries Leo
@ 2010-09-11  2:51 ` John Wiegley
  2010-09-11 12:09 ` Leo
  2010-10-24 17:25 ` Chong Yidong
  2 siblings, 0 replies; 4+ messages in thread
From: John Wiegley @ 2010-09-11  2:51 UTC (permalink / raw
  To: Leo; +Cc: bug-gnu-emacs

Good patch, Leo!

John

On Sep 10, 2010, at 10:49 PM, Leo wrote:

> eshell-remove-entries implements its own recursive delete of files in a
> directory and this does not play well with the move-to-trash feature.
> For example, if you use 'rm -rf' in eshell to delete a dir with hundreds
> of files in it (eg .git), you will get hundreds of files at the top
> level of the Trash bin.
> 
> The following patch enables eshell-remove-entries to support
> move-to-trash feature and use delete-directory's RECURSIVE arg instead.
> 
> 
> diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
> index 6ceb591..e12e03c 100644
> --- a/lisp/eshell/em-unix.el
> +++ b/lisp/eshell/em-unix.el
> @@ -204,12 +204,6 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
>       (if (and (file-directory-p (car files))
> 	       (not (file-symlink-p (car files))))
> 	  (let ((dir (file-name-as-directory (car files))))
> -	    (eshell-remove-entries dir
> -				   (mapcar
> -				    (function
> -				     (lambda (file)
> -				       (concat dir file)))
> -				    (directory-files dir)))
> 	    (if verbose
> 		(eshell-printn (format "rm: removing directory `%s'"
> 				       (car files))))
> @@ -219,7 +213,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
> 			 (not (y-or-n-p
> 			       (format "rm: remove directory `%s'? "
> 				       (car files))))))
> -	      (eshell-funcalln 'delete-directory (car files))))
> +	      (eshell-funcalln 'delete-directory (car files) t t)))
> 	(if verbose
> 	    (eshell-printn (format "rm: removing file `%s'"
> 				   (car files))))
> @@ -228,7 +222,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
> 			 (not (y-or-n-p
> 			       (format "rm: remove `%s'? "
> 				       (car files))))))
> -	  (eshell-funcalln 'delete-file (car files)))))
> +	  (eshell-funcalln 'delete-file (car files) t))))
>     (setq files (cdr files))))
> 
> (defun eshell/rm (&rest args)
> 
> 
> Leo






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#7011: 24.1; [PATCH] improve eshell-remove-entries
  2010-09-11  2:49 bug#7011: 24.1; [PATCH] improve eshell-remove-entries Leo
  2010-09-11  2:51 ` John Wiegley
@ 2010-09-11 12:09 ` Leo
  2010-10-24 17:25 ` Chong Yidong
  2 siblings, 0 replies; 4+ messages in thread
From: Leo @ 2010-09-11 12:09 UTC (permalink / raw
  To: bug-gnu-emacs

On 2010-09-11 03:49 +0100, Leo wrote:
> eshell-remove-entries implements its own recursive delete of files in a
> directory and this does not play well with the move-to-trash feature.
> For example, if you use 'rm -rf' in eshell to delete a dir with hundreds
> of files in it (eg .git), you will get hundreds of files at the top
> level of the Trash bin.
>
> The following patch enables eshell-remove-entries to support
> move-to-trash feature and use delete-directory's RECURSIVE arg instead.
>
>
> diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
> index 6ceb591..e12e03c 100644
> --- a/lisp/eshell/em-unix.el
> +++ b/lisp/eshell/em-unix.el
> @@ -204,12 +204,6 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
>        (if (and (file-directory-p (car files))
>  	       (not (file-symlink-p (car files))))
>  	  (let ((dir (file-name-as-directory (car files))))
> -	    (eshell-remove-entries dir
> -				   (mapcar
> -				    (function
> -				     (lambda (file)
> -				       (concat dir file)))
> -				    (directory-files dir)))
>  	    (if verbose
>  		(eshell-printn (format "rm: removing directory `%s'"
>  				       (car files))))
> @@ -219,7 +213,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
>  			 (not (y-or-n-p
>  			       (format "rm: remove directory `%s'? "
>  				       (car files))))))
> -	      (eshell-funcalln 'delete-directory (car files))))
> +	      (eshell-funcalln 'delete-directory (car files) t t)))
>  	(if verbose
>  	    (eshell-printn (format "rm: removing file `%s'"
>  				   (car files))))
> @@ -228,7 +222,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
>  			 (not (y-or-n-p
>  			       (format "rm: remove `%s'? "
>  				       (car files))))))
> -	  (eshell-funcalln 'delete-file (car files)))))
> +	  (eshell-funcalln 'delete-file (car files) t))))
>      (setq files (cdr files))))
>  
>  (defun eshell/rm (&rest args)
>
>
> Leo

Also remove the unused let bound var dir.

diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index e12e03c..f22cc4f 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -203,7 +203,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
 	    (eshell-error "rm: cannot remove `.' or `..'\n"))
       (if (and (file-directory-p (car files))
 	       (not (file-symlink-p (car files))))
-	  (let ((dir (file-name-as-directory (car files))))
+	  (progn
 	    (if verbose
 		(eshell-printn (format "rm: removing directory `%s'"
 				       (car files))))

Leo






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#7011: 24.1; [PATCH] improve eshell-remove-entries
  2010-09-11  2:49 bug#7011: 24.1; [PATCH] improve eshell-remove-entries Leo
  2010-09-11  2:51 ` John Wiegley
  2010-09-11 12:09 ` Leo
@ 2010-10-24 17:25 ` Chong Yidong
  2 siblings, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2010-10-24 17:25 UTC (permalink / raw
  To: Leo; +Cc: John Wiegley, 7011

Leo <sdl.web@gmail.com> writes:

> eshell-remove-entries implements its own recursive delete of files in a
> directory and this does not play well with the move-to-trash feature.
> For example, if you use 'rm -rf' in eshell to delete a dir with hundreds
> of files in it (eg .git), you will get hundreds of files at the top
> level of the Trash bin.
>
> The following patch enables eshell-remove-entries to support
> move-to-trash feature and use delete-directory's RECURSIVE arg instead.

Thanks.  I've committed this patch, and your followup patch.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-10-24 17:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-11  2:49 bug#7011: 24.1; [PATCH] improve eshell-remove-entries Leo
2010-09-11  2:51 ` John Wiegley
2010-09-11 12:09 ` Leo
2010-10-24 17:25 ` Chong Yidong

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.