Skip to content

Instantly share code, notes, and snippets.

@nfunato
Last active June 14, 2020 02:09
Show Gist options
  • Select an option

  • Save nfunato/1dcf6aba428e672f6137d153b751a46c to your computer and use it in GitHub Desktop.

Select an option

Save nfunato/1dcf6aba428e672f6137d153b751a46c to your computer and use it in GitHub Desktop.
;;;===================================================================
;;; override dired-flag-backup-files with
;;; dired-flag-backup-files-and-lisp-fasl-files
(defcustom dired-lisp-fasl-files-regexp
;; SBCL -- .fasl
;; CCL --
;; CLISP --
;; ECL -- .o (and perhaps others)
(concat (regexp-opt
'(".fasl" ".o"))
"\\'")
"Regular expression to match \"garbage\" files for `dired-flag-lisp-fasl-files'."
:type 'regexp
:group 'dired)
(defun dired-flag-lisp-fasl-files ()
"Flag for deletion all files that match `dired-flag-lisp-fasl-files'."
(interactive)
(dired-flag-files-regexp dired-lisp-fasl-files-regexp))
(defun dired-flag-backup-files-and-lisp-fasl-files (&optional unflag-p)
"Flag all backup files (names ending with `~') for deletion.
With prefix argument, FLAG ALSO LISP FASL FILES (NOT UNMARK OR UNFLAG THESE FILES)."
(interactive "P")
;; note: override dired-flag-backup-files, i.e. the original means calling
;; (dired-flag-backup-files unflag-p)
(prog1 (dired-flag-backup-files nil)
(when unflag-p ; note: in fact, unflag-p should be renamed as with-fasl-files-p
(dired-flag-lisp-fasl-files))))
(add-hook 'dired-load-hook
(lambda ()
(define-key dired-mode-map "~" 'dired-flag-backup-files-and-lisp-fasl-files)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment