=== modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-08-11 04:46:38 +0000 +++ lisp/ChangeLog 2012-08-12 01:44:26 +0000 @@ -1,3 +1,11 @@ +2012-08-12 Jambunathan K + + * vc/vc-dir.el (vc-dir-hide-these-states): New custom variable. + (vc-dir-hide-some-states): New command. + (vc-dir-hide-up-to-date): Use `vc-dir-hide-some-states'. + (vc-dir-mode-map): Map "x" to `vc-dir-hide-some-states' instead of + `vc-dir-hide-up-to-date'. + 2012-08-11 Glenn Morris * emacs-lisp/copyright.el (copyright-update-directory): Logic fix. === 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-12 10:47:23 +0000 @@ -51,6 +51,25 @@ :type 'hook :group 'vc) +(defcustom vc-dir-hide-these-states '(up-to-date) + "States hidden by `vc-dir-hide-some-states'." + :type '(choice + (const :tag "None") + (set :tag "Choices" + (symbol :tag "VC State" added) + (symbol :tag "VC State" conflict) + (symbol :tag "VC State" edited) + (symbol :tag "VC State" ignored) + (symbol :tag "VC State" missing) + (symbol :tag "VC State" needs-merge) + (symbol :tag "VC State" needs-update) + (symbol :tag "VC State" removed) + (symbol :tag "VC State" unlocked-changes) + (symbol :tag "VC State" unregistered) + (symbol :tag "VC State" up-to-date))) + :group 'vc + :version "24.2") + ;; Used to store information for the files displayed in the directory buffer. ;; Each item displayed corresponds to one of these defstructs. (cl-defstruct (vc-dir-fileinfo @@ -271,7 +290,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-some-states) (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 +1125,43 @@ (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-some-states (&optional states) + "Hide items that are in STATES from display. +STATES is a list of vc states (see`vc-state'). + +If STATES is nil, use `vc-dir-hide-these-states' as default. + +In interactive mode, if prefix argument is non-nil or if +`vc-dir-hide-these-states' is nil, hide items that share the same +state as file at point." + (interactive + ;; Interactive use. + (list + (or (and (not current-prefix-arg) vc-dir-hide-these-states) + ;; Command is prefixed or `vc-dir-hide-these-states' is nil. + ;; State to hide, is the one at point. + (let ((node (ewoc-locate vc-ewoc))) + (unless node (error "No file available")) + (let* ((data (ewoc-data node)) + (state (vc-dir-fileinfo->state data))) + (unless state (error "No state at point")) + (list state)))))) + ;; Non-interactive use. + (unless (called-interactively-p 'any) + (setq states (or states vc-dir-hide-these-states))) + ;; Hide specified states. + (when states + (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 @@ -1129,9 +1171,14 @@ ;; 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)) + (member (vc-dir-fileinfo->state data) states)) (ewoc-delete vc-ewoc crt)) - (setq crt prev))))) + (setq crt prev)))))) + +(defun vc-dir-hide-up-to-date () + "Hide up-to-date items from display." + (interactive) + (vc-dir-hide-some-states '(up-to-date))) (defun vc-dir-kill-line () "Remove the current line from display."