From: Glenn Morris Date: Sat, 19 Feb 2011 18:55:15 +0000 (-0800) Subject: Merge dired-x's dired-clean-up-after-deletion into dired's version. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~805 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=429242317e3abaa40dad9f3d2a9eb537cd0fd9b3;p=emacs.git Merge dired-x's dired-clean-up-after-deletion into dired's version. * lisp/dired-x.el (dired-clean-up-after-deletion): Merge into dired.el. * lisp/dired.el (dired-clean-up-after-deletion): Merge dired-x's version. (dired-clean-up-buffers-too): Declare. * doc/misc/dired-x.texi (Technical Details): No longer redefine dired-clean-up-after-deletion. --- diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 882eec34193..d6fbc06d721 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,7 +1,7 @@ 2011-02-19 Glenn Morris * dired-x.texi (Technical Details): No longer redefines dired-add-entry, - or dired-initial-position. + dired-initial-position, or dired-clean-up-after-deletion. 2011-02-18 Glenn Morris diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi index 9f7b40ceb58..3bc2964c1b3 100644 --- a/doc/misc/dired-x.texi +++ b/doc/misc/dired-x.texi @@ -177,22 +177,15 @@ Point}). @cindex Redefined functions @cindex @file{dired-aux.el} -When loaded this code @emph{redefines} the following functions of GNU Emacs -from @file{dired.el} - -@itemize @bullet -@item -@code{dired-clean-up-after-deletion} -@item -@code{dired-find-buffer-nocreate} -@end itemize - -@noindent +When loaded this code @emph{redefines} some standard Dired functions. +From @file{dired.el}, the function @code{dired-find-buffer-nocreate}; and from @file{dired-aux.el} the function @code{dired-read-shell-command}. -In addition, once @file{dired.el} is loaded, @code{dired-add-entry} -obeys Dired Omit mode (@pxref{Omitting Files in Dired}), if it is active. -Similarly, @code{dired-initial-position} obeys @code{dired-find-subdir} -(@pxref{Miscellaneous Commands}). +In addition, once @file{dired-x.el} is loaded, the following Dired +functions offer additional features. @code{dired-add-entry} obeys Dired +Omit mode (@pxref{Omitting Files in Dired}), if it is active. +@code{dired-initial-position} obeys @code{dired-find-subdir} +(@pxref{Miscellaneous Commands}). @code{dired-clean-up-after-deletion} +respects the value of @code{dired-clean-up-buffers-too}. @node Installation, Omitting Files in Dired, Introduction, Top @chapter Installation diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 824f5f24d06..8372c03f73d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2011-02-19 Glenn Morris + * dired-x.el (dired-clean-up-after-deletion): Merge into dired.el. + * dired.el (dired-clean-up-after-deletion): Merge dired-x's version. + (dired-clean-up-buffers-too): Declare. + * dired-x.el (dired-initial-position): Merge into dired.el's version. * dired.el (dired-initial-position): Merge dired-x's version here. (dired-find-subdir): Declare. diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 901614e49d0..1810d59712d 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -48,7 +48,7 @@ ;; User customization: M-x customize-group RET dired-x RET. ;; When loaded this code redefines the following functions of GNU Emacs: -;; From dired.el: dired-clean-up-after-deletion, dired-find-buffer-nocreate. +;; From dired.el: dired-find-buffer-nocreate. ;; From dired-aux.el: dired-read-shell-command. ;; *Please* see the `dired-x' info pages for more details. @@ -322,32 +322,6 @@ See also the functions: (dired-hack-local-variables) (dired-omit-startup)) - -;;; BUFFER CLEANING. - -;; REDEFINE. -(defun dired-clean-up-after-deletion (fn) - "Clean up after a deleted file or directory FN. -Remove expanded subdir of deleted dir, if any." - (save-excursion (and (cdr dired-subdir-alist) - (dired-goto-subdir fn) - (dired-kill-subdir))) - ;; Offer to kill buffer of deleted file FN. - (when dired-clean-up-buffers-too - (let ((buf (get-file-buffer fn))) - (and buf - (funcall #'y-or-n-p - (format "Kill buffer of %s, too? " - (file-name-nondirectory fn))) - (kill-buffer buf))) - (let ((buf-list (dired-buffers-for-dir (expand-file-name fn)))) - (and buf-list - (y-or-n-p (format "Kill dired buffer%s of %s, too? " - (dired-plural-s (length buf-list)) - (file-name-nondirectory fn))) - (dolist (buf buf-list) - (kill-buffer buf)))))) - ;;; EXTENSION MARKING FUNCTIONS. diff --git a/lisp/dired.el b/lisp/dired.el index 101ee78992d..c5174561faf 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2749,12 +2749,32 @@ non-empty directories is allowed." (save-excursion (forward-line 1) (point)))))) (dired-clean-up-after-deletion file)) -;; This is a separate function for the sake of dired-x.el. +(defvar dired-clean-up-buffers-too) + (defun dired-clean-up-after-deletion (fn) - ;; Clean up after a deleted file or directory FN. + "Clean up after a deleted file or directory FN. +Removes any expanded subdirectory of deleted directory. +If `dired-x' is loaded and `dired-clean-up-buffers-too' is non-nil, +also offers to kill buffers visiting deleted files and directories." (save-excursion (and (cdr dired-subdir-alist) (dired-goto-subdir fn) - (dired-kill-subdir)))) + (dired-kill-subdir))) + ;; Offer to kill buffer of deleted file FN. + (when (and (featurep 'dired-x) dired-clean-up-buffers-too) + (let ((buf (get-file-buffer fn))) + (and buf + (funcall #'y-or-n-p + (format "Kill buffer of %s, too? " + (file-name-nondirectory fn))) + (kill-buffer buf))) + (let ((buf-list (dired-buffers-for-dir (expand-file-name fn)))) + (and buf-list + (y-or-n-p (format "Kill dired buffer%s of %s, too? " + (dired-plural-s (length buf-list)) + (file-name-nondirectory fn))) + (dolist (buf buf-list) + (kill-buffer buf)))))) + ;; Confirmation