# HG changeset patch # User Dan Nicolaescu # Date 1206079371 0 # Node ID 3546cd0119d256a30a15cdd71470d9a640e6ca85 # Parent 01d3fd1a2cfe5d18bb17514618576cef923c1d46 (vc-status-mark-buffer-changed): Better deal with files in the 'added state. (vc-status-remove-up-to-date): New function. (vc-status-mode-map, vc-status-menu-map): Bind it. (vc-status-printer): Use a different face up-to-date files. (vc-resynch-buffer): Update the vc-status buffer if it exists. (Todo): Remove solved entries. diff -r 01d3fd1a2cfe -r 3546cd0119d2 lisp/ChangeLog --- a/lisp/ChangeLog Fri Mar 21 05:53:48 2008 +0000 +++ b/lisp/ChangeLog Fri Mar 21 06:02:51 2008 +0000 @@ -1,5 +1,13 @@ 2008-03-21 Dan Nicolaescu + * vc.el (vc-status-mark-buffer-changed): Better deal with files in + the 'added state. + (vc-status-remove-up-to-date): New function. + (vc-status-mode-map, vc-status-menu-map): Bind it. + (vc-status-printer): Use a different face up-to-date files. + (vc-resynch-buffer): Update the vc-status buffer if it exists. + (Todo): Remove solved entries. + * vc-hg.el (vc-hg-state): * vc-git.el (vc-git-state): * vc-cvs.el (vc-cvs-parse-status): diff -r 01d3fd1a2cfe -r 3546cd0119d2 lisp/vc.el --- a/lisp/vc.el Fri Mar 21 05:53:48 2008 +0000 +++ b/lisp/vc.el Fri Mar 21 06:02:51 2008 +0000 @@ -553,8 +553,6 @@ ;;; Todo: -;; - vc-state needs a new state for `added'. -;; ;; - vc-update/vc-merge should deal with VC systems that don't ;; update/merge on a file basis, but on a whole repository basis. ;; @@ -592,12 +590,6 @@ ;; them, or remove them from the VCS. C-x v v might also need ;; adjustments. ;; -;; - when changing a file whose directory is shown in the vc-status -;; buffer, it should be added there as "modified". (PCL-CVS does this). -;; -;; - Update the vc-status buffers after vc operations, implement the -;; equivalent of vc-dired-resynch-file. -;; ;; - vc-status needs a toolbar. ;; ;; - vc-status: refresh should not completely wipe out the current @@ -1791,10 +1783,15 @@ (if (string= buffer-file-name file) (vc-resynch-window file keep noquery) (let ((buffer (get-file-buffer file))) - (if buffer - (with-current-buffer buffer - (vc-resynch-window file keep noquery))))) - (vc-dired-resynch-file file)) + (when buffer + (with-current-buffer buffer + (vc-resynch-window file keep noquery))))) + (vc-dired-resynch-file file) + (when (memq 'vc-status-mark-buffer-changed after-save-hook) + (let ((buffer (get-file-buffer file))) + (with-current-buffer buffer + (when buffer (vc-status-mark-buffer-changed)))))) + (defun vc-start-entry (files rev comment initial-contents msg action &optional after-hook) "Accept a comment for an operation on FILES revision REV. @@ -2665,20 +2662,23 @@ (defun vc-status-printer (fileentry) "Pretty print FILEENTRY." ;; If you change the layout here, change vc-status-move-to-goal-column. - (insert - (propertize - (format "%c" (if (vc-status-fileinfo->marked fileentry) ?* ? )) - 'face 'font-lock-type-face) - " " - (propertize - (format "%-20s" (vc-status-fileinfo->state fileentry)) - 'face 'font-lock-variable-name-face - 'mouse-face 'highlight) - " " - (propertize - (format "%s" (vc-status-fileinfo->name fileentry)) - 'face 'font-lock-function-name-face - 'mouse-face 'highlight))) + (let ((state (vc-status-fileinfo->state fileentry))) + (insert + (propertize + (format "%c" (if (vc-status-fileinfo->marked fileentry) ?* ? )) + 'face 'font-lock-type-face) + " " + (propertize + (format "%-20s" state) + 'face (if (eq state 'up-to-date) + 'font-lock-builtin-face + 'font-lock-variable-name-face) + 'mouse-face 'highlight) + " " + (propertize + (format "%s" (vc-status-fileinfo->name fileentry)) + 'face 'font-lock-function-name-face + 'mouse-face 'highlight)))) (defun vc-status-move-to-goal-column () (beginning-of-line) @@ -2702,7 +2702,9 @@ (define-key map [refresh] '(menu-item "Refresh" vc-status-refresh :help "Refresh the contents of the VC status buffer")) - + (define-key map [remup] + '(menu-item "Remove up-to-date" vc-status-remove-up-to-date + :help "Remove up-to-date items from display")) ;; VC commands. (define-key map [separator-vc-commands] '("--")) (define-key map [annotate] @@ -2786,6 +2788,7 @@ ;; The remainder. (define-key map "f" 'vc-status-find-file) (define-key map "o" 'vc-status-find-file-other-window) + (define-key map "x" 'vc-status-remove-up-to-date) (define-key map "q" 'bury-buffer) (define-key map "g" 'vc-status-refresh) (define-key map "\C-c\C-c" 'vc-status-kill-dir-status-process) @@ -3118,9 +3121,16 @@ vc-status (lambda (crt) (vc-status-fileinfo->marked crt))))) +(defun vc-status-remove-up-to-date () + "Remove up-to-date items from display." + (interactive) + (ewoc-filter + vc-status + (lambda (crt) (not (eq (vc-status-fileinfo->state crt) 'up-to-date))))) + (defun vc-status-mark-buffer-changed () (let* ((file (expand-file-name buffer-file-name)) - (version (and (vc-backend file) (vc-working-revision file))) + (state (and (vc-backend file) (vc-state file))) (found-vc-status-buf nil)) (save-excursion (dolist (status-buf (buffer-list)) @@ -3128,21 +3138,11 @@ ;; look for a vc-status buffer that might show this file. (when (eq major-mode 'vc-status-mode) (setq found-vc-status-buf t) - (let ((def-dir (expand-file-name default-directory))) + (let ((ddir (expand-file-name default-directory))) ;; This test is cvs-string-prefix-p - (when (eq t (compare-strings file nil (length def-dir) def-dir nil nil)) - (let* ((file-short - (substring file (length def-dir))) - (entry - (cons - file-short - (if version - ;; This it not the correct test to check if - ;; the files is "added" for all backends. - ;; It does not work for git for example. - ;; vc-state needs a new state: `added'. - (if (string= "0" version) 'added 'modified) - 'unregistered)))) + (when (eq t (compare-strings file nil (length ddir) ddir nil nil)) + (let* ((file-short (substring file (length ddir))) + (entry (cons file-short (if state state 'unregistered)))) (vc-status-add-entry entry status-buf)))))) ;; We didn't find any vc-status buffers, remove the hook, it is ;; not needed.