Mercurial > emacs
comparison lisp/vc-dispatcher.el @ 94611:78377ffa1363
Bug fix for vc-dispatcher split.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Sun, 04 May 2008 13:17:33 +0000 |
parents | 16008b90ad8c |
children | 5cfb1b43668c |
comparison
equal
deleted
inserted
replaced
94610:318ecca53bb5 | 94611:78377ffa1363 |
---|---|
538 (vc-resynch-window file keep noquery) | 538 (vc-resynch-window file keep noquery) |
539 (let ((buffer (get-file-buffer file))) | 539 (let ((buffer (get-file-buffer file))) |
540 (when buffer | 540 (when buffer |
541 (with-current-buffer buffer | 541 (with-current-buffer buffer |
542 (vc-resynch-window file keep noquery))))) | 542 (vc-resynch-window file keep noquery))))) |
543 ;; FIME: Call into vc.el | |
544 (vc-directory-resynch-file file) | 543 (vc-directory-resynch-file file) |
545 (when (memq 'vc-dir-mark-buffer-changed after-save-hook) | 544 (when (memq 'vc-dir-mark-buffer-changed after-save-hook) |
546 (let ((buffer (get-file-buffer file))) | 545 (let ((buffer (get-file-buffer file))) |
547 ;; FIME: Call into vc.el | |
548 (vc-dir-mark-buffer-changed file)))) | 546 (vc-dir-mark-buffer-changed file)))) |
549 | 547 |
550 ;; Command closures | 548 ;; Command closures |
551 | 549 |
552 (defun vc-start-logentry (files extra comment initial-contents msg action &optional after-hook) | 550 (defun vc-start-logentry (files extra comment initial-contents msg action &optional after-hook) |
886 ;; To keep track of not updated files during a global refresh | 884 ;; To keep track of not updated files during a global refresh |
887 needs-update | 885 needs-update |
888 ;; To distinguish files and directories. | 886 ;; To distinguish files and directories. |
889 directory) | 887 directory) |
890 | 888 |
889 ;; Used to describe a dispatcher client mode. | |
890 (defstruct (vc-client-object | |
891 (:copier nil) | |
892 (:constructor | |
893 vc-create-client-object (name | |
894 headers | |
895 file-to-info | |
896 file-to-state | |
897 file-to-extra | |
898 updater)) | |
899 (:conc-name vc-client-object->)) | |
900 name | |
901 headers | |
902 file-to-info | |
903 file-to-state | |
904 file-to-extra | |
905 updater) | |
906 | |
891 (defvar vc-ewoc nil) | 907 (defvar vc-ewoc nil) |
892 (defvar vc-dir-process-buffer nil | 908 (defvar vc-dir-process-buffer nil |
893 "The buffer used for the asynchronous call that computes the VC status.") | 909 "The buffer used for the asynchronous call that computes the VC status.") |
894 | 910 |
895 (defun vc-dir-move-to-goal-column () | 911 (defun vc-dir-move-to-goal-column () |
1025 (define-key map "n" 'vc-dir-next-line) | 1041 (define-key map "n" 'vc-dir-next-line) |
1026 (define-key map " " 'vc-dir-next-line) | 1042 (define-key map " " 'vc-dir-next-line) |
1027 (define-key map "\t" 'vc-dir-next-line) | 1043 (define-key map "\t" 'vc-dir-next-line) |
1028 (define-key map "p" 'vc-dir-previous-line) | 1044 (define-key map "p" 'vc-dir-previous-line) |
1029 (define-key map [backtab] 'vc-dir-previous-line) | 1045 (define-key map [backtab] 'vc-dir-previous-line) |
1030 ;; VC commands. | |
1031 ;; FIXME: These need to be in a client-local keymap | |
1032 (define-key map "=" 'vc-diff) ;; C-x v = | |
1033 (define-key map "a" 'vc-dir-register) | |
1034 (define-key map "+" 'vc-update) ;; C-x v + | |
1035 (define-key map "R" 'vc-revert) ;; u is taken by unmark. | |
1036 (define-key map "A" 'vc-annotate);; Can't be "g" (as in vc map) | |
1037 (define-key map "l" 'vc-print-log) ;; C-x v l | |
1038 ;; The remainder. | 1046 ;; The remainder. |
1039 (define-key map "f" 'vc-dir-find-file) | 1047 (define-key map "f" 'vc-dir-find-file) |
1040 (define-key map "\C-m" 'vc-dir-find-file) | 1048 (define-key map "\C-m" 'vc-dir-find-file) |
1041 (define-key map "o" 'vc-dir-find-file-other-window) | 1049 (define-key map "o" 'vc-dir-find-file-other-window) |
1042 (define-key map "x" 'vc-dir-hide-up-to-date) | |
1043 (define-key map "q" 'quit-window) | 1050 (define-key map "q" 'quit-window) |
1044 (define-key map "g" 'vc-dir-refresh) | 1051 (define-key map "g" 'vc-dir-refresh) |
1045 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) | 1052 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) |
1046 (define-key map [(down-mouse-3)] 'vc-dir-menu) | 1053 (define-key map [(down-mouse-3)] 'vc-dir-menu) |
1047 (define-key map [(mouse-2)] 'vc-dir-toggle-mark) | 1054 (define-key map [(mouse-2)] 'vc-dir-toggle-mark) |
1048 | 1055 |
1056 ;; FIXME: Calls back into vc.el | |
1049 ;; Hook up the menu. | 1057 ;; Hook up the menu. |
1050 (define-key map [menu-bar vc-dir-mode] | 1058 (define-key map [menu-bar vc-dir-mode] |
1051 '(menu-item | 1059 '(menu-item |
1052 ;; This is used so that client modes can add mode-specific | 1060 ;; This is used so that client modes can add mode-specific |
1053 ;; menu items to vc-dir-menu-map. | 1061 ;; menu items to vc-dir-menu-map. |
1491 (mapcar | 1499 (mapcar |
1492 (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) | 1500 (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) |
1493 (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) | 1501 (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) |
1494 | 1502 |
1495 (defun vc-dir-marked-only-files () | 1503 (defun vc-dir-marked-only-files () |
1496 "Return the list of marked files, for marked directories, return child files." | 1504 "Return the list of marked files, For marked directories return child files." |
1497 | |
1498 (let ((crt (ewoc-nth vc-ewoc 0)) | 1505 (let ((crt (ewoc-nth vc-ewoc 0)) |
1499 result) | 1506 result) |
1500 (while crt | 1507 (while crt |
1501 (let ((crt-data (ewoc-data crt))) | 1508 (let ((crt-data (ewoc-data crt))) |
1502 (if (vc-dir-fileinfo->marked crt-data) | 1509 (if (vc-dir-fileinfo->marked crt-data) |
1523 (push (expand-file-name (vc-dir-fileinfo->name crt-data)) result) | 1530 (push (expand-file-name (vc-dir-fileinfo->name crt-data)) result) |
1524 (setq crt (ewoc-next vc-ewoc crt))) | 1531 (setq crt (ewoc-next vc-ewoc crt))) |
1525 (setq crt (ewoc-next vc-ewoc crt))))) | 1532 (setq crt (ewoc-next vc-ewoc crt))))) |
1526 result)) | 1533 result)) |
1527 | 1534 |
1535 (defun vc-dir-mark-buffer-changed (&optional fname) | |
1536 (let* ((file (or fname (expand-file-name buffer-file-name))) | |
1537 (found-vc-dir-buf nil)) | |
1538 (save-excursion | |
1539 (dolist (status-buf (buffer-list)) | |
1540 (set-buffer status-buf) | |
1541 ;; look for a vc-dir buffer that might show this file. | |
1542 (when (eq major-mode 'vc-dir-mode) | |
1543 (setq found-vc-dir-buf t) | |
1544 (let ((ddir (expand-file-name default-directory))) | |
1545 ;; This test is cvs-string-prefix-p | |
1546 (when (eq t (compare-strings file nil (length ddir) ddir nil nil)) | |
1547 (let* | |
1548 ((file-short (substring file (length ddir))) | |
1549 (state | |
1550 (apply (client-mode->file-to-state client-mode) fname)) | |
1551 (extra | |
1552 (apply (client-mode->file-to-extra client-mode) fname)) | |
1553 (entry | |
1554 (list file-short state extra))) | |
1555 (vc-dir-update (list entry) status-buf)))))) | |
1556 ;; We didn't find any vc-dir buffers, remove the hook, it is | |
1557 ;; not needed. | |
1558 (unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-dir-mark-buffer-changed))))) | |
1559 | |
1560 (defun vc-dir-mode (client-object) | |
1561 "Major mode for showing the VC status for a directory. | |
1562 Marking/Unmarking key bindings and actions: | |
1563 m - marks a file/directory or if the region is active, mark all the files | |
1564 in region. | |
1565 Restrictions: - a file cannot be marked if any parent directory is marked | |
1566 - a directory cannot be marked if any child file or | |
1567 directory is marked | |
1568 u - marks a file/directory or if the region is active, unmark all the files | |
1569 in region. | |
1570 M - if the cursor is on a file: mark all the files with the same VC state as | |
1571 the current file | |
1572 - if the cursor is on a directory: mark all child files | |
1573 - with a prefix argument: mark all files | |
1574 U - if the cursor is on a file: unmark all the files with the same VC state | |
1575 as the current file | |
1576 - if the cursor is on a directory: unmark all child files | |
1577 - with a prefix argument: unmark all files | |
1578 | |
1579 | |
1580 \\{vc-dir-mode-map}" | |
1581 (setq mode-name (vc-client-object->name client-object)) | |
1582 (setq major-mode 'vc-dir-mode) | |
1583 (setq buffer-read-only t) | |
1584 (use-local-map vc-dir-mode-map) | |
1585 (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map) | |
1586 (set (make-local-variable 'client-mode) client-object) | |
1587 (let ((buffer-read-only nil)) | |
1588 (erase-buffer) | |
1589 (set (make-local-variable 'vc-dir-process-buffer) nil) | |
1590 (set (make-local-variable 'vc-ewoc) | |
1591 (ewoc-create (vc-client-object->file-to-info client-object) | |
1592 (vc-client-object->headers client-object))) | |
1593 (add-hook 'after-save-hook 'vc-dir-mark-buffer-changed) | |
1594 ;; Make sure that if the VC status buffer is killed, the update | |
1595 ;; process running in the background is also killed. | |
1596 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) | |
1597 (funcall (vc-client-object->updater client-object))) | |
1598 (run-hooks 'vc-dir-mode-hook)) | |
1599 | |
1600 (put 'vc-dir-mode 'mode-class 'special) | |
1601 | |
1528 ;;; vc-dispatcher.el ends here | 1602 ;;; vc-dispatcher.el ends here |