diff options
| author | Dan Nicolaescu | 2008-06-24 03:45:06 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-06-24 03:45:06 +0000 |
| commit | c4c0a44b61d3b85bd0b7fc0d7fdab33931f4aa7a (patch) | |
| tree | f5c916c56422a36ffc945d92d96e7df9923aa5d1 | |
| parent | 572aed3d4cfa7a6701b717924de1623cabb60c20 (diff) | |
| download | emacs-c4c0a44b61d3b85bd0b7fc0d7fdab33931f4aa7a.tar.gz emacs-c4c0a44b61d3b85bd0b7fc0d7fdab33931f4aa7a.zip | |
(vc-client-object): Remove.
(vc-dir-prepare-status-buffer): Take a backend as an argument and
use it when looking for a buffer.
(vc-dir): Add a backend argument. Set revert-buffer-function.
Don't create a client object. Move bindings ...
(vc-dir-menu-map, vc-dir-mode-map): ... here.
(vc-dir-revert-buffer-function): New function.
(vc-generic-status-printer): Rename to ...
(vc-dir-status-printer): ... this.
(vc-generic-state, vc-generic-status-fileinfo-extra)
(vc-dir-extra-menu, vc-make-backend-object): Remove.
(vc-default-status-printer): Use a different face for
directories. Don't display any text for directories in the state
column. Add tooltips.
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/vc-dir.el | 254 |
2 files changed, 119 insertions, 150 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a0a6ec54795..49a997095df 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,20 @@ | |||
| 1 | 2008-06-24 Dan Nicolaescu <dann@ics.uci.edu> | 1 | 2008-06-24 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 2 | ||
| 3 | * vc-dir.el (vc-client-object): Remove. | ||
| 4 | (vc-dir-prepare-status-buffer): Take a backend as an argument and | ||
| 5 | use it when looking for a buffer. | ||
| 6 | (vc-dir): Add a backend argument. Set revert-buffer-function. | ||
| 7 | Don't create a client object. Move bindings ... | ||
| 8 | (vc-dir-menu-map, vc-dir-mode-map): ... here. | ||
| 9 | (vc-dir-revert-buffer-function): New function. | ||
| 10 | (vc-generic-status-printer): Rename to ... | ||
| 11 | (vc-dir-status-printer): ... this. | ||
| 12 | (vc-generic-state, vc-generic-status-fileinfo-extra) | ||
| 13 | (vc-dir-extra-menu, vc-make-backend-object): Remove. | ||
| 14 | (vc-default-status-printer): Use a different face for | ||
| 15 | directories. Don't display any text for directories in the state | ||
| 16 | column. Add tooltips. | ||
| 17 | |||
| 3 | * vc.el (Todo): Update. | 18 | * vc.el (Todo): Update. |
| 4 | 19 | ||
| 5 | * vc-hg.el (vc-annotate-convert-time, vc-default-status-printer): | 20 | * vc-hg.el (vc-annotate-convert-time, vc-default-status-printer): |
diff --git a/lisp/vc-dir.el b/lisp/vc-dir.el index 7f516848a16..3db5366c230 100644 --- a/lisp/vc-dir.el +++ b/lisp/vc-dir.el | |||
| @@ -62,7 +62,7 @@ See `run-hooks'." | |||
| 62 | (:conc-name vc-dir-fileinfo->)) | 62 | (:conc-name vc-dir-fileinfo->)) |
| 63 | name ;Keep it as first, for `member'. | 63 | name ;Keep it as first, for `member'. |
| 64 | state | 64 | state |
| 65 | ;; For storing client-mode specific information. | 65 | ;; For storing backend specific information. |
| 66 | extra | 66 | extra |
| 67 | marked | 67 | marked |
| 68 | ;; To keep track of not updated files during a global refresh | 68 | ;; To keep track of not updated files during a global refresh |
| @@ -70,30 +70,14 @@ See `run-hooks'." | |||
| 70 | ;; To distinguish files and directories. | 70 | ;; To distinguish files and directories. |
| 71 | directory) | 71 | directory) |
| 72 | 72 | ||
| 73 | ;; Used to describe a dispatcher client mode. | ||
| 74 | (defstruct (vc-client-object | ||
| 75 | (:copier nil) | ||
| 76 | (:constructor | ||
| 77 | vc-create-client-object (name | ||
| 78 | headers | ||
| 79 | file-to-info | ||
| 80 | file-to-state | ||
| 81 | file-to-extra | ||
| 82 | updater | ||
| 83 | extra-menu)) | ||
| 84 | (:conc-name vc-client-object->)) | ||
| 85 | name | ||
| 86 | headers | ||
| 87 | file-to-info | ||
| 88 | file-to-state | ||
| 89 | file-to-extra | ||
| 90 | updater | ||
| 91 | extra-menu) | ||
| 92 | |||
| 93 | (defvar vc-ewoc nil) | 73 | (defvar vc-ewoc nil) |
| 74 | |||
| 94 | (defvar vc-dir-process-buffer nil | 75 | (defvar vc-dir-process-buffer nil |
| 95 | "The buffer used for the asynchronous call that computes status.") | 76 | "The buffer used for the asynchronous call that computes status.") |
| 96 | 77 | ||
| 78 | (defvar vc-dir-backend nil | ||
| 79 | "The backend used by the current *vc-dir* buffer.") | ||
| 80 | |||
| 97 | (defun vc-dir-move-to-goal-column () | 81 | (defun vc-dir-move-to-goal-column () |
| 98 | ;; Used to keep the cursor on the file name column. | 82 | ;; Used to keep the cursor on the file name column. |
| 99 | (beginning-of-line) | 83 | (beginning-of-line) |
| @@ -101,7 +85,7 @@ See `run-hooks'." | |||
| 101 | ;; Must be in sync with vc-default-status-printer. | 85 | ;; Must be in sync with vc-default-status-printer. |
| 102 | (forward-char 25))) | 86 | (forward-char 25))) |
| 103 | 87 | ||
| 104 | (defun vc-dir-prepare-status-buffer (bname dir &optional create-new) | 88 | (defun vc-dir-prepare-status-buffer (bname dir backend &optional create-new) |
| 105 | "Find a buffer named BNAME showing DIR, or create a new one." | 89 | "Find a buffer named BNAME showing DIR, or create a new one." |
| 106 | (setq dir (expand-file-name dir)) | 90 | (setq dir (expand-file-name dir)) |
| 107 | (let* | 91 | (let* |
| @@ -110,7 +94,8 @@ See `run-hooks'." | |||
| 110 | (unless create-new | 94 | (unless create-new |
| 111 | (dolist (buffer (buffer-list)) | 95 | (dolist (buffer (buffer-list)) |
| 112 | (set-buffer buffer) | 96 | (set-buffer buffer) |
| 113 | (when (and (vc-dispatcher-browsing) | 97 | (when (and (derived-mode-p 'vc-dir-mode) |
| 98 | (eq vc-dir-backend backend) | ||
| 114 | (string= (expand-file-name default-directory) dir)) | 99 | (string= (expand-file-name default-directory) dir)) |
| 115 | (return buffer))))))) | 100 | (return buffer))))))) |
| 116 | (or buf | 101 | (or buf |
| @@ -133,9 +118,12 @@ See `run-hooks'." | |||
| 133 | :enable (vc-dir-busy) | 118 | :enable (vc-dir-busy) |
| 134 | :help "Kill the command that updates the directory buffer")) | 119 | :help "Kill the command that updates the directory buffer")) |
| 135 | (define-key map [refresh] | 120 | (define-key map [refresh] |
| 136 | '(menu-item "Refresh" vc-dir-refresh | 121 | '(menu-item "Refresh" revert-buffer |
| 137 | :enable (not (vc-dir-busy)) | 122 | :enable (not (vc-dir-busy)) |
| 138 | :help "Refresh the contents of the directory buffer")) | 123 | :help "Refresh the contents of the directory buffer")) |
| 124 | (define-key map [remup] | ||
| 125 | '(menu-item "Hide up-to-date" vc-dir-hide-up-to-date | ||
| 126 | :help "Hide up-to-date items from display")) | ||
| 139 | ;; Movement. | 127 | ;; Movement. |
| 140 | (define-key map [sepmv] '("--")) | 128 | (define-key map [sepmv] '("--")) |
| 141 | (define-key map [next-line] | 129 | (define-key map [next-line] |
| @@ -173,21 +161,48 @@ See `run-hooks'." | |||
| 173 | (define-key map [open] | 161 | (define-key map [open] |
| 174 | '(menu-item "Open file" vc-dir-find-file | 162 | '(menu-item "Open file" vc-dir-find-file |
| 175 | :help "Find the file on the current line")) | 163 | :help "Find the file on the current line")) |
| 164 | (define-key map [sepvcdet] '("--")) | ||
| 165 | ;; FIXME: This needs a key binding. And maybe a better name | ||
| 166 | ;; ("Insert" like PCL-CVS uses does not sound that great either)... | ||
| 167 | (define-key map [ins] | ||
| 168 | '(menu-item "Show File" vc-dir-show-fileentry | ||
| 169 | :help "Show a file in the VC status listing even though it might be up to date")) | ||
| 170 | (define-key map [annotate] | ||
| 171 | '(menu-item "Annotate" vc-annotate | ||
| 172 | :help "Display the edit history of the current file using colors")) | ||
| 173 | (define-key map [diff] | ||
| 174 | '(menu-item "Compare with Base Version" vc-diff | ||
| 175 | :help "Compare file set with the base version")) | ||
| 176 | (define-key map [log] | ||
| 177 | '(menu-item "Show history" vc-print-log | ||
| 178 | :help "List the change log of the current file set in a window")) | ||
| 179 | ;; VC commands. | ||
| 180 | (define-key map [sepvccmd] '("--")) | ||
| 181 | (define-key map [update] | ||
| 182 | '(menu-item "Update to latest version" vc-update | ||
| 183 | :help "Update the current fileset's files to their tip revisions")) | ||
| 184 | (define-key map [revert] | ||
| 185 | '(menu-item "Revert to base version" vc-revert | ||
| 186 | :help "Revert working copies of the selected fileset to their repository contents.")) | ||
| 187 | (define-key map [next-action] | ||
| 188 | ;; FIXME: This really really really needs a better name! | ||
| 189 | ;; And a key binding too. | ||
| 190 | '(menu-item "Check In/Out" vc-next-action | ||
| 191 | :help "Do the next logical version control operation on the current fileset")) | ||
| 192 | (define-key map [register] | ||
| 193 | '(menu-item "Register" vc-register | ||
| 194 | :help "Register file set into the version control system")) | ||
| 176 | map) | 195 | map) |
| 177 | "Menu for dispatcher status") | 196 | "Menu for dispatcher status") |
| 178 | 197 | ||
| 179 | (defvar vc-client-mode) | 198 | ;; VC backends can use this to add mode-specific menu items to |
| 180 | 199 | ;; vc-dir-menu-map. | |
| 181 | ;; This is used so that client modes can add mode-specific menu | ||
| 182 | ;; items to vc-dir-menu-map. | ||
| 183 | (defun vc-dir-menu-map-filter (orig-binding) | 200 | (defun vc-dir-menu-map-filter (orig-binding) |
| 184 | (when (and (symbolp orig-binding) (fboundp orig-binding)) | 201 | (when (and (symbolp orig-binding) (fboundp orig-binding)) |
| 185 | (setq orig-binding (indirect-function orig-binding))) | 202 | (setq orig-binding (indirect-function orig-binding))) |
| 186 | (let ((ext-binding | 203 | (let ((ext-binding |
| 187 | ;; This may be executed at load-time for tool-bar-local-item-from-menu | 204 | (when (derived-mode-p 'vc-dir-mode) |
| 188 | ;; but at that time vc-client-mode is not known (or even bound) yet. | 205 | (vc-call-backend vc-dir-backend 'extra-status-menu)))) |
| 189 | (when (and (boundp 'vc-client-mode) vc-client-mode) | ||
| 190 | (funcall (vc-client-object->extra-menu vc-client-mode))))) | ||
| 191 | (if (null ext-binding) | 206 | (if (null ext-binding) |
| 192 | orig-binding | 207 | orig-binding |
| 193 | (append orig-binding | 208 | (append orig-binding |
| @@ -197,6 +212,15 @@ See `run-hooks'." | |||
| 197 | (defvar vc-dir-mode-map | 212 | (defvar vc-dir-mode-map |
| 198 | (let ((map (make-keymap))) | 213 | (let ((map (make-keymap))) |
| 199 | (suppress-keymap map) | 214 | (suppress-keymap map) |
| 215 | ;; VC commands | ||
| 216 | (define-key map "v" 'vc-next-action) ;; C-x v v | ||
| 217 | (define-key map "=" 'vc-diff) ;; C-x v = | ||
| 218 | (define-key map "i" 'vc-register) ;; C-x v i | ||
| 219 | (define-key map "+" 'vc-update) ;; C-x v + | ||
| 220 | (define-key map "l" 'vc-print-log) ;; C-x v l | ||
| 221 | ;; More confusing than helpful, probably | ||
| 222 | ;;(define-key map "R" 'vc-revert) ;; u is taken by dispatcher unmark. | ||
| 223 | ;;(define-key map "A" 'vc-annotate) ;; g is taken by dispatcher refresh | ||
| 200 | ;; Marking. | 224 | ;; Marking. |
| 201 | (define-key map "m" 'vc-dir-mark) | 225 | (define-key map "m" 'vc-dir-mark) |
| 202 | (define-key map "M" 'vc-dir-mark-all-files) | 226 | (define-key map "M" 'vc-dir-mark-all-files) |
| @@ -219,17 +243,16 @@ See `run-hooks'." | |||
| 219 | (define-key map "f" 'vc-dir-find-file) | 243 | (define-key map "f" 'vc-dir-find-file) |
| 220 | (define-key map "\C-m" 'vc-dir-find-file) | 244 | (define-key map "\C-m" 'vc-dir-find-file) |
| 221 | (define-key map "o" 'vc-dir-find-file-other-window) | 245 | (define-key map "o" 'vc-dir-find-file-other-window) |
| 222 | (define-key map "q" 'quit-window) | ||
| 223 | (define-key map "g" 'vc-dir-refresh) | ||
| 224 | (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) | 246 | (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) |
| 225 | (define-key map [down-mouse-3] 'vc-dir-menu) | 247 | (define-key map [down-mouse-3] 'vc-dir-menu) |
| 226 | (define-key map [mouse-2] 'vc-dir-toggle-mark) | 248 | (define-key map [mouse-2] 'vc-dir-toggle-mark) |
| 249 | (define-key map "x" 'vc-dir-hide-up-to-date) | ||
| 227 | 250 | ||
| 228 | ;; Hook up the menu. | 251 | ;; Hook up the menu. |
| 229 | (define-key map [menu-bar vc-dir-mode] | 252 | (define-key map [menu-bar vc-dir-mode] |
| 230 | `(menu-item | 253 | `(menu-item |
| 231 | ;; This is used so that client modes can add mode-specific | 254 | ;; VC backends can use this to add mode-specific menu items to |
| 232 | ;; menu items to vc-dir-menu-map. | 255 | ;; vc-dir-menu-map. |
| 233 | "VC-dir" ,vc-dir-menu-map :filter vc-dir-menu-map-filter)) | 256 | "VC-dir" ,vc-dir-menu-map :filter vc-dir-menu-map-filter)) |
| 234 | map) | 257 | map) |
| 235 | "Keymap for directory buffer.") | 258 | "Keymap for directory buffer.") |
| @@ -265,7 +288,7 @@ If `body' uses `event', it should be a variable, | |||
| 265 | :rtl "left-arrow") | 288 | :rtl "left-arrow") |
| 266 | (tool-bar-local-item-from-menu 'vc-print-log "info" | 289 | (tool-bar-local-item-from-menu 'vc-print-log "info" |
| 267 | map vc-dir-mode-map) | 290 | map vc-dir-mode-map) |
| 268 | (tool-bar-local-item-from-menu 'vc-dir-refresh "refresh" | 291 | (tool-bar-local-item-from-menu 'revert-buffer "refresh" |
| 269 | map vc-dir-mode-map) | 292 | map vc-dir-mode-map) |
| 270 | (tool-bar-local-item-from-menu 'nonincremental-search-forward | 293 | (tool-bar-local-item-from-menu 'nonincremental-search-forward |
| 271 | "search" map) | 294 | "search" map) |
| @@ -733,12 +756,9 @@ If it is a file, return the file itself." | |||
| 733 | (let* | 756 | (let* |
| 734 | ;; FIXME: Any reason we don't use file-relative-name? | 757 | ;; FIXME: Any reason we don't use file-relative-name? |
| 735 | ((file-short (substring file (length ddir))) | 758 | ((file-short (substring file (length ddir))) |
| 736 | (state (funcall (vc-client-object->file-to-state | 759 | (state (vc-call-backend vc-dir-backend 'state file)) |
| 737 | vc-client-mode) | 760 | (extra (vc-call-backend vc-dir-backend |
| 738 | file)) | 761 | 'status-fileinfo-extra file)) |
| 739 | (extra (funcall (vc-client-object->file-to-extra | ||
| 740 | vc-client-mode) | ||
| 741 | file)) | ||
| 742 | (entry | 762 | (entry |
| 743 | (list file-short state extra))) | 763 | (list file-short state extra))) |
| 744 | (vc-dir-update (list entry) status-buf)))))) | 764 | (vc-dir-update (list entry) status-buf)))))) |
| @@ -747,7 +767,9 @@ If it is a file, return the file itself." | |||
| 747 | (unless found-vc-dir-buf | 767 | (unless found-vc-dir-buf |
| 748 | (remove-hook 'after-save-hook 'vc-dir-resynch-file))))))) | 768 | (remove-hook 'after-save-hook 'vc-dir-resynch-file))))))) |
| 749 | 769 | ||
| 750 | (defun vc-dir-mode (client-object) | 770 | (defvar use-vc-backend) ;; dynamically bound |
| 771 | |||
| 772 | (define-derived-mode vc-dir-mode special-mode "VC dir" | ||
| 751 | "Major mode for dispatcher directory buffers. | 773 | "Major mode for dispatcher directory buffers. |
| 752 | Marking/Unmarking key bindings and actions: | 774 | Marking/Unmarking key bindings and actions: |
| 753 | m - marks a file/directory or if the region is active, mark all the files | 775 | m - marks a file/directory or if the region is active, mark all the files |
| @@ -768,30 +790,23 @@ U - if the cursor is on a file: unmark all the files with the same state | |||
| 768 | 790 | ||
| 769 | 791 | ||
| 770 | \\{vc-dir-mode-map}" | 792 | \\{vc-dir-mode-map}" |
| 771 | (setq mode-name (vc-client-object->name client-object)) | 793 | (set (make-local-variable 'vc-dir-backend) use-vc-backend) |
| 772 | (setq major-mode 'vc-dir-mode) | ||
| 773 | (setq buffer-read-only t) | 794 | (setq buffer-read-only t) |
| 774 | (use-local-map vc-dir-mode-map) | 795 | (when (boundp 'tool-bar-map) |
| 775 | (if (boundp 'tool-bar-map) | 796 | (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)) |
| 776 | (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)) | ||
| 777 | (set (make-local-variable 'vc-client-mode) client-object) | ||
| 778 | (let ((buffer-read-only nil)) | 797 | (let ((buffer-read-only nil)) |
| 779 | (erase-buffer) | 798 | (erase-buffer) |
| 780 | (set (make-local-variable 'vc-dir-process-buffer) nil) | 799 | (set (make-local-variable 'vc-dir-process-buffer) nil) |
| 781 | (set (make-local-variable 'vc-ewoc) | 800 | (set (make-local-variable 'vc-ewoc) |
| 782 | (ewoc-create (vc-client-object->file-to-info client-object) | 801 | (ewoc-create #'vc-dir-status-printer |
| 783 | (vc-client-object->headers client-object))) | 802 | (vc-dir-headers vc-dir-backend default-directory))) |
| 803 | (set (make-local-variable 'revert-buffer-function) | ||
| 804 | 'vc-dir-revert-buffer-function) | ||
| 784 | (add-hook 'after-save-hook 'vc-dir-resynch-file) | 805 | (add-hook 'after-save-hook 'vc-dir-resynch-file) |
| 785 | ;; Make sure that if the directory buffer is killed, the update | 806 | ;; Make sure that if the directory buffer is killed, the update |
| 786 | ;; process running in the background is also killed. | 807 | ;; process running in the background is also killed. |
| 787 | (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) | 808 | (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) |
| 788 | (funcall (vc-client-object->updater client-object))) | 809 | (vc-dir-refresh))) |
| 789 | (run-hooks 'vc-dir-mode-hook)) | ||
| 790 | |||
| 791 | (put 'vc-dir-mode 'mode-class 'special) | ||
| 792 | |||
| 793 | (defvar vc-dir-backend nil | ||
| 794 | "The backend used by the current *vc-dir* buffer.") | ||
| 795 | 810 | ||
| 796 | (defun vc-dir-headers (backend dir) | 811 | (defun vc-dir-headers (backend dir) |
| 797 | "Display the headers in the *VC dir* buffer. | 812 | "Display the headers in the *VC dir* buffer. |
| @@ -849,6 +864,9 @@ specific headers." | |||
| 849 | 864 | ||
| 850 | (not (vc-dir-fileinfo->needs-update info)))))))))))) | 865 | (not (vc-dir-fileinfo->needs-update info)))))))))))) |
| 851 | 866 | ||
| 867 | (defun vc-dir-revert-buffer-function (&optional ignore-auto noconfirm) | ||
| 868 | (vc-dir-refresh)) | ||
| 869 | |||
| 852 | (defun vc-dir-refresh () | 870 | (defun vc-dir-refresh () |
| 853 | "Refresh the contents of the *VC-dir* buffer. | 871 | "Refresh the contents of the *VC-dir* buffer. |
| 854 | Throw an error if another update process is in progress." | 872 | Throw an error if another update process is in progress." |
| @@ -911,94 +929,30 @@ outside of VC) and one wants to do some operation on it." | |||
| 911 | vc-ewoc | 929 | vc-ewoc |
| 912 | (lambda (crt) (not (eq (vc-dir-fileinfo->state crt) 'up-to-date))))) | 930 | (lambda (crt) (not (eq (vc-dir-fileinfo->state crt) 'up-to-date))))) |
| 913 | 931 | ||
| 914 | ;; FIXME: Replace these with a more efficient dispatch | 932 | (defun vc-dir-status-printer (fileentry) |
| 915 | |||
| 916 | (defun vc-generic-status-printer (fileentry) | ||
| 917 | (vc-call-backend vc-dir-backend 'status-printer fileentry)) | 933 | (vc-call-backend vc-dir-backend 'status-printer fileentry)) |
| 918 | 934 | ||
| 919 | (defun vc-generic-state (file) | ||
| 920 | (vc-call-backend vc-dir-backend 'state file)) | ||
| 921 | |||
| 922 | (defun vc-generic-status-fileinfo-extra (file) | ||
| 923 | (vc-call-backend vc-dir-backend 'status-fileinfo-extra file)) | ||
| 924 | |||
| 925 | (defun vc-dir-extra-menu () | ||
| 926 | (vc-call-backend vc-dir-backend 'extra-status-menu)) | ||
| 927 | |||
| 928 | (defun vc-make-backend-object (file-or-dir) | ||
| 929 | "Create the backend capability object needed by vc-dispatcher." | ||
| 930 | (vc-create-client-object | ||
| 931 | "VC dir" | ||
| 932 | (vc-dir-headers vc-dir-backend file-or-dir) | ||
| 933 | #'vc-generic-status-printer | ||
| 934 | #'vc-generic-state | ||
| 935 | #'vc-generic-status-fileinfo-extra | ||
| 936 | #'vc-dir-refresh | ||
| 937 | #'vc-dir-extra-menu)) | ||
| 938 | |||
| 939 | ;;;###autoload | 935 | ;;;###autoload |
| 940 | (defun vc-dir (dir) | 936 | (defun vc-dir (dir backend) |
| 941 | "Show the VC status for DIR." | 937 | "Show the VC status for DIR. |
| 942 | (interactive "DVC status for directory: ") | 938 | With a prefix argument ask what VC backend to use." |
| 943 | (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir)) | 939 | (interactive |
| 944 | (if (and (derived-mode-p 'vc-dir-mode) (boundp 'client-object)) | 940 | (list |
| 941 | (read-file-name "VC status for directory: " | ||
| 942 | default-directory default-directory t) | ||
| 943 | (if current-prefix-arg | ||
| 944 | (intern | ||
| 945 | (completing-read | ||
| 946 | "Use VC backend: " | ||
| 947 | (mapcar (lambda (b) (list (symbol-name b))) vc-handled-backends) | ||
| 948 | nil t nil nil)) | ||
| 949 | (vc-responsible-backend default-directory)))) | ||
| 950 | (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend)) | ||
| 951 | (if (derived-mode-p 'vc-dir-mode) | ||
| 945 | (vc-dir-refresh) | 952 | (vc-dir-refresh) |
| 946 | ;; Otherwise, initialize a new view using the dispatcher layer | 953 | ;; FIXME: find a better way to pass the backend to `vc-dir-mode'. |
| 947 | (progn | 954 | (let ((use-vc-backend backend)) |
| 948 | (set (make-local-variable 'vc-dir-backend) (vc-responsible-backend dir)) | 955 | (vc-dir-mode)))) |
| 949 | ;; Build a capability object and hand it to the dispatcher initializer | ||
| 950 | (vc-dir-mode (vc-make-backend-object dir)) | ||
| 951 | ;; FIXME: Make a derived-mode instead. | ||
| 952 | ;; Add VC-specific keybindings | ||
| 953 | (let ((map (current-local-map))) | ||
| 954 | (define-key map "v" 'vc-next-action) ;; C-x v v | ||
| 955 | (define-key map "=" 'vc-diff) ;; C-x v = | ||
| 956 | (define-key map "i" 'vc-register) ;; C-x v i | ||
| 957 | (define-key map "+" 'vc-update) ;; C-x v + | ||
| 958 | (define-key map "l" 'vc-print-log) ;; C-x v l | ||
| 959 | ;; More confusing than helpful, probably | ||
| 960 | ;(define-key map "R" 'vc-revert) ;; u is taken by dispatcher unmark. | ||
| 961 | ;(define-key map "A" 'vc-annotate) ;; g is taken by dispatcher refresh | ||
| 962 | (define-key map "x" 'vc-dir-hide-up-to-date)) | ||
| 963 | ) | ||
| 964 | ;; FIXME: Needs to alter a buffer-local map, otherwise clients may clash | ||
| 965 | (let ((map vc-dir-menu-map)) | ||
| 966 | ;; VC info details | ||
| 967 | (define-key map [sepvcdet] '("--")) | ||
| 968 | (define-key map [remup] | ||
| 969 | '(menu-item "Hide up-to-date" vc-dir-hide-up-to-date | ||
| 970 | :help "Hide up-to-date items from display")) | ||
| 971 | ;; FIXME: This needs a key binding. And maybe a better name | ||
| 972 | ;; ("Insert" like PCL-CVS uses does not sound that great either)... | ||
| 973 | (define-key map [ins] | ||
| 974 | '(menu-item "Show File" vc-dir-show-fileentry | ||
| 975 | :help "Show a file in the VC status listing even though it might be up to date")) | ||
| 976 | (define-key map [annotate] | ||
| 977 | '(menu-item "Annotate" vc-annotate | ||
| 978 | :help "Display the edit history of the current file using colors")) | ||
| 979 | (define-key map [diff] | ||
| 980 | '(menu-item "Compare with Base Version" vc-diff | ||
| 981 | :help "Compare file set with the base version")) | ||
| 982 | (define-key map [log] | ||
| 983 | '(menu-item "Show history" vc-print-log | ||
| 984 | :help "List the change log of the current file set in a window")) | ||
| 985 | ;; VC commands. | ||
| 986 | (define-key map [sepvccmd] '("--")) | ||
| 987 | (define-key map [update] | ||
| 988 | '(menu-item "Update to latest version" vc-update | ||
| 989 | :help "Update the current fileset's files to their tip revisions")) | ||
| 990 | (define-key map [revert] | ||
| 991 | '(menu-item "Revert to base version" vc-revert | ||
| 992 | :help "Revert working copies of the selected fileset to their repository contents.")) | ||
| 993 | (define-key map [next-action] | ||
| 994 | ;; FIXME: This really really really needs a better name! | ||
| 995 | ;; And a key binding too. | ||
| 996 | '(menu-item "Check In/Out" vc-next-action | ||
| 997 | :help "Do the next logical version control operation on the current fileset")) | ||
| 998 | (define-key map [register] | ||
| 999 | '(menu-item "Register" vc-dir-register | ||
| 1000 | :help "Register file set into the version control system")) | ||
| 1001 | ))) | ||
| 1002 | 956 | ||
| 1003 | (defun vc-default-status-extra-headers (backend dir) | 957 | (defun vc-default-status-extra-headers (backend dir) |
| 1004 | ;; Be loud by default to remind people to add code to display | 958 | ;; Be loud by default to remind people to add code to display |
| @@ -1013,13 +967,8 @@ outside of VC) and one wants to do some operation on it." | |||
| 1013 | "Pretty print FILEENTRY." | 967 | "Pretty print FILEENTRY." |
| 1014 | ;; If you change the layout here, change vc-dir-move-to-goal-column. | 968 | ;; If you change the layout here, change vc-dir-move-to-goal-column. |
| 1015 | (let* ((isdir (vc-dir-fileinfo->directory fileentry)) | 969 | (let* ((isdir (vc-dir-fileinfo->directory fileentry)) |
| 1016 | (state (if isdir 'DIRECTORY (vc-dir-fileinfo->state fileentry))) | 970 | (state (if isdir "" (vc-dir-fileinfo->state fileentry))) |
| 1017 | (filename (vc-dir-fileinfo->name fileentry))) | 971 | (filename (vc-dir-fileinfo->name fileentry))) |
| 1018 | ;; FIXME: Backends that want to print the state in a different way | ||
| 1019 | ;; can do it by defining the `status-printer' function. Using | ||
| 1020 | ;; `prettify-state-info' adds two extra vc-calls per item, which | ||
| 1021 | ;; is too expensive. | ||
| 1022 | ;;(prettified (if isdir state (vc-call-backend backend 'prettify-state-info filename)))) | ||
| 1023 | (insert | 972 | (insert |
| 1024 | (propertize | 973 | (propertize |
| 1025 | (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? )) | 974 | (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? )) |
| @@ -1034,7 +983,12 @@ outside of VC) and one wants to do some operation on it." | |||
| 1034 | " " | 983 | " " |
| 1035 | (propertize | 984 | (propertize |
| 1036 | (format "%s" filename) | 985 | (format "%s" filename) |
| 1037 | 'face 'font-lock-function-name-face | 986 | 'face |
| 987 | (if isdir 'font-lock-comment-delimiter-face 'font-lock-function-name-face) | ||
| 988 | 'help-echo | ||
| 989 | (if isdir | ||
| 990 | "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu" | ||
| 991 | "File\nmouse-3: Pop-up menu") | ||
| 1038 | 'mouse-face 'highlight)))) | 992 | 'mouse-face 'highlight)))) |
| 1039 | 993 | ||
| 1040 | (defun vc-default-extra-status-menu (backend) | 994 | (defun vc-default-extra-status-menu (backend) |