我可以从`* vc-dir *`缓冲区中删除文件吗?

时间:2015-04-07 22:28:28

标签: emacs version-control

我正在使用vc-dir,我有几十个"未注册"我想删除的文件。我搜索了菜单,互联网和键绑定,但我还没弄明白该怎么做。

这真的不可能吗?

1 个答案:

答案 0 :(得分:2)

看起来没有实现。试试这个。目录处理源自delete-directory的交互式表单。如果任何删除导致错误,我们会挽救,但我们仍会刷新*vc-dir*缓冲区,以便我们可以看到已经完成了什么。

(defun my-vc-dir-delete-marked-files ()
  "Delete all marked files in a `vc-dir' buffer."
  (interactive)
  (let ((files (vc-dir-marked-files)))
    (if (not files)
        (message "No marked files.")
      (when (yes-or-no-p (format "%s %d marked file(s)? "
                                 (if delete-by-moving-to-trash "Trash" "Delete")
                                 (length files)))
        (unwind-protect
            (mapcar
             (lambda (path)
               (if (and (file-directory-p path)
                        (not (file-symlink-p path)))
                   (when (or (not (directory-files
                                   path nil directory-files-no-dot-files-regexp))
                             (y-or-n-p
                              (format "Directory `%s' is not empty, really %s? "
                                      path (if delete-by-moving-to-trash
                                               "trash" "delete"))))
                     (delete-directory path t t))
                 (delete-file path t)))
             files)
          (revert-buffer))))))

(eval-after-load 'vc-dir
  '(define-key vc-dir-mode-map (kbd "k") 'my-vc-dir-delete-marked-files))