=== modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-08-12 22:52:33 +0000 +++ lisp/ChangeLog 2012-08-13 17:26:55 +0000 @@ -1,3 +1,12 @@ +2012-08-13 Jambunathan K + + * vc/vc-dir.el (vc-dir-hide-up-to-date): Remove it. + (vc-dir-hide-state): New command. + (vc-dir-mode-map): Map key "x" to `vc-dir-hide-state' instead of + `vc-dir-hide-up-to-date'. + (vc-dir-menu-map): Use `vc-dir-hide-state' instead of + `vc-dir-hide-up-to-date' + 2012-08-12 Stefan Monnier * subr.el (internal--before-with-seleted-window) === modified file 'lisp/vc/vc-dir.el' --- lisp/vc/vc-dir.el 2012-07-11 23:13:41 +0000 +++ lisp/vc/vc-dir.el 2012-08-13 17:32:12 +0000 @@ -123,9 +123,9 @@ '(menu-item "Refresh" revert-buffer :enable (not (vc-dir-busy)) :help "Refresh the contents of the directory buffer")) - (define-key map [remup] - '(menu-item "Hide Up-to-date" vc-dir-hide-up-to-date - :help "Hide up-to-date items from display")) + (define-key map [hide] + '(menu-item "Hide current state" vc-dir-hide-state + :help "Hide items share current state")) ;; Movement. (define-key map [sepmv] '("--")) (define-key map [next-line] @@ -271,7 +271,7 @@ (define-key map [down-mouse-3] 'vc-dir-menu) (define-key map [mouse-2] 'vc-dir-toggle-mark) (define-key map [follow-link] 'mouse-face) - (define-key map "x" 'vc-dir-hide-up-to-date) + (define-key map "x" 'vc-dir-hide-state) (define-key map [?\C-k] 'vc-dir-kill-line) (define-key map "S" 'vc-dir-search) ;; FIXME: Maybe use A like dired? (define-key map "Q" 'vc-dir-query-replace-regexp) @@ -1106,20 +1106,30 @@ (interactive "fShow file: ") (vc-dir-update (list (list (file-relative-name file) (vc-state file))) (current-buffer))) -(defun vc-dir-hide-up-to-date () - "Hide up-to-date items from display." - (interactive) - (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)) +(defun vc-dir-hide-state (state) + "Hide items that are in STATE from display. +See `vc-state' for valid values of STATE. + +Interactively, set STATE to state of item at point." + (interactive (list + ;; Infer STATE from point. Complain otherwise. + (let ((node (ewoc-locate vc-ewoc))) + (unless node (error "No file available")) + (or (vc-dir-fileinfo->state (ewoc-data node)) + (error "No state at point"))))) + (when state + (message "Hiding items in state \"%s\"" state) + (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 @@ -1128,10 +1138,11 @@ (not next) ;; Next item is a directory. (vc-dir-fileinfo->directory (ewoc-data next)))) - ;; Remove files in the up-to-date state. - (eq (vc-dir-fileinfo->state data) 'up-to-date)) + ;; Remove files in specified STATE. STATE can be a + ;; symbol or a user-name. + (equal (vc-dir-fileinfo->state data) state)) (ewoc-delete vc-ewoc crt)) - (setq crt prev))))) + (setq crt prev)))))) (defun vc-dir-kill-line () "Remove the current line from display."