Function: vc-dir-hide-state

vc-dir-hide-state is an interactive and byte-compiled function defined in vc-dir.el.gz.

Signature

(vc-dir-hide-state &optional STATE)

Documentation

Hide items that are in STATE from display.

See vc-state for valid values of STATE.

If STATE is nil, hide both up-to-date and ignored items.

Interactively, if current-prefix-arg is non-nil, set STATE to state of item at point, if any.

Key Bindings

Aliases

vc-dir-hide-up-to-date

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-dir.el.gz
(defun vc-dir-hide-state (&optional state)
  "Hide items that are in STATE from display.
See `vc-state' for valid values of STATE.

If STATE is nil, hide both `up-to-date' and `ignored' items.

Interactively, if `current-prefix-arg' is non-nil, set STATE to
state of item at point, if any."
  (interactive (list
		(and current-prefix-arg
		     ;; Command is prefixed.  Infer STATE from point.
		     (let ((node (ewoc-locate vc-ewoc)))
		       (and node (vc-dir-fileinfo->state (ewoc-data node)))))))
  (if state
      (message "Hiding items in state \"%s\"" state)
    (message "Hiding up-to-date and ignored items"))
  (let ((crt (ewoc-nth vc-ewoc -1))
	(first (ewoc-nth vc-ewoc 0)))
    ;; Go over from the last item to the first and remove the
    ;; up-to-date files and directories with no child files.
    (while (not (eq crt first))
      (let* ((data (ewoc-data crt))
	     (dir (vc-dir-fileinfo->directory data))
	     (next (ewoc-next vc-ewoc crt))
	     (prev (ewoc-prev vc-ewoc crt))
	     ;; ewoc-delete does not work without this...
	     (inhibit-read-only t))
	(when (or
	       ;; Remove directories with no child files.
	       (and dir
		    (or
		     ;; Nothing follows this directory.
		     (not next)
		     ;; Next item is a directory.
		     (vc-dir-fileinfo->directory (ewoc-data next))))
	       ;; Remove files in specified STATE.  STATE can be a
	       ;; symbol, a user-name, or nil.
               (if state
                   (equal (vc-dir-fileinfo->state data) state)
                 (memq (vc-dir-fileinfo->state data) '(up-to-date ignored))))
	  (ewoc-delete vc-ewoc crt))
	(setq crt prev)))))