comparison lisp/vc.el @ 94106:9294e3bd7d46

Rename vc-status to vc-dir and the vc-status var to vc-ewoc.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 16 Apr 2008 00:57:12 +0000
parents e8b7cae31fe3
children d4c7a819cf48
comparison
equal deleted inserted replaced
94105:4067304970d0 94106:9294e3bd7d46
180 ;; If the backend uses a process filter, hence it produces partial results, 180 ;; If the backend uses a process filter, hence it produces partial results,
181 ;; they can be passed back by doing: 181 ;; they can be passed back by doing:
182 ;; (funcall UPDATE-FUNCTION RESULT t) 182 ;; (funcall UPDATE-FUNCTION RESULT t)
183 ;; and then do a (funcall UPDATE-FUNCTION RESULT nil) 183 ;; and then do a (funcall UPDATE-FUNCTION RESULT nil)
184 ;; when all the results have been computed. 184 ;; when all the results have been computed.
185 ;; To provide more backend specific functionality for `vc-status' 185 ;; To provide more backend specific functionality for `vc-dir'
186 ;; the following functions might be needed: `status-extra-headers', 186 ;; the following functions might be needed: `status-extra-headers',
187 ;; `status-printer', `extra-status-menu' and `dir-status-files'. 187 ;; `status-printer', `extra-status-menu' and `dir-status-files'.
188 ;; This function is used by `vc-status', a replacement for 188 ;; This function is used by `vc-dir', a replacement for
189 ;; `vc-dired'. vc-status is still under development, and is NOT 189 ;; `vc-dired'. vc-dir is still under development, and is NOT
190 ;; feature complete. As such, the requirements for this function 190 ;; feature complete. As such, the requirements for this function
191 ;; might change. This is a replacement for `dir-state'. 191 ;; might change. This is a replacement for `dir-state'.
192 ;; 192 ;;
193 ;; - dir-status-files (dir files default-state update-function) 193 ;; - dir-status-files (dir files default-state update-function)
194 ;; 194 ;;
198 ;; files. If not provided, the default is to consider that the files 198 ;; files. If not provided, the default is to consider that the files
199 ;; are in DEFAULT-STATE. 199 ;; are in DEFAULT-STATE.
200 ;; 200 ;;
201 ;; - status-extra-headers (dir) 201 ;; - status-extra-headers (dir)
202 ;; 202 ;;
203 ;; Return a string that will be added to the *vc-status* buffer header. 203 ;; Return a string that will be added to the *vc-dir* buffer header.
204 ;; 204 ;;
205 ;; - status-printer (fileinfo) 205 ;; - status-printer (fileinfo)
206 ;; 206 ;;
207 ;; Pretty print the `vc-status-fileinfo' FILEINFO. 207 ;; Pretty print the `vc-dir-fileinfo' FILEINFO.
208 ;; If a backend needs to show more information than the default FILE 208 ;; If a backend needs to show more information than the default FILE
209 ;; and STATE in the vc-status listing, it can store that extra 209 ;; and STATE in the vc-dir listing, it can store that extra
210 ;; information in `vc-status-fileinfo->extra'. This function can be 210 ;; information in `vc-dir-fileinfo->extra'. This function can be
211 ;; used to display that extra information in the *vc-status* buffer. 211 ;; used to display that extra information in the *vc-dir* buffer.
212 ;; 212 ;;
213 ;; - status-fileinfo-extra (file) 213 ;; - status-fileinfo-extra (file)
214 ;; 214 ;;
215 ;; Compute `vc-status-fileinfo->extra' for FILE. 215 ;; Compute `vc-dir-fileinfo->extra' for FILE.
216 ;; 216 ;;
217 ;; * working-revision (file) 217 ;; * working-revision (file)
218 ;; 218 ;;
219 ;; Return the working revision of FILE. This is the revision fetched 219 ;; Return the working revision of FILE. This is the revision fetched
220 ;; by the last checkout or upate, not necessarily the same thing as the 220 ;; by the last checkout or upate, not necessarily the same thing as the
588 ;; is specific to a backend and which does not map to any of the VC 588 ;; is specific to a backend and which does not map to any of the VC
589 ;; generic concepts. 589 ;; generic concepts.
590 590
591 ;;; Todo: 591 ;;; Todo:
592 592
593 ;; - vc-status-kill-dir-status-process should not be specific to dir-status, 593 ;; - vc-dir-kill-dir-status-process should not be specific to dir-status,
594 ;; it should work for other async commands as well (pull/push/...). 594 ;; it should work for other async commands as well (pull/push/...).
595 ;; 595 ;;
596 ;; - vc-update/vc-merge should deal with VC systems that don't 596 ;; - vc-update/vc-merge should deal with VC systems that don't
597 ;; update/merge on a file basis, but on a whole repository basis. 597 ;; update/merge on a file basis, but on a whole repository basis.
598 ;; 598 ;;
631 ;; - add a mechanism for ignoring files. 631 ;; - add a mechanism for ignoring files.
632 ;; 632 ;;
633 ;; - vc-next-action should do something about 'missing files. Maybe 633 ;; - vc-next-action should do something about 'missing files. Maybe
634 ;; just warn, or offer to checkout. 634 ;; just warn, or offer to checkout.
635 ;; 635 ;;
636 ;; - display the directory names in vc-status, similar to what PCL-CVS 636 ;; - display the directory names in vc-dir, similar to what PCL-CVS
637 ;; does. 637 ;; does.
638 ;; 638 ;;
639 ;; - most vc-status backends need more work. They might need to 639 ;; - most vc-dir backends need more work. They might need to
640 ;; provide custom headers, use the `extra' field and deal with all 640 ;; provide custom headers, use the `extra' field and deal with all
641 ;; possible VC states. 641 ;; possible VC states.
642 ;; 642 ;;
643 ;; - add function that calls vc-status to `find-directory-functions'. 643 ;; - add function that calls vc-dir to `find-directory-functions'.
644 ;; 644 ;;
645 ;; - vc-status needs mouse bindings. 645 ;; - vc-dir needs mouse bindings.
646 ;; 646 ;;
647 ;; - vc-status needs more key bindings for VC actions. 647 ;; - vc-dir needs more key bindings for VC actions.
648 ;; 648 ;;
649 ;; - vc-status toolbar needs more icons. 649 ;; - vc-dir toolbar needs more icons.
650 ;; 650 ;;
651 ;; - vc-diff, vc-annotate, etc. need to deal better with unregistered 651 ;; - vc-diff, vc-annotate, etc. need to deal better with unregistered
652 ;; files. Now that unregistered and ignored files are shown in 652 ;; files. Now that unregistered and ignored files are shown in
653 ;; vc-dired/vc-status, it is possible that these commands are called 653 ;; vc-dired/vc-dir, it is possible that these commands are called
654 ;; for unregistered/ignored files. 654 ;; for unregistered/ignored files.
655 ;; 655 ;;
656 ;; - do not default to RCS anymore when the current directory is not 656 ;; - do not default to RCS anymore when the current directory is not
657 ;; controlled by any VCS and the user does C-x v v 657 ;; controlled by any VCS and the user does C-x v v
658 ;; 658 ;;
1435 (let ((firstbackend (vc-backend (car marked)))) 1435 (let ((firstbackend (vc-backend (car marked))))
1436 (dolist (f (cdr marked)) 1436 (dolist (f (cdr marked))
1437 (unless (eq (vc-backend f) firstbackend) 1437 (unless (eq (vc-backend f) firstbackend)
1438 (error "All members of a fileset must be under the same version-control system.")))) 1438 (error "All members of a fileset must be under the same version-control system."))))
1439 marked)) 1439 marked))
1440 ((eq major-mode 'vc-status-mode) 1440 ((eq major-mode 'vc-dir-mode)
1441 (or (vc-status-marked-files) 1441 (or (vc-dir-marked-files)
1442 (list (vc-status-current-file)))) 1442 (list (vc-dir-current-file))))
1443 ((vc-backend buffer-file-name) 1443 ((vc-backend buffer-file-name)
1444 (list buffer-file-name)) 1444 (list buffer-file-name))
1445 ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer) 1445 ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer)
1446 (with-current-buffer vc-parent-buffer 1446 (with-current-buffer vc-parent-buffer
1447 (or vc-dired-mode (eq major-mode 'vc-status-mode))))) 1447 (or vc-dired-mode (eq major-mode 'vc-dir-mode)))))
1448 (progn 1448 (progn
1449 (set-buffer vc-parent-buffer) 1449 (set-buffer vc-parent-buffer)
1450 (vc-deduce-fileset))) 1450 (vc-deduce-fileset)))
1451 ;; This is guarded by an enabling arg so users won't potentially 1451 ;; This is guarded by an enabling arg so users won't potentially
1452 ;; shoot themselves in the foot by modifying a fileset they can't 1452 ;; shoot themselves in the foot by modifying a fileset they can't
1470 (defun vc-ensure-vc-buffer () 1470 (defun vc-ensure-vc-buffer ()
1471 "Make sure that the current buffer visits a version-controlled file." 1471 "Make sure that the current buffer visits a version-controlled file."
1472 (cond 1472 (cond
1473 (vc-dired-mode 1473 (vc-dired-mode
1474 (set-buffer (find-file-noselect (dired-get-filename)))) 1474 (set-buffer (find-file-noselect (dired-get-filename))))
1475 ((eq major-mode 'vc-status-mode) 1475 ((eq major-mode 'vc-dir-mode)
1476 (set-buffer (find-file-noselect (vc-status-current-file)))) 1476 (set-buffer (find-file-noselect (vc-dir-current-file))))
1477 (t 1477 (t
1478 (while (and vc-parent-buffer 1478 (while (and vc-parent-buffer
1479 (buffer-live-p vc-parent-buffer) 1479 (buffer-live-p vc-parent-buffer)
1480 ;; Avoid infinite looping when vc-parent-buffer and 1480 ;; Avoid infinite looping when vc-parent-buffer and
1481 ;; current buffer are the same buffer. 1481 ;; current buffer are the same buffer.
1576 (error "Fileset has mixed checkout models"))) 1576 (error "Fileset has mixed checkout models")))
1577 ;; Check for buffers in the fileset not matching the on-disk contents. 1577 ;; Check for buffers in the fileset not matching the on-disk contents.
1578 (dolist (file files) 1578 (dolist (file files)
1579 (let ((visited (get-file-buffer file))) 1579 (let ((visited (get-file-buffer file)))
1580 (when visited 1580 (when visited
1581 (if (or vc-dired-mode (eq major-mode 'vc-status-mode)) 1581 (if (or vc-dired-mode (eq major-mode 'vc-dir-mode))
1582 (switch-to-buffer-other-window visited) 1582 (switch-to-buffer-other-window visited)
1583 (set-buffer visited)) 1583 (set-buffer visited))
1584 ;; Check relation of buffer and file, and make sure 1584 ;; Check relation of buffer and file, and make sure
1585 ;; user knows what he's doing. First, finding the file 1585 ;; user knows what he's doing. First, finding the file
1586 ;; will check whether the file on disk is newer. 1586 ;; will check whether the file on disk is newer.
1836 (let ((buffer (get-file-buffer file))) 1836 (let ((buffer (get-file-buffer file)))
1837 (when buffer 1837 (when buffer
1838 (with-current-buffer buffer 1838 (with-current-buffer buffer
1839 (vc-resynch-window file keep noquery))))) 1839 (vc-resynch-window file keep noquery)))))
1840 (vc-dired-resynch-file file) 1840 (vc-dired-resynch-file file)
1841 (when (memq 'vc-status-mark-buffer-changed after-save-hook) 1841 (when (memq 'vc-dir-mark-buffer-changed after-save-hook)
1842 (let ((buffer (get-file-buffer file))) 1842 (let ((buffer (get-file-buffer file)))
1843 (vc-status-mark-buffer-changed file)))) 1843 (vc-dir-mark-buffer-changed file))))
1844 1844
1845 1845
1846 (defun vc-start-entry (files rev comment initial-contents msg action &optional after-hook) 1846 (defun vc-start-entry (files rev comment initial-contents msg action &optional after-hook)
1847 "Accept a comment for an operation on FILES revision REV. 1847 "Accept a comment for an operation on FILES revision REV.
1848 If COMMENT is nil, pop up a VC-log buffer, emit MSG, and set the 1848 If COMMENT is nil, pop up a VC-log buffer, emit MSG, and set the
1853 entered COMMENT. If COMMENT is t, also do action immediately with an 1853 entered COMMENT. If COMMENT is t, also do action immediately with an
1854 empty comment. Remember the file's buffer in `vc-parent-buffer' 1854 empty comment. Remember the file's buffer in `vc-parent-buffer'
1855 \(current one if no file). AFTER-HOOK specifies the local value 1855 \(current one if no file). AFTER-HOOK specifies the local value
1856 for `vc-log-after-operation-hook'." 1856 for `vc-log-after-operation-hook'."
1857 (let ((parent 1857 (let ((parent
1858 (if (or (eq major-mode 'vc-dired-mode) (eq major-mode 'vc-status-mode)) 1858 (if (or (eq major-mode 'vc-dired-mode) (eq major-mode 'vc-dir-mode))
1859 ;; If we are called from VC dired, the parent buffer is 1859 ;; If we are called from VC dired, the parent buffer is
1860 ;; the current buffer. 1860 ;; the current buffer.
1861 (current-buffer) 1861 (current-buffer)
1862 (if (and files (equal (length files) 1)) 1862 (if (and files (equal (length files) 1))
1863 (get-file-buffer (car files)) 1863 (get-file-buffer (car files))
2000 'logentry-check) 2000 'logentry-check)
2001 (run-hooks 'vc-logentry-check-hook)) 2001 (run-hooks 'vc-logentry-check-hook))
2002 ;; Sync parent buffer in case the user modified it while editing the comment. 2002 ;; Sync parent buffer in case the user modified it while editing the comment.
2003 ;; But not if it is a vc-dired buffer. 2003 ;; But not if it is a vc-dired buffer.
2004 (with-current-buffer vc-parent-buffer 2004 (with-current-buffer vc-parent-buffer
2005 (or vc-dired-mode (eq major-mode 'vc-status-mode) (vc-buffer-sync))) 2005 (or vc-dired-mode (eq major-mode 'vc-dir-mode) (vc-buffer-sync)))
2006 (if (not vc-log-operation) 2006 (if (not vc-log-operation)
2007 (error "No log operation is pending")) 2007 (error "No log operation is pending"))
2008 ;; save the parameters held in buffer-local variables 2008 ;; save the parameters held in buffer-local variables
2009 (let ((log-operation vc-log-operation) 2009 (let ((log-operation vc-log-operation)
2010 (log-fileset vc-log-fileset) 2010 (log-fileset vc-log-fileset)
2032 ;; Now make sure we see the expanded headers 2032 ;; Now make sure we see the expanded headers
2033 (if log-fileset 2033 (if log-fileset
2034 (mapc 2034 (mapc
2035 (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t)) 2035 (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t))
2036 log-fileset)) 2036 log-fileset))
2037 (if (or vc-dired-mode (eq major-mode 'vc-status-mode)) 2037 (if (or vc-dired-mode (eq major-mode 'vc-dir-mode))
2038 (dired-move-to-filename)) 2038 (dired-move-to-filename))
2039 (run-hooks after-hook 'vc-finish-logentry-hook))) 2039 (run-hooks after-hook 'vc-finish-logentry-hook)))
2040 2040
2041 ;;; Additional entry points for examining version histories 2041 ;;; Additional entry points for examining version histories
2042 2042
2699 2699
2700 ;; VC status implementation 2700 ;; VC status implementation
2701 2701
2702 ;; Used to store information for the files displayed in the *VC status* buffer. 2702 ;; Used to store information for the files displayed in the *VC status* buffer.
2703 ;; Each item displayed corresponds to one of these defstructs. 2703 ;; Each item displayed corresponds to one of these defstructs.
2704 (defstruct (vc-status-fileinfo 2704 (defstruct (vc-dir-fileinfo
2705 (:copier nil) 2705 (:copier nil)
2706 (:type list) ;So we can use `member' on lists of FIs. 2706 (:type list) ;So we can use `member' on lists of FIs.
2707 (:constructor 2707 (:constructor
2708 ;; We could define it as an alias for `list'. 2708 ;; We could define it as an alias for `list'.
2709 vc-status-create-fileinfo (name state &optional extra marked)) 2709 vc-dir-create-fileinfo (name state &optional extra marked))
2710 (:conc-name vc-status-fileinfo->)) 2710 (:conc-name vc-dir-fileinfo->))
2711 name ;Keep it as first, for `member'. 2711 name ;Keep it as first, for `member'.
2712 state 2712 state
2713 ;; For storing backend specific information. 2713 ;; For storing backend specific information.
2714 extra 2714 extra
2715 marked 2715 marked
2716 ;; To keep track of not updated files during a global refresh 2716 ;; To keep track of not updated files during a global refresh
2717 needs-update 2717 needs-update
2718 ;; To distinguish files and directories. 2718 ;; To distinguish files and directories.
2719 directoryp) 2719 directoryp)
2720 2720
2721 (defvar vc-status nil) 2721 (defvar vc-ewoc nil)
2722 2722
2723 (defun vc-default-status-extra-headers (backend dir) 2723 (defun vc-default-status-extra-headers (backend dir)
2724 ;; Be loud by default to remind people to add coded to display 2724 ;; Be loud by default to remind people to add coded to display
2725 ;; backend specific headers. 2725 ;; backend specific headers.
2726 ;; XXX: change this to return nil before the release. 2726 ;; XXX: change this to return nil before the release.
2727 "Extra : Add backend specific headers here") 2727 "Extra : Add backend specific headers here")
2728 2728
2729 (defun vc-status-headers (backend dir) 2729 (defun vc-dir-headers (backend dir)
2730 "Display the headers in the *VC status* buffer. 2730 "Display the headers in the *VC status* buffer.
2731 It calls the `status-extra-headers' backend method to display backend 2731 It calls the `status-extra-headers' backend method to display backend
2732 specific headers." 2732 specific headers."
2733 (concat 2733 (concat
2734 (propertize "VC backend : " 'face 'font-lock-type-face) 2734 (propertize "VC backend : " 'face 'font-lock-type-face)
2738 (vc-call-backend backend 'status-extra-headers dir) 2738 (vc-call-backend backend 'status-extra-headers dir)
2739 "\n")) 2739 "\n"))
2740 2740
2741 (defun vc-default-status-printer (backend fileentry) 2741 (defun vc-default-status-printer (backend fileentry)
2742 "Pretty print FILEENTRY." 2742 "Pretty print FILEENTRY."
2743 (if (vc-status-fileinfo->directoryp fileentry) 2743 (if (vc-dir-fileinfo->directoryp fileentry)
2744 (insert " Directory: %s" (vc-status-fileinfo->name fileentry)) 2744 (insert " Directory: %s" (vc-dir-fileinfo->name fileentry))
2745 ;; If you change the layout here, change vc-status-move-to-goal-column. 2745 ;; If you change the layout here, change vc-dir-move-to-goal-column.
2746 (let ((state (vc-status-fileinfo->state fileentry))) 2746 (let ((state (vc-dir-fileinfo->state fileentry)))
2747 (insert 2747 (insert
2748 (propertize 2748 (propertize
2749 (format "%c" (if (vc-status-fileinfo->marked fileentry) ?* ? )) 2749 (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? ))
2750 'face 'font-lock-type-face) 2750 'face 'font-lock-type-face)
2751 " " 2751 " "
2752 (propertize 2752 (propertize
2753 (format "%-20s" state) 2753 (format "%-20s" state)
2754 'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face) 2754 'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face)
2755 ((memq state '(missing conflict)) 'font-lock-warning-face) 2755 ((memq state '(missing conflict)) 'font-lock-warning-face)
2756 (t 'font-lock-variable-name-face)) 2756 (t 'font-lock-variable-name-face))
2757 'mouse-face 'highlight) 2757 'mouse-face 'highlight)
2758 " " 2758 " "
2759 (propertize 2759 (propertize
2760 (format "%s" (vc-status-fileinfo->name fileentry)) 2760 (format "%s" (vc-dir-fileinfo->name fileentry))
2761 'face 'font-lock-function-name-face 2761 'face 'font-lock-function-name-face
2762 'mouse-face 'highlight))))) 2762 'mouse-face 'highlight)))))
2763 2763
2764 (defun vc-status-printer (fileentry) 2764 (defun vc-dir-printer (fileentry)
2765 (let ((backend (vc-responsible-backend default-directory))) 2765 (let ((backend (vc-responsible-backend default-directory)))
2766 (vc-call-backend backend 'status-printer fileentry))) 2766 (vc-call-backend backend 'status-printer fileentry)))
2767 2767
2768 (defun vc-status-move-to-goal-column () 2768 (defun vc-dir-move-to-goal-column ()
2769 ;; Used to keep the cursor on the file name column. 2769 ;; Used to keep the cursor on the file name column.
2770 (beginning-of-line) 2770 (beginning-of-line)
2771 ;; Must be in sync with vc-default-status-printer. 2771 ;; Must be in sync with vc-default-status-printer.
2772 (forward-char 25)) 2772 (forward-char 25))
2773 2773
2774 (defun vc-status-prepare-status-buffer (dir &optional create-new) 2774 (defun vc-dir-prepare-status-buffer (dir &optional create-new)
2775 "Find a *vc-status* buffer showing DIR, or create a new one." 2775 "Find a *vc-dir* buffer showing DIR, or create a new one."
2776 (setq dir (expand-file-name dir)) 2776 (setq dir (expand-file-name dir))
2777 (let* ((bname "*vc-status*") 2777 (let* ((bname "*vc-dir*")
2778 ;; Look for another *vc-status* buffer visiting the same directory. 2778 ;; Look for another *vc-dir* buffer visiting the same directory.
2779 (buf (save-excursion 2779 (buf (save-excursion
2780 (unless create-new 2780 (unless create-new
2781 (dolist (buffer (buffer-list)) 2781 (dolist (buffer (buffer-list))
2782 (set-buffer buffer) 2782 (set-buffer buffer)
2783 (when (and (eq major-mode 'vc-status-mode) 2783 (when (and (eq major-mode 'vc-dir-mode)
2784 (string= (expand-file-name default-directory) dir)) 2784 (string= (expand-file-name default-directory) dir))
2785 (return buffer))))))) 2785 (return buffer)))))))
2786 (if buf 2786 (or buf
2787 buf 2787 ;; Create a new *vc-dir* buffer.
2788 ;; Create a new *vc-status* buffer. 2788 (with-current-buffer (create-file-buffer bname)
2789 (with-current-buffer (create-file-buffer bname) 2789 (cd dir)
2790 (cd dir) 2790 (vc-setup-buffer (current-buffer))
2791 (vc-setup-buffer (current-buffer)) 2791 ;; Reset the vc-parent-buffer-name so that it does not appear
2792 ;; Reset the vc-parent-buffer-name so that it does not appear 2792 ;; in the mode-line.
2793 ;; in the mode-line. 2793 (setq vc-parent-buffer-name nil)
2794 (setq vc-parent-buffer-name nil) 2794 (current-buffer)))))
2795 (current-buffer)))))
2796 2795
2797 ;;;###autoload 2796 ;;;###autoload
2798 (defun vc-status (dir) 2797 (defun vc-dir (dir)
2799 "Show the VC status for DIR." 2798 "Show the VC status for DIR."
2800 (interactive "DVC status for directory: ") 2799 (interactive "DVC status for directory: ")
2801 (switch-to-buffer (vc-status-prepare-status-buffer dir)) 2800 (switch-to-buffer (vc-dir-prepare-status-buffer dir))
2802 (if (eq major-mode 'vc-status-mode) 2801 (if (eq major-mode 'vc-dir-mode)
2803 (vc-status-refresh) 2802 (vc-dir-refresh)
2804 (vc-status-mode))) 2803 (vc-dir-mode)))
2805 2804
2806 (defvar vc-status-menu-map 2805 (defvar vc-dir-menu-map
2807 (let ((map (make-sparse-keymap "VC-status"))) 2806 (let ((map (make-sparse-keymap "VC-dir")))
2808 (define-key map [quit] 2807 (define-key map [quit]
2809 '(menu-item "Quit" bury-buffer 2808 '(menu-item "Quit" bury-buffer
2810 :help "Quit")) 2809 :help "Quit"))
2811 (define-key map [kill] 2810 (define-key map [kill]
2812 '(menu-item "Kill Update Command" vc-status-kill-dir-status-process 2811 '(menu-item "Kill Update Command" vc-dir-kill-dir-status-process
2813 :enable (vc-status-busy) 2812 :enable (vc-dir-busy)
2814 :help "Kill the command that updates VC status buffer")) 2813 :help "Kill the command that updates VC status buffer"))
2815 (define-key map [refresh] 2814 (define-key map [refresh]
2816 '(menu-item "Refresh" vc-status-refresh 2815 '(menu-item "Refresh" vc-dir-refresh
2817 :enable (not (vc-status-busy)) 2816 :enable (not (vc-dir-busy))
2818 :help "Refresh the contents of the VC status buffer")) 2817 :help "Refresh the contents of the VC status buffer"))
2819 (define-key map [remup] 2818 (define-key map [remup]
2820 '(menu-item "Hide up-to-date" vc-status-hide-up-to-date 2819 '(menu-item "Hide up-to-date" vc-dir-hide-up-to-date
2821 :help "Hide up-to-date items from display")) 2820 :help "Hide up-to-date items from display"))
2822 ;; Movement. 2821 ;; Movement.
2823 (define-key map [sepmv] '("--")) 2822 (define-key map [sepmv] '("--"))
2824 (define-key map [next-line] 2823 (define-key map [next-line]
2825 '(menu-item "Next line" vc-status-next-line 2824 '(menu-item "Next line" vc-dir-next-line
2826 :help "Go to the next line" :keys "n")) 2825 :help "Go to the next line" :keys "n"))
2827 (define-key map [previous-line] 2826 (define-key map [previous-line]
2828 '(menu-item "Previous line" vc-status-previous-line 2827 '(menu-item "Previous line" vc-dir-previous-line
2829 :help "Go to the previous line")) 2828 :help "Go to the previous line"))
2830 ;; Marking. 2829 ;; Marking.
2831 (define-key map [sepmrk] '("--")) 2830 (define-key map [sepmrk] '("--"))
2832 (define-key map [unmark-all] 2831 (define-key map [unmark-all]
2833 '(menu-item "Unmark All" vc-status-unmark-all-files 2832 '(menu-item "Unmark All" vc-dir-unmark-all-files
2834 :help "Unmark all files that are in the same state as the current file\ 2833 :help "Unmark all files that are in the same state as the current file\
2835 \nWith prefix argument unmark all files")) 2834 \nWith prefix argument unmark all files"))
2836 (define-key map [unmark-previous] 2835 (define-key map [unmark-previous]
2837 '(menu-item "Unmark previous " vc-status-unmark-file-up 2836 '(menu-item "Unmark previous " vc-dir-unmark-file-up
2838 :help "Move to the previous line and unmark the file")) 2837 :help "Move to the previous line and unmark the file"))
2839 2838
2840 (define-key map [mark-all] 2839 (define-key map [mark-all]
2841 '(menu-item "Mark All" vc-status-mark-all-files 2840 '(menu-item "Mark All" vc-dir-mark-all-files
2842 :help "Mark all files that are in the same state as the current file\ 2841 :help "Mark all files that are in the same state as the current file\
2843 \nWith prefix argument mark all files")) 2842 \nWith prefix argument mark all files"))
2844 (define-key map [unmark] 2843 (define-key map [unmark]
2845 '(menu-item "Unmark" vc-status-unmark 2844 '(menu-item "Unmark" vc-dir-unmark
2846 :help "Unmark the current file or all files in the region")) 2845 :help "Unmark the current file or all files in the region"))
2847 2846
2848 (define-key map [mark] 2847 (define-key map [mark]
2849 '(menu-item "Mark" vc-status-mark 2848 '(menu-item "Mark" vc-dir-mark
2850 :help "Mark the current file or all files in the region")) 2849 :help "Mark the current file or all files in the region"))
2851 2850
2852 (define-key map [sepopn] '("--")) 2851 (define-key map [sepopn] '("--"))
2853 (define-key map [open-other] 2852 (define-key map [open-other]
2854 '(menu-item "Open in other window" vc-status-find-file-other-window 2853 '(menu-item "Open in other window" vc-dir-find-file-other-window
2855 :help "Find the file on the current line, in another window")) 2854 :help "Find the file on the current line, in another window"))
2856 (define-key map [open] 2855 (define-key map [open]
2857 '(menu-item "Open file" vc-status-find-file 2856 '(menu-item "Open file" vc-dir-find-file
2858 :help "Find the file on the current line")) 2857 :help "Find the file on the current line"))
2859 ;; VC info details 2858 ;; VC info details
2860 (define-key map [sepvcdet] '("--")) 2859 (define-key map [sepvcdet] '("--"))
2861 ;; FIXME: This needs a key binding. And maybe a better name 2860 ;; FIXME: This needs a key binding. And maybe a better name
2862 ;; ("Insert" like PCL-CVS uses does not sound that great either)... 2861 ;; ("Insert" like PCL-CVS uses does not sound that great either)...
2863 (define-key map [ins] 2862 (define-key map [ins]
2864 '(menu-item "Show File" vc-status-show-fileentry 2863 '(menu-item "Show File" vc-dir-show-fileentry
2865 :help "Show a file in the VC status listing even though it might be up to date")) 2864 :help "Show a file in the VC status listing even though it might be up to date"))
2866 (define-key map [annotate] 2865 (define-key map [annotate]
2867 '(menu-item "Annotate" vc-annotate 2866 '(menu-item "Annotate" vc-annotate
2868 :help "Display the edit history of the current file using colors")) 2867 :help "Display the edit history of the current file using colors"))
2869 (define-key map [diff] 2868 (define-key map [diff]
2884 ;; FIXME: This really really really needs a better name! 2883 ;; FIXME: This really really really needs a better name!
2885 ;; And a key binding too. 2884 ;; And a key binding too.
2886 '(menu-item "Check In/Out" vc-next-action 2885 '(menu-item "Check In/Out" vc-next-action
2887 :help "Do the next logical version control operation on the current fileset")) 2886 :help "Do the next logical version control operation on the current fileset"))
2888 (define-key map [register] 2887 (define-key map [register]
2889 '(menu-item "Register" vc-status-register 2888 '(menu-item "Register" vc-dir-register
2890 :help "Register file set into the version control system")) 2889 :help "Register file set into the version control system"))
2891 map) 2890 map)
2892 "Menu for VC status") 2891 "Menu for VC status")
2893 2892
2894 (defalias 'vc-status-menu-map vc-status-menu-map) 2893 (defalias 'vc-dir-menu-map vc-dir-menu-map)
2895 2894
2896 (defvar vc-status-mode-map 2895 (defvar vc-dir-mode-map
2897 (let ((map (make-keymap))) 2896 (let ((map (make-keymap)))
2898 (suppress-keymap map) 2897 (suppress-keymap map)
2899 ;; Marking. 2898 ;; Marking.
2900 (define-key map "m" 'vc-status-mark) 2899 (define-key map "m" 'vc-dir-mark)
2901 (define-key map "M" 'vc-status-mark-all-files) 2900 (define-key map "M" 'vc-dir-mark-all-files)
2902 (define-key map "u" 'vc-status-unmark) 2901 (define-key map "u" 'vc-dir-unmark)
2903 (define-key map "\C-?" 'vc-status-unmark-file-up) 2902 (define-key map "\C-?" 'vc-dir-unmark-file-up)
2904 (define-key map "\M-\C-?" 'vc-status-unmark-all-files) 2903 (define-key map "\M-\C-?" 'vc-dir-unmark-all-files)
2905 ;; Movement. 2904 ;; Movement.
2906 (define-key map "n" 'vc-status-next-line) 2905 (define-key map "n" 'vc-dir-next-line)
2907 (define-key map " " 'vc-status-next-line) 2906 (define-key map " " 'vc-dir-next-line)
2908 (define-key map "\t" 'vc-status-next-line) 2907 (define-key map "\t" 'vc-dir-next-line)
2909 (define-key map "p" 'vc-status-previous-line) 2908 (define-key map "p" 'vc-dir-previous-line)
2910 (define-key map [backtab] 'vc-status-previous-line) 2909 (define-key map [backtab] 'vc-dir-previous-line)
2911 ;; VC commands. 2910 ;; VC commands.
2912 (define-key map "=" 'vc-diff) ;; C-x v = 2911 (define-key map "=" 'vc-diff) ;; C-x v =
2913 (define-key map "a" 'vc-status-register) 2912 (define-key map "a" 'vc-dir-register)
2914 (define-key map "+" 'vc-update) ;; C-x v + 2913 (define-key map "+" 'vc-update) ;; C-x v +
2915 2914
2916 ;;XXX: Maybe use something else here, so we can use 'U' for unmark 2915 ;;XXX: Maybe use something else here, so we can use 'U' for unmark
2917 ;;all, similar to 'M'.. 2916 ;;all, similar to 'M'..
2918 (define-key map "U" 'vc-revert) ;; u is taken by unmark. 2917 (define-key map "U" 'vc-revert) ;; u is taken by unmark.
2919 2918
2920 ;; Can't be "g" (as in vc map), so "A" for "Annotate". 2919 ;; Can't be "g" (as in vc map), so "A" for "Annotate".
2921 (define-key map "A" 'vc-annotate) 2920 (define-key map "A" 'vc-annotate)
2922 (define-key map "l" 'vc-print-log) ;; C-x v l 2921 (define-key map "l" 'vc-print-log) ;; C-x v l
2923 ;; The remainder. 2922 ;; The remainder.
2924 (define-key map "f" 'vc-status-find-file) 2923 (define-key map "f" 'vc-dir-find-file)
2925 (define-key map "\C-m" 'vc-status-find-file) 2924 (define-key map "\C-m" 'vc-dir-find-file)
2926 (define-key map "o" 'vc-status-find-file-other-window) 2925 (define-key map "o" 'vc-dir-find-file-other-window)
2927 (define-key map "x" 'vc-status-hide-up-to-date) 2926 (define-key map "x" 'vc-dir-hide-up-to-date)
2928 (define-key map "q" 'bury-buffer) 2927 (define-key map "q" 'bury-buffer)
2929 (define-key map "g" 'vc-status-refresh) 2928 (define-key map "g" 'vc-dir-refresh)
2930 (define-key map "\C-c\C-c" 'vc-status-kill-dir-status-process) 2929 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process)
2931 ;; Not working yet. Functions like vc-status-find-file need to 2930 ;; Not working yet. Functions like vc-dir-find-file need to
2932 ;; find the file from the mouse position, not `point'. 2931 ;; find the file from the mouse position, not `point'.
2933 ;; (define-key map [(down-mouse-3)] 'vc-status-menu) 2932 ;; (define-key map [(down-mouse-3)] 'vc-dir-menu)
2934 2933
2935 ;; Hook up the menu. 2934 ;; Hook up the menu.
2936 (define-key map [menu-bar vc-status-mode] 2935 (define-key map [menu-bar vc-dir-mode]
2937 '(menu-item 2936 '(menu-item
2938 ;; This is used to that VC backends could add backend specific 2937 ;; This is used to that VC backends could add backend specific
2939 ;; menu items to vc-status-menu-map. 2938 ;; menu items to vc-dir-menu-map.
2940 "VC Status" vc-status-menu-map :filter vc-status-menu-map-filter)) 2939 "VC Status" vc-dir-menu-map :filter vc-dir-menu-map-filter))
2941 map) 2940 map)
2942 "Keymap for VC status") 2941 "Keymap for VC status")
2943 2942
2944 (defun vc-default-extra-status-menu (backend) 2943 (defun vc-default-extra-status-menu (backend)
2945 nil) 2944 nil)
2946 2945
2947 ;; This is used to that VC backends could add backend specific menu 2946 ;; This is used to that VC backends could add backend specific menu
2948 ;; items to vc-status-menu-map. 2947 ;; items to vc-dir-menu-map.
2949 (defun vc-status-menu-map-filter (orig-binding) 2948 (defun vc-dir-menu-map-filter (orig-binding)
2950 (when (and (symbolp orig-binding) (fboundp orig-binding)) 2949 (when (and (symbolp orig-binding) (fboundp orig-binding))
2951 (setq orig-binding (indirect-function orig-binding))) 2950 (setq orig-binding (indirect-function orig-binding)))
2952 (let ((ext-binding 2951 (let ((ext-binding
2953 (vc-call-backend (vc-responsible-backend default-directory) 2952 (vc-call-backend (vc-responsible-backend default-directory)
2954 'extra-status-menu))) 2953 'extra-status-menu)))
2956 orig-binding 2955 orig-binding
2957 (append orig-binding 2956 (append orig-binding
2958 '("----") 2957 '("----")
2959 ext-binding)))) 2958 ext-binding))))
2960 2959
2961 (defun vc-status-menu (e) 2960 (defun vc-dir-menu (e)
2962 "Popup the VC status menu." 2961 "Popup the VC status menu."
2963 (interactive "e") 2962 (interactive "e")
2964 (popup-menu vc-status-menu-map e)) 2963 (popup-menu vc-dir-menu-map e))
2965 2964
2966 (defvar vc-status-tool-bar-map 2965 (defvar vc-dir-tool-bar-map
2967 (let ((map (make-sparse-keymap))) 2966 (let ((map (make-sparse-keymap)))
2968 (tool-bar-local-item-from-menu 'vc-status-find-file "open" 2967 (tool-bar-local-item-from-menu 'vc-dir-find-file "open"
2969 map vc-status-mode-map) 2968 map vc-dir-mode-map)
2970 (tool-bar-local-item "bookmark_add" 2969 (tool-bar-local-item "bookmark_add"
2971 'vc-status-toggle-mark 'vc-status-toggle-mark map 2970 'vc-dir-toggle-mark 'vc-dir-toggle-mark map
2972 :help "Toggle mark on current item") 2971 :help "Toggle mark on current item")
2973 (tool-bar-local-item-from-menu 'vc-status-previous-line "left-arrow" 2972 (tool-bar-local-item-from-menu 'vc-dir-previous-line "left-arrow"
2974 map vc-status-mode-map 2973 map vc-dir-mode-map
2975 :rtl "right-arrow") 2974 :rtl "right-arrow")
2976 (tool-bar-local-item-from-menu 'vc-status-next-line "right-arrow" 2975 (tool-bar-local-item-from-menu 'vc-dir-next-line "right-arrow"
2977 map vc-status-mode-map 2976 map vc-dir-mode-map
2978 :rtl "left-arrow") 2977 :rtl "left-arrow")
2979 (tool-bar-local-item-from-menu 'vc-print-log "info" 2978 (tool-bar-local-item-from-menu 'vc-print-log "info"
2980 map vc-status-mode-map) 2979 map vc-dir-mode-map)
2981 (tool-bar-local-item-from-menu 'vc-status-refresh "refresh" 2980 (tool-bar-local-item-from-menu 'vc-dir-refresh "refresh"
2982 map vc-status-mode-map) 2981 map vc-dir-mode-map)
2983 (tool-bar-local-item-from-menu 'nonincremental-search-forward 2982 (tool-bar-local-item-from-menu 'nonincremental-search-forward
2984 "search" map) 2983 "search" map)
2985 (tool-bar-local-item-from-menu 'vc-status-kill-dir-status-process "cancel" 2984 (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel"
2986 map vc-status-mode-map) 2985 map vc-dir-mode-map)
2987 (tool-bar-local-item-from-menu 'bury-buffer "exit" 2986 (tool-bar-local-item-from-menu 'bury-buffer "exit"
2988 map vc-status-mode-map) 2987 map vc-dir-mode-map)
2989 map)) 2988 map))
2990 2989
2991 (defvar vc-status-process-buffer nil 2990 (defvar vc-dir-process-buffer nil
2992 "The buffer used for the asynchronous call that computes the VC status.") 2991 "The buffer used for the asynchronous call that computes the VC status.")
2993 2992
2994 (defun vc-status-mode () 2993 (defun vc-dir-mode ()
2995 "Major mode for VC status. 2994 "Major mode for VC status.
2996 \\{vc-status-mode-map}" 2995 \\{vc-dir-mode-map}"
2997 (setq mode-name "VC Status") 2996 (setq mode-name "VC Status")
2998 (setq major-mode 'vc-status-mode) 2997 (setq major-mode 'vc-dir-mode)
2999 (setq buffer-read-only t) 2998 (setq buffer-read-only t)
3000 (use-local-map vc-status-mode-map) 2999 (use-local-map vc-dir-mode-map)
3001 (set (make-local-variable 'tool-bar-map) vc-status-tool-bar-map) 3000 (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)
3002 (let ((buffer-read-only nil) 3001 (let ((buffer-read-only nil)
3003 (backend (vc-responsible-backend default-directory)) 3002 (backend (vc-responsible-backend default-directory))
3004 entries) 3003 entries)
3005 (erase-buffer) 3004 (erase-buffer)
3006 (set (make-local-variable 'vc-status-process-buffer) nil) 3005 (set (make-local-variable 'vc-dir-process-buffer) nil)
3007 (set (make-local-variable 'vc-status) 3006 (set (make-local-variable 'vc-ewoc)
3008 (ewoc-create #'vc-status-printer 3007 (ewoc-create #'vc-dir-printer
3009 (vc-status-headers backend default-directory))) 3008 (vc-dir-headers backend default-directory)))
3010 (add-hook 'after-save-hook 'vc-status-mark-buffer-changed) 3009 (add-hook 'after-save-hook 'vc-dir-mark-buffer-changed)
3011 ;; Make sure that if the VC status buffer is killed, the update 3010 ;; Make sure that if the VC status buffer is killed, the update
3012 ;; process running in the background is also killed. 3011 ;; process running in the background is also killed.
3013 (add-hook 'kill-buffer-query-functions 'vc-status-kill-query nil t) 3012 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t)
3014 (vc-status-refresh))) 3013 (vc-dir-refresh)))
3015 3014
3016 (put 'vc-status-mode 'mode-class 'special) 3015 (put 'vc-dir-mode 'mode-class 'special)
3017 3016
3018 (defun vc-status-update (entries buffer &optional noinsert) 3017 (defun vc-dir-update (entries buffer &optional noinsert)
3019 "Update BUFFER's ewoc from the list of ENTRIES. 3018 "Update BUFFER's ewoc from the list of ENTRIES.
3020 If NOINSERT, ignore elements on ENTRIES which are not in the ewoc." 3019 If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
3021 ;; Add ENTRIES to the vc-status buffer BUFFER. 3020 ;; Add ENTRIES to the vc-dir buffer BUFFER.
3022 (with-current-buffer buffer 3021 (with-current-buffer buffer
3023 ;; Insert the entries sorted by name into the ewoc. 3022 ;; Insert the entries sorted by name into the ewoc.
3024 ;; We assume the ewoc is sorted too, which should be the 3023 ;; We assume the ewoc is sorted too, which should be the
3025 ;; case if we always add entries with vc-status-update. 3024 ;; case if we always add entries with vc-dir-update.
3026 (setq entries 3025 (setq entries
3027 ;; Sort: first files and then subdirectories. 3026 ;; Sort: first files and then subdirectories.
3028 ;; XXX: this is VERY inefficient, it computes the directory 3027 ;; XXX: this is VERY inefficient, it computes the directory
3029 ;; names too many times 3028 ;; names too many times
3030 (sort entries 3029 (sort entries
3034 (cond 3033 (cond
3035 ((string< dir1 dir2) t) 3034 ((string< dir1 dir2) t)
3036 ((not (string= dir1 dir2)) nil) 3035 ((not (string= dir1 dir2)) nil)
3037 ((string< (car entry1) (car entry2)))))))) 3036 ((string< (car entry1) (car entry2))))))))
3038 (let ((entry (car entries)) 3037 (let ((entry (car entries))
3039 (node (ewoc-nth vc-status 0))) 3038 (node (ewoc-nth vc-ewoc 0)))
3040 (while (and entry node) 3039 (while (and entry node)
3041 (let ((entryfile (car entry)) 3040 (let ((entryfile (car entry))
3042 (nodefile (vc-status-fileinfo->name (ewoc-data node)))) 3041 (nodefile (vc-dir-fileinfo->name (ewoc-data node))))
3043 (cond 3042 (cond
3044 ((string-lessp nodefile entryfile) 3043 ((string-lessp nodefile entryfile)
3045 (setq node (ewoc-next vc-status node))) 3044 (setq node (ewoc-next vc-ewoc node)))
3046 ((string-lessp entryfile nodefile) 3045 ((string-lessp entryfile nodefile)
3047 (unless noinsert 3046 (unless noinsert
3048 (ewoc-enter-before vc-status node 3047 (ewoc-enter-before vc-ewoc node
3049 (apply 'vc-status-create-fileinfo entry))) 3048 (apply 'vc-dir-create-fileinfo entry)))
3050 (setq entries (cdr entries) entry (car entries))) 3049 (setq entries (cdr entries) entry (car entries)))
3051 (t 3050 (t
3052 (setf (vc-status-fileinfo->state (ewoc-data node)) (nth 1 entry)) 3051 (setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry))
3053 (setf (vc-status-fileinfo->extra (ewoc-data node)) (nth 2 entry)) 3052 (setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry))
3054 (setf (vc-status-fileinfo->needs-update (ewoc-data node)) nil) 3053 (setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil)
3055 (ewoc-invalidate vc-status node) 3054 (ewoc-invalidate vc-ewoc node)
3056 (setq entries (cdr entries) entry (car entries)) 3055 (setq entries (cdr entries) entry (car entries))
3057 (setq node (ewoc-next vc-status node)))))) 3056 (setq node (ewoc-next vc-ewoc node))))))
3058 (unless (or node noinsert) 3057 (unless (or node noinsert)
3059 ;; We're past the last node, all remaining entries go to the end. 3058 ;; We're past the last node, all remaining entries go to the end.
3060 (while entries 3059 (while entries
3061 (ewoc-enter-last vc-status 3060 (ewoc-enter-last vc-ewoc
3062 (apply 'vc-status-create-fileinfo (pop entries)))))))) 3061 (apply 'vc-dir-create-fileinfo (pop entries))))))))
3063 3062
3064 (defun vc-status-busy () 3063 (defun vc-dir-busy ()
3065 (and (buffer-live-p vc-status-process-buffer) 3064 (and (buffer-live-p vc-dir-process-buffer)
3066 (get-buffer-process vc-status-process-buffer))) 3065 (get-buffer-process vc-dir-process-buffer)))
3067 3066
3068 (defun vc-status-refresh-files (files default-state) 3067 (defun vc-dir-refresh-files (files default-state)
3069 "Refresh some files in the VC status buffer." 3068 "Refresh some files in the VC status buffer."
3070 (let ((backend (vc-responsible-backend default-directory)) 3069 (let ((backend (vc-responsible-backend default-directory))
3071 (status-buffer (current-buffer)) 3070 (status-buffer (current-buffer))
3072 (def-dir default-directory)) 3071 (def-dir default-directory))
3073 (vc-set-mode-line-busy-indicator) 3072 (vc-set-mode-line-busy-indicator)
3074 ;; Call the `dir-status-file' backend function. 3073 ;; Call the `dir-status-file' backend function.
3075 ;; `dir-status-file' is supposed to be asynchronous. 3074 ;; `dir-status-file' is supposed to be asynchronous.
3076 ;; It should compute the results, and then call the function 3075 ;; It should compute the results, and then call the function
3077 ;; passed as an argument in order to update the vc-status buffer 3076 ;; passed as an argument in order to update the vc-dir buffer
3078 ;; with the results. 3077 ;; with the results.
3079 (unless (buffer-live-p vc-status-process-buffer) 3078 (unless (buffer-live-p vc-dir-process-buffer)
3080 (setq vc-status-process-buffer 3079 (setq vc-dir-process-buffer
3081 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) 3080 (generate-new-buffer (format " *VC-%s* tmp status" backend))))
3082 (lexical-let ((buffer (current-buffer))) 3081 (lexical-let ((buffer (current-buffer)))
3083 (with-current-buffer vc-status-process-buffer 3082 (with-current-buffer vc-dir-process-buffer
3084 (cd def-dir) 3083 (cd def-dir)
3085 (erase-buffer) 3084 (erase-buffer)
3086 (vc-call-backend 3085 (vc-call-backend
3087 backend 'dir-status-files def-dir files default-state 3086 backend 'dir-status-files def-dir files default-state
3088 (lambda (entries &optional more-to-come) 3087 (lambda (entries &optional more-to-come)
3089 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. 3088 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
3090 ;; If MORE-TO-COME is true, then more updates will come from 3089 ;; If MORE-TO-COME is true, then more updates will come from
3091 ;; the asynchronous process. 3090 ;; the asynchronous process.
3092 (with-current-buffer buffer 3091 (with-current-buffer buffer
3093 (vc-status-update entries buffer) 3092 (vc-dir-update entries buffer)
3094 (unless more-to-come 3093 (unless more-to-come
3095 (setq mode-line-process nil) 3094 (setq mode-line-process nil)
3096 ;; Remove the ones that haven't been updated at all 3095 ;; Remove the ones that haven't been updated at all.
3097 (ewoc-filter vc-status (lambda (info) (not (vc-status-fileinfo->needs-update info)))))))))))) 3096 ;; Those not-updated are those whose state is nil because the
3098 3097 ;; file/dir doesn't exist and isn't versioned.
3099 (defun vc-status-refresh () 3098 (ewoc-filter vc-ewoc
3099 (lambda (info)
3100 (not (vc-dir-fileinfo->needs-update info))))))))))))
3101
3102 (defun vc-dir-refresh ()
3100 "Refresh the contents of the VC status buffer. 3103 "Refresh the contents of the VC status buffer.
3101 Throw an error if another update process is in progress." 3104 Throw an error if another update process is in progress."
3102 (interactive) 3105 (interactive)
3103 (if (vc-status-busy) 3106 (if (vc-dir-busy)
3104 (error "Another update process is in progress, cannot run two at a time") 3107 (error "Another update process is in progress, cannot run two at a time")
3105 (let ((backend (vc-responsible-backend default-directory)) 3108 (let ((backend (vc-responsible-backend default-directory))
3106 (status-buffer (current-buffer)) 3109 (status-buffer (current-buffer))
3107 (def-dir default-directory)) 3110 (def-dir default-directory))
3108 (vc-set-mode-line-busy-indicator) 3111 (vc-set-mode-line-busy-indicator)
3109 ;; Call the `dir-status' backend function. 3112 ;; Call the `dir-status' backend function.
3110 ;; `dir-status' is supposed to be asynchronous. 3113 ;; `dir-status' is supposed to be asynchronous.
3111 ;; It should compute the results, and then call the function 3114 ;; It should compute the results, and then call the function
3112 ;; passed as an argument in order to update the vc-status buffer 3115 ;; passed as an argument in order to update the vc-dir buffer
3113 ;; with the results. 3116 ;; with the results.
3114 3117
3115 ;; Create a buffer that can be used by `dir-status' and call 3118 ;; Create a buffer that can be used by `dir-status' and call
3116 ;; `dir-status' with this buffer as the current buffer. Use 3119 ;; `dir-status' with this buffer as the current buffer. Use
3117 ;; `vc-status-process-buffer' to remember this buffer, so that 3120 ;; `vc-dir-process-buffer' to remember this buffer, so that
3118 ;; it can be used later to kill the update process in case it 3121 ;; it can be used later to kill the update process in case it
3119 ;; takes too long. 3122 ;; takes too long.
3120 (unless (buffer-live-p vc-status-process-buffer) 3123 (unless (buffer-live-p vc-dir-process-buffer)
3121 (setq vc-status-process-buffer 3124 (setq vc-dir-process-buffer
3122 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) 3125 (generate-new-buffer (format " *VC-%s* tmp status" backend))))
3123 ;; set the needs-update flag on all entries 3126 ;; set the needs-update flag on all entries
3124 (ewoc-map (lambda (info) (setf (vc-status-fileinfo->needs-update info) t) nil) 3127 (ewoc-map (lambda (info) (setf (vc-dir-fileinfo->needs-update info) t) nil)
3125 vc-status) 3128 vc-ewoc)
3126 (lexical-let ((buffer (current-buffer))) 3129 (lexical-let ((buffer (current-buffer)))
3127 (with-current-buffer vc-status-process-buffer 3130 (with-current-buffer vc-dir-process-buffer
3128 (cd def-dir) 3131 (cd def-dir)
3129 (erase-buffer) 3132 (erase-buffer)
3130 (vc-call-backend 3133 (vc-call-backend
3131 backend 'dir-status def-dir 3134 backend 'dir-status def-dir
3132 (lambda (entries &optional more-to-come) 3135 (lambda (entries &optional more-to-come)
3133 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. 3136 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
3134 ;; If MORE-TO-COME is true, then more updates will come from 3137 ;; If MORE-TO-COME is true, then more updates will come from
3135 ;; the asynchronous process. 3138 ;; the asynchronous process.
3136 (with-current-buffer buffer 3139 (with-current-buffer buffer
3137 (vc-status-update entries buffer) 3140 (vc-dir-update entries buffer)
3138 (unless more-to-come 3141 (unless more-to-come
3139 (let ((remaining 3142 (let ((remaining
3140 (ewoc-collect 3143 (ewoc-collect
3141 vc-status 'vc-status-fileinfo->needs-update))) 3144 vc-ewoc 'vc-dir-fileinfo->needs-update)))
3142 (if remaining 3145 (if remaining
3143 (vc-status-refresh-files 3146 (vc-dir-refresh-files
3144 (mapcar 'vc-status-fileinfo->name remaining) 3147 (mapcar 'vc-dir-fileinfo->name remaining)
3145 'up-to-date) 3148 'up-to-date)
3146 (setq mode-line-process nil)))))))))))) 3149 (setq mode-line-process nil))))))))))))
3147 3150
3148 (defun vc-status-kill-dir-status-process () 3151 (defun vc-dir-kill-dir-status-process ()
3149 "Kill the temporary buffer and associated process." 3152 "Kill the temporary buffer and associated process."
3150 (interactive) 3153 (interactive)
3151 (when (buffer-live-p vc-status-process-buffer) 3154 (when (buffer-live-p vc-dir-process-buffer)
3152 (let ((proc (get-buffer-process vc-status-process-buffer))) 3155 (let ((proc (get-buffer-process vc-dir-process-buffer)))
3153 (when proc (delete-process proc)) 3156 (when proc (delete-process proc))
3154 (setq vc-status-process-buffer nil) 3157 (setq vc-dir-process-buffer nil)
3155 (setq mode-line-process nil)))) 3158 (setq mode-line-process nil))))
3156 3159
3157 (defun vc-status-kill-query () 3160 (defun vc-dir-kill-query ()
3158 ;; Make sure that when the VC status buffer is killed the update 3161 ;; Make sure that when the VC status buffer is killed the update
3159 ;; process running in background is also killed. 3162 ;; process running in background is also killed.
3160 (when (vc-status-busy) 3163 (when (vc-dir-busy)
3161 (when (y-or-n-p "Status update process running, really kill status buffer?") 3164 (when (y-or-n-p "Status update process running, really kill status buffer?")
3162 (vc-status-kill-dir-status-process) 3165 (vc-dir-kill-dir-status-process)
3163 t))) 3166 t)))
3164 3167
3165 (defun vc-status-next-line (arg) 3168 (defun vc-dir-next-line (arg)
3166 "Go to the next line. 3169 "Go to the next line.
3167 If a prefix argument is given, move by that many lines." 3170 If a prefix argument is given, move by that many lines."
3168 (interactive "p") 3171 (interactive "p")
3169 (ewoc-goto-next vc-status arg) 3172 (ewoc-goto-next vc-ewoc arg)
3170 (vc-status-move-to-goal-column)) 3173 (vc-dir-move-to-goal-column))
3171 3174
3172 (defun vc-status-previous-line (arg) 3175 (defun vc-dir-previous-line (arg)
3173 "Go to the previous line. 3176 "Go to the previous line.
3174 If a prefix argument is given, move by that many lines." 3177 If a prefix argument is given, move by that many lines."
3175 (interactive "p") 3178 (interactive "p")
3176 (ewoc-goto-prev vc-status arg) 3179 (ewoc-goto-prev vc-ewoc arg)
3177 (vc-status-move-to-goal-column)) 3180 (vc-dir-move-to-goal-column))
3178 3181
3179 (defun vc-status-mark-unmark (mark-unmark-function) 3182 (defun vc-dir-mark-unmark (mark-unmark-function)
3180 (if (use-region-p) 3183 (if (use-region-p)
3181 (let ((firstl (line-number-at-pos (region-beginning))) 3184 (let ((firstl (line-number-at-pos (region-beginning)))
3182 (lastl (line-number-at-pos (region-end)))) 3185 (lastl (line-number-at-pos (region-end))))
3183 (save-excursion 3186 (save-excursion
3184 (goto-char (region-beginning)) 3187 (goto-char (region-beginning))
3185 (while (<= (line-number-at-pos) lastl) 3188 (while (<= (line-number-at-pos) lastl)
3186 (funcall mark-unmark-function)))) 3189 (funcall mark-unmark-function))))
3187 (funcall mark-unmark-function))) 3190 (funcall mark-unmark-function)))
3188 3191
3189 (defun vc-status-mark-file () 3192 (defun vc-dir-mark-file ()
3190 ;; Mark the current file and move to the next line. 3193 ;; Mark the current file and move to the next line.
3191 (let* ((crt (ewoc-locate vc-status)) 3194 (let* ((crt (ewoc-locate vc-ewoc))
3192 (file (ewoc-data crt))) 3195 (file (ewoc-data crt)))
3193 (setf (vc-status-fileinfo->marked file) t) 3196 (setf (vc-dir-fileinfo->marked file) t)
3194 (ewoc-invalidate vc-status crt) 3197 (ewoc-invalidate vc-ewoc crt)
3195 (vc-status-next-line 1))) 3198 (vc-dir-next-line 1)))
3196 3199
3197 (defun vc-status-mark () 3200 (defun vc-dir-mark ()
3198 "Mark the current file or all files in the region. 3201 "Mark the current file or all files in the region.
3199 If the region is active, mark all the files in the region. 3202 If the region is active, mark all the files in the region.
3200 Otherwise mark the file on the current line and move to the next 3203 Otherwise mark the file on the current line and move to the next
3201 line." 3204 line."
3202 (interactive) 3205 (interactive)
3203 (vc-status-mark-unmark 'vc-status-mark-file)) 3206 (vc-dir-mark-unmark 'vc-dir-mark-file))
3204 3207
3205 3208
3206 ;; XXX: Should this take the region into consideration? 3209 ;; XXX: Should this take the region into consideration?
3207 (defun vc-status-mark-all-files (arg) 3210 (defun vc-dir-mark-all-files (arg)
3208 "Mark all files with the same state as the current one. 3211 "Mark all files with the same state as the current one.
3209 With a prefix argument mark all files. 3212 With a prefix argument mark all files.
3210 3213
3211 The VC commands operate on files that are on the same state. 3214 The VC commands operate on files that are on the same state.
3212 This command is intended to make it easy to select all files that 3215 This command is intended to make it easy to select all files that
3213 share the same state." 3216 share the same state."
3214 (interactive "P") 3217 (interactive "P")
3215 (if arg 3218 (if arg
3216 (ewoc-map 3219 (ewoc-map
3217 (lambda (filearg) 3220 (lambda (filearg)
3218 (unless (vc-status-fileinfo->marked filearg) 3221 (unless (vc-dir-fileinfo->marked filearg)
3219 (setf (vc-status-fileinfo->marked filearg) t) 3222 (setf (vc-dir-fileinfo->marked filearg) t)
3220 t)) 3223 t))
3221 vc-status) 3224 vc-ewoc)
3222 (let* ((crt (ewoc-locate vc-status)) 3225 (let* ((crt (ewoc-locate vc-ewoc))
3223 (crt-state (vc-status-fileinfo->state (ewoc-data crt)))) 3226 (crt-state (vc-dir-fileinfo->state (ewoc-data crt))))
3224 (ewoc-map 3227 (ewoc-map
3225 (lambda (filearg) 3228 (lambda (filearg)
3226 (when (and (not (vc-status-fileinfo->marked filearg)) 3229 (when (and (not (vc-dir-fileinfo->marked filearg))
3227 (eq (vc-status-fileinfo->state filearg) crt-state)) 3230 (eq (vc-dir-fileinfo->state filearg) crt-state))
3228 (setf (vc-status-fileinfo->marked filearg) t) 3231 (setf (vc-dir-fileinfo->marked filearg) t)
3229 t)) 3232 t))
3230 vc-status)))) 3233 vc-ewoc))))
3231 3234
3232 (defun vc-status-unmark-file () 3235 (defun vc-dir-unmark-file ()
3233 ;; Unmark the current file and move to the next line. 3236 ;; Unmark the current file and move to the next line.
3234 (let* ((crt (ewoc-locate vc-status)) 3237 (let* ((crt (ewoc-locate vc-ewoc))
3235 (file (ewoc-data crt))) 3238 (file (ewoc-data crt)))
3236 (setf (vc-status-fileinfo->marked file) nil) 3239 (setf (vc-dir-fileinfo->marked file) nil)
3237 (ewoc-invalidate vc-status crt) 3240 (ewoc-invalidate vc-ewoc crt)
3238 (vc-status-next-line 1))) 3241 (vc-dir-next-line 1)))
3239 3242
3240 (defun vc-status-unmark () 3243 (defun vc-dir-unmark ()
3241 "Unmark the current file or all files in the region. 3244 "Unmark the current file or all files in the region.
3242 If the region is active, unmark all the files in the region. 3245 If the region is active, unmark all the files in the region.
3243 Otherwise mark the file on the current line and move to the next 3246 Otherwise mark the file on the current line and move to the next
3244 line." 3247 line."
3245 (interactive) 3248 (interactive)
3246 (vc-status-mark-unmark 'vc-status-unmark-file)) 3249 (vc-dir-mark-unmark 'vc-dir-unmark-file))
3247 3250
3248 (defun vc-status-unmark-file-up () 3251 (defun vc-dir-unmark-file-up ()
3249 "Move to the previous line and unmark the file." 3252 "Move to the previous line and unmark the file."
3250 (interactive) 3253 (interactive)
3251 ;; If we're on the first line, we won't move up, but we will still 3254 ;; If we're on the first line, we won't move up, but we will still
3252 ;; remove the mark. This seems a bit odd but it is what buffer-menu 3255 ;; remove the mark. This seems a bit odd but it is what buffer-menu
3253 ;; does. 3256 ;; does.
3254 (let* ((prev (ewoc-goto-prev vc-status 1)) 3257 (let* ((prev (ewoc-goto-prev vc-ewoc 1))
3255 (file (ewoc-data prev))) 3258 (file (ewoc-data prev)))
3256 (setf (vc-status-fileinfo->marked file) nil) 3259 (setf (vc-dir-fileinfo->marked file) nil)
3257 (ewoc-invalidate vc-status prev) 3260 (ewoc-invalidate vc-ewoc prev)
3258 (vc-status-move-to-goal-column))) 3261 (vc-dir-move-to-goal-column)))
3259 3262
3260 (defun vc-status-unmark-all-files (arg) 3263 (defun vc-dir-unmark-all-files (arg)
3261 "Unmark all files with the same state as the current one. 3264 "Unmark all files with the same state as the current one.
3262 With a prefix argument mark all files. 3265 With a prefix argument mark all files.
3263 3266
3264 The VC commands operate on files that are on the same state. 3267 The VC commands operate on files that are on the same state.
3265 This command is intended to make it easy to deselect all files 3268 This command is intended to make it easy to deselect all files
3266 that share the same state." 3269 that share the same state."
3267 (interactive "P") 3270 (interactive "P")
3268 (if arg 3271 (if arg
3269 (ewoc-map 3272 (ewoc-map
3270 (lambda (filearg) 3273 (lambda (filearg)
3271 (when (vc-status-fileinfo->marked filearg) 3274 (when (vc-dir-fileinfo->marked filearg)
3272 (setf (vc-status-fileinfo->marked filearg) nil) 3275 (setf (vc-dir-fileinfo->marked filearg) nil)
3273 t)) 3276 t))
3274 vc-status) 3277 vc-ewoc)
3275 (let* ((crt (ewoc-locate vc-status)) 3278 (let* ((crt (ewoc-locate vc-ewoc))
3276 (crt-state (vc-status-fileinfo->state (ewoc-data crt)))) 3279 (crt-state (vc-dir-fileinfo->state (ewoc-data crt))))
3277 (ewoc-map 3280 (ewoc-map
3278 (lambda (filearg) 3281 (lambda (filearg)
3279 (when (and (vc-status-fileinfo->marked filearg) 3282 (when (and (vc-dir-fileinfo->marked filearg)
3280 (eq (vc-status-fileinfo->state filearg) crt-state)) 3283 (eq (vc-dir-fileinfo->state filearg) crt-state))
3281 (setf (vc-status-fileinfo->marked filearg) nil) 3284 (setf (vc-dir-fileinfo->marked filearg) nil)
3282 t)) 3285 t))
3283 vc-status)))) 3286 vc-ewoc))))
3284 3287
3285 (defun vc-status-toggle-mark-file () 3288 (defun vc-dir-toggle-mark-file ()
3286 (let* ((crt (ewoc-locate vc-status)) 3289 (let* ((crt (ewoc-locate vc-ewoc))
3287 (file (ewoc-data crt))) 3290 (file (ewoc-data crt)))
3288 (if (vc-status-fileinfo->marked file) 3291 (if (vc-dir-fileinfo->marked file)
3289 (vc-status-unmark-file) 3292 (vc-dir-unmark-file)
3290 (vc-status-mark-file)))) 3293 (vc-dir-mark-file))))
3291 3294
3292 (defun vc-status-toggle-mark () 3295 (defun vc-dir-toggle-mark ()
3293 (interactive) 3296 (interactive)
3294 (vc-status-mark-unmark 'vc-status-toggle-mark-file)) 3297 (vc-dir-mark-unmark 'vc-dir-toggle-mark-file))
3295 3298
3296 (defun vc-status-register () 3299 (defun vc-dir-register ()
3297 "Register the marked files, or the current file if no marks." 3300 "Register the marked files, or the current file if no marks."
3298 (interactive) 3301 (interactive)
3299 ;; FIXME: Just pass the fileset to vc-register. 3302 ;; FIXME: Just pass the fileset to vc-register.
3300 (mapc 'vc-register (or (vc-status-marked-files) 3303 (mapc 'vc-register (or (vc-dir-marked-files)
3301 (list (vc-status-current-file))))) 3304 (list (vc-dir-current-file)))))
3302 3305
3303 (defun vc-status-show-fileentry (file) 3306 (defun vc-dir-show-fileentry (file)
3304 "Insert an entry for a specific file into the current VC status listing. 3307 "Insert an entry for a specific file into the current VC status listing.
3305 This is typically used if the file is up-to-date (or has been added 3308 This is typically used if the file is up-to-date (or has been added
3306 outside of VC) and one wants to do some operation on it." 3309 outside of VC) and one wants to do some operation on it."
3307 (interactive "fShow file: ") 3310 (interactive "fShow file: ")
3308 (vc-status-update (list (list (file-relative-name file) (vc-state file))) (current-buffer))) 3311 (vc-dir-update (list (list (file-relative-name file) (vc-state file))) (current-buffer)))
3309 3312
3310 (defun vc-status-find-file () 3313 (defun vc-dir-find-file ()
3311 "Find the file on the current line." 3314 "Find the file on the current line."
3312 (interactive) 3315 (interactive)
3313 (find-file (vc-status-current-file))) 3316 (find-file (vc-dir-current-file)))
3314 3317
3315 (defun vc-status-find-file-other-window () 3318 (defun vc-dir-find-file-other-window ()
3316 "Find the file on the current line, in another window." 3319 "Find the file on the current line, in another window."
3317 (interactive) 3320 (interactive)
3318 (find-file-other-window (vc-status-current-file))) 3321 (find-file-other-window (vc-dir-current-file)))
3319 3322
3320 (defun vc-status-current-file () 3323 (defun vc-dir-current-file ()
3321 (let ((node (ewoc-locate vc-status))) 3324 (let ((node (ewoc-locate vc-ewoc)))
3322 (unless node 3325 (unless node
3323 (error "No file available.")) 3326 (error "No file available."))
3324 (expand-file-name (vc-status-fileinfo->name (ewoc-data node))))) 3327 (expand-file-name (vc-dir-fileinfo->name (ewoc-data node)))))
3325 3328
3326 (defun vc-status-marked-files () 3329 (defun vc-dir-marked-files ()
3327 "Return the list of marked files" 3330 "Return the list of marked files"
3328 (mapcar 3331 (mapcar
3329 (lambda (elem) (expand-file-name (vc-status-fileinfo->name elem))) 3332 (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem)))
3330 (ewoc-collect vc-status 'vc-status-fileinfo->marked))) 3333 (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked)))
3331 3334
3332 (defun vc-status-hide-up-to-date () 3335 (defun vc-dir-hide-up-to-date ()
3333 "Hide up-to-date items from display." 3336 "Hide up-to-date items from display."
3334 (interactive) 3337 (interactive)
3335 (ewoc-filter 3338 (ewoc-filter
3336 vc-status 3339 vc-ewoc
3337 (lambda (crt) (not (eq (vc-status-fileinfo->state crt) 'up-to-date))))) 3340 (lambda (crt) (not (eq (vc-dir-fileinfo->state crt) 'up-to-date)))))
3338 3341
3339 (defun vc-default-status-fileinfo-extra (backend file) 3342 (defun vc-default-status-fileinfo-extra (backend file)
3340 nil) 3343 nil)
3341 3344
3342 (defun vc-status-mark-buffer-changed (&optional fname) 3345 (defun vc-dir-mark-buffer-changed (&optional fname)
3343 (let* ((file (or fname (expand-file-name buffer-file-name))) 3346 (let* ((file (or fname (expand-file-name buffer-file-name)))
3344 (found-vc-status-buf nil)) 3347 (found-vc-dir-buf nil))
3345 (save-excursion 3348 (save-excursion
3346 (dolist (status-buf (buffer-list)) 3349 (dolist (status-buf (buffer-list))
3347 (set-buffer status-buf) 3350 (set-buffer status-buf)
3348 ;; look for a vc-status buffer that might show this file. 3351 ;; look for a vc-dir buffer that might show this file.
3349 (when (eq major-mode 'vc-status-mode) 3352 (when (eq major-mode 'vc-dir-mode)
3350 (setq found-vc-status-buf t) 3353 (setq found-vc-dir-buf t)
3351 (let ((ddir (expand-file-name default-directory))) 3354 (let ((ddir (expand-file-name default-directory)))
3352 ;; This test is cvs-string-prefix-p 3355 ;; This test is cvs-string-prefix-p
3353 (when (eq t (compare-strings file nil (length ddir) ddir nil nil)) 3356 (when (eq t (compare-strings file nil (length ddir) ddir nil nil))
3354 (let* 3357 (let*
3355 ((file-short (substring file (length ddir))) 3358 ((file-short (substring file (length ddir)))
3358 (extra 3361 (extra
3359 (and backend 3362 (and backend
3360 (vc-call-backend backend 'status-fileinfo-extra file))) 3363 (vc-call-backend backend 'status-fileinfo-extra file)))
3361 (entry 3364 (entry
3362 (list file-short (if state state 'unregistered) extra))) 3365 (list file-short (if state state 'unregistered) extra)))
3363 (vc-status-update (list entry) status-buf)))))) 3366 (vc-dir-update (list entry) status-buf))))))
3364 ;; We didn't find any vc-status buffers, remove the hook, it is 3367 ;; We didn't find any vc-dir buffers, remove the hook, it is
3365 ;; not needed. 3368 ;; not needed.
3366 (unless found-vc-status-buf (remove-hook 'after-save-hook 'vc-status-mark-buffer-changed))))) 3369 (unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-dir-mark-buffer-changed)))))
3367 3370
3368 ;; Named-configuration entry points 3371 ;; Named-configuration entry points
3369 3372
3370 (defun vc-snapshot-precondition (dir) 3373 (defun vc-snapshot-precondition (dir)
3371 "Scan the tree below DIR, looking for files not up-to-date. 3374 "Scan the tree below DIR, looking for files not up-to-date.