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

Can I delete files from the `*vc-dir*` buffer?

我正在使用 vc-dir,我有几十个 "unregistered" 文件要删除。我搜索了菜单、互联网和按键绑定,但我还没有想出如何去做。

这真的不可能吗?

好像还没有实现。试试这个。目录处理源自 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))