Function: dired-omit-expunge

dired-omit-expunge is an interactive and byte-compiled function defined in dired-x.el.gz.

Signature

(dired-omit-expunge &optional REGEXP)

Documentation

Erases all unmarked files matching REGEXP.

Does nothing if global variable dired-omit-mode(var)/dired-omit-mode(fun) is nil, or if called
  non-interactively and buffer is bigger than dired-omit-size-limit.
If REGEXP is nil or not specified, uses dired-omit-files, and also omits
  filenames ending in dired-omit-extensions.
If REGEXP is the empty string, this function is a no-op.

This functions works by temporarily binding dired-marker-char to dired-omit-marker-char and calling dired-do-kill-lines.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/dired-x.el.gz
(defun dired-omit-expunge (&optional regexp)
  "Erases all unmarked files matching REGEXP.
Does nothing if global variable `dired-omit-mode' is nil, or if called
  non-interactively and buffer is bigger than `dired-omit-size-limit'.
If REGEXP is nil or not specified, uses `dired-omit-files', and also omits
  filenames ending in `dired-omit-extensions'.
If REGEXP is the empty string, this function is a no-op.

This functions works by temporarily binding `dired-marker-char' to
`dired-omit-marker-char' and calling `dired-do-kill-lines'."
  (interactive "sOmit files (regexp): ")
  (if (and dired-omit-mode
           (or (called-interactively-p 'interactive)
               (not dired-omit-size-limit)
               (< (buffer-size) dired-omit-size-limit)
	       (progn
		 (when dired-omit-verbose
		   (message "Not omitting: directory larger than %d characters."
			    dired-omit-size-limit))
		 (setq dired-omit-mode nil)
		 nil)))
      (let ((omit-re (or regexp (dired-omit-regexp)))
            (old-modified-p (buffer-modified-p))
            count)
        (or (string= omit-re "")
            (let ((dired-marker-char dired-omit-marker-char))
              (when dired-omit-verbose (message "Omitting..."))
              (if (dired-mark-unmarked-files omit-re nil nil dired-omit-localp
                                             (dired-omit-case-fold-p (if (stringp dired-directory)
                                                                         dired-directory
                                                                       (car dired-directory))))
                  (progn
                    (setq count (dired-do-kill-lines
				 nil
				 (if dired-omit-verbose "Omitted %d line%s." "")))
                    (force-mode-line-update))
                (when dired-omit-verbose (message "(Nothing to omit)")))))
        ;; Try to preserve modified state of buffer.  So `%*' doesn't appear
        ;; in mode-line of omitted buffers.
        (set-buffer-modified-p (and old-modified-p
                                    (save-excursion
                                      (goto-char (point-min))
                                      (re-search-forward dired-re-mark nil t))))
        count)))