[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dired-kill-tree
From: |
Luc Teirlinck |
Subject: |
Re: dired-kill-tree |
Date: |
Mon, 7 Jun 2004 21:39:51 -0500 (CDT) |
Richard Stallman wrote:
I think this behavior is rather error-prone and counterintuitive.
I would rather consider it a bug, and change it to exclude
DIRNAME even if it is specified in the syntactic form of a file name.
If this makes it hard to kill a subdir, we could add a new interface
for doing that, or we could make this command ask whether
to kill directory DIRNAME as well. That would provide an accident-proof
way to ask for either behavior.
What about the following patch, which kills DIRNAME as well if a
prefix argument is given?
===File ~/dired-aux-diff====================================
*** dired-aux.el 07 Jun 2004 15:59:16 -0500 1.120
--- dired-aux.el 07 Jun 2004 21:04:22 -0500
***************
*** 1852,1870 ****
(> (dired-get-subdir-min elt1)
(dired-get-subdir-min elt2)))))))
! (defun dired-kill-tree (dirname &optional remember-marks)
"Kill all proper subdirs of DIRNAME, excluding DIRNAME itself.
! With optional arg REMEMBER-MARKS, return an alist of marked files."
! (interactive "DKill tree below directory: ")
! (setq dirname (expand-file-name dirname))
(let ((s-alist dired-subdir-alist) dir m-alist)
(while s-alist
(setq dir (car (car s-alist))
s-alist (cdr s-alist))
! (if (and (not (string-equal dir dirname))
! (dired-in-this-tree dir dirname)
! (dired-goto-subdir dir))
! (setq m-alist (nconc (dired-kill-subdir remember-marks) m-alist))))
m-alist))
(defun dired-insert-subdir-newpos (new-dir)
--- 1852,1874 ----
(> (dired-get-subdir-min elt1)
(dired-get-subdir-min elt2)))))))
! (defun dired-kill-tree (dirname &optional remember-marks kill-root)
"Kill all proper subdirs of DIRNAME, excluding DIRNAME itself.
! Interactively, you can kill DIRNAME as well by using a prefix argument.
! In interactive use, the command prompts for DIRNAME.
!
! When called from Lisp, if REMEMBER-MARKS is non-nil, return an alist
! of marked files. If KILL-ROOT is non-nil, kill DIRNAME as well."
! (interactive "DKill tree below directory: \ni\nP")
! (setq dirname (file-name-as-directory (expand-file-name dirname)))
(let ((s-alist dired-subdir-alist) dir m-alist)
(while s-alist
(setq dir (car (car s-alist))
s-alist (cdr s-alist))
! (and (or kill-root (not (string-equal dir dirname)))
! (dired-in-this-tree dir dirname)
! (dired-goto-subdir dir)
! (setq m-alist (nconc (dired-kill-subdir remember-marks) m-alist))))
m-alist))
(defun dired-insert-subdir-newpos (new-dir)
============================================================