Commit 42924231 authored by Glenn Morris's avatar Glenn Morris
Browse files

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.
parent 56e96bed
2011-02-19 Glenn Morris <rgm@gnu.org>
* 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 <rgm@gnu.org>
......
......@@ -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
......
2011-02-19 Glenn Morris <rgm@gnu.org>
* 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.
......
......@@ -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.
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment