如果你删除一个文件foo
,dired-x
你会被问到Kill buffer of foo, too?
。我怎样才能跳过这个问题并总是用 回答它yes
?
问问题
482 次
2 回答
9
您可以建议该dired-delete-entry
函数,以便在删除之前关闭任何文件缓冲区:
(defadvice dired-delete-entry (before force-clean-up-buffers (file) activate)
(kill-buffer (get-file-buffer file)))
Elisp 手册将建议描述为“比重新定义整个函数更干净”,如果函数的定义在未来发生变化,它不太可能中断。
于 2012-07-18T17:31:59.067 回答
6
只需在 dired-x.el 中重新定义 dired-clean-up-after-deletion。
;; redefine the definition in dired-x.el, so that we are not prompted
;; to remove buffers that were associated with deleted
;; files/directories
(eval-after-load "dired-x" '(defun dired-clean-up-after-deletion (fn)
"My. 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.
(if dired-clean-up-buffers-too
(progn
(let ((buf (get-file-buffer fn)))
(and buf
(save-excursion ; you never know where kill-buffer leaves you
(kill-buffer buf))))
(let ((buf-list (dired-buffers-for-dir (expand-file-name fn)))
(buf nil))
(and buf-list
(while buf-list
(save-excursion (kill-buffer (car buf-list)))
(setq buf-list (cdr buf-list)))))))
;; Anything else?
))
于 2012-07-19T19:27:44.527 回答