Emacs: Delete Backup in Current Dir Recursively 🚀
here's a command to delete all emacs backup files~ in current dir and all subdirs.
this is good because it does not rely on bash or PowerShell, and can be called by Alt+x, no need to drop to shell.
(defun xah-list-emacs-backup () "List emacs backup files~ in current dir, recursively. In lisp code, return a list of file paths. Version: 2023-09-13" (interactive) (let ((xpaths (directory-files-recursively default-directory "~$")) (xbuf (generate-new-buffer "*emacs backup files*"))) (display-buffer xbuf) (mapc (lambda (x) (princ (format "%s\n" x) xbuf)) xpaths))) (defun xah-delete-emacs-backup () "Delete emacs backup files~ in current dir, recursively. Version: 2023-09-13" (interactive) (let ((xpaths (xah-list-emacs-backup))) (when (y-or-n-p (format "Delete in %s" default-directory)) (mapc 'delete-file xpaths)) xpaths))