Mercurial > emacs
comparison lisp/vc.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 | ce8579003c4f |
children | b37bca16668a |
comparison
equal
deleted
inserted
replaced
94610:318ecca53bb5 | 94611:78377ffa1363 |
---|---|
2052 'mouse-face 'highlight)))) | 2052 'mouse-face 'highlight)))) |
2053 | 2053 |
2054 (defun vc-default-extra-status-menu (backend) | 2054 (defun vc-default-extra-status-menu (backend) |
2055 nil) | 2055 nil) |
2056 | 2056 |
2057 (defun vc-dir-mode (entry-printer header-printer updater marker) | |
2058 "Major mode for showing the VC status for a directory. | |
2059 Marking/Unmarking key bindings and actions: | |
2060 m - marks a file/directory or ff the region is active, mark all the files | |
2061 in region. | |
2062 Restrictions: - a file cannot be marked if any parent directory is marked | |
2063 - a directory cannot be marked if any child file or | |
2064 directory is marked | |
2065 u - marks a file/directory or if the region is active, unmark all the files | |
2066 in region. | |
2067 M - if the cursor is on a file: mark all the files with the same VC state as | |
2068 the current file | |
2069 - if the cursor is on a directory: mark all child files | |
2070 - with a prefix argument: mark all files | |
2071 U - if the cursor is on a file: unmark all the files with the same VC state | |
2072 as the current file | |
2073 - if the cursor is on a directory: unmark all child files | |
2074 - with a prefix argument: unmark all files | |
2075 | |
2076 | |
2077 \\{vc-dir-mode-map}" | |
2078 (setq mode-name "VC Status") | |
2079 (setq major-mode 'vc-dir-mode) | |
2080 (setq buffer-read-only t) | |
2081 (use-local-map vc-dir-mode-map) | |
2082 (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map) | |
2083 (let ((buffer-read-only nil) | |
2084 entries) | |
2085 (erase-buffer) | |
2086 (set (make-local-variable 'vc-dir-process-buffer) nil) | |
2087 (set (make-local-variable 'vc-ewoc) | |
2088 (ewoc-create entry-printer | |
2089 header-printer)) | |
2090 (add-hook 'after-save-hook marker) | |
2091 ;; Make sure that if the VC status buffer is killed, the update | |
2092 ;; process running in the background is also killed. | |
2093 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) | |
2094 (eval updater)) | |
2095 (run-hooks 'vc-dir-mode-hook)) | |
2096 | |
2097 (put 'vc-dir-mode 'mode-class 'special) | |
2098 | |
2099 ;;;###autoload | |
2100 (defun vc-dir (dir) | |
2101 "Show the VC status for DIR." | |
2102 (interactive "DVC status for directory: ") | |
2103 (pop-to-buffer (vc-dir-prepare-status-buffer dir)) | |
2104 (if (eq major-mode 'vc-dir-mode) | |
2105 (vc-dir-refresh) | |
2106 (let ((backend (vc-responsible-backend default-directory))) | |
2107 (vc-dir-mode (lambda (fileentry) | |
2108 (vc-call-backend backend 'status-printer fileentry)) | |
2109 (lambda (dir) | |
2110 (vc-dir-headers backend default-directory)) | |
2111 #'vc-dir-mark-buffer-changed | |
2112 #'vc-dir-refresh)))) | |
2113 | |
2114 ;; This is used to that VC backends could add backend specific menu | 2057 ;; This is used to that VC backends could add backend specific menu |
2115 ;; items to vc-dir-menu-map. | 2058 ;; items to vc-dir-menu-map. |
2116 (defun vc-dir-menu-map-filter (orig-binding) | 2059 (defun vc-dir-menu-map-filter (orig-binding) |
2117 (when (and (symbolp orig-binding) (fboundp orig-binding)) | 2060 (when (and (symbolp orig-binding) (fboundp orig-binding)) |
2118 (setq orig-binding (indirect-function orig-binding))) | 2061 (setq orig-binding (indirect-function orig-binding))) |
2229 ;; FIXME: Just pass the fileset to vc-register. | 2172 ;; FIXME: Just pass the fileset to vc-register. |
2230 (mapc (lambda (arg) (vc-register nil arg)) | 2173 (mapc (lambda (arg) (vc-register nil arg)) |
2231 (or (vc-dir-marked-files) (list (vc-dir-current-file))))) | 2174 (or (vc-dir-marked-files) (list (vc-dir-current-file))))) |
2232 | 2175 |
2233 (defun vc-default-status-fileinfo-extra (backend file) | 2176 (defun vc-default-status-fileinfo-extra (backend file) |
2177 "Default absence of extra information returned for a file." | |
2234 nil) | 2178 nil) |
2235 | 2179 |
2236 (defun vc-dir-mark-buffer-changed (&optional fname) | 2180 ;; FIXME: Replace these with a more efficient dispatch |
2237 (let* ((file (or fname (expand-file-name buffer-file-name))) | 2181 |
2238 (found-vc-dir-buf nil)) | 2182 (defun vc-generic-status-printer (fileentry) |
2239 (save-excursion | 2183 (let ((backend (vc-responsible-backend (vc-dir-fileinfo->name fileentry)))) |
2240 (dolist (status-buf (buffer-list)) | 2184 (vc-call-backend backend 'status-printer fileentry))) |
2241 (set-buffer status-buf) | 2185 |
2242 ;; look for a vc-dir buffer that might show this file. | 2186 (defun vc-generic-state (file) |
2243 (when (eq major-mode 'vc-dir-mode) | 2187 (let ((backend (vc-responsible-backend file))) |
2244 (setq found-vc-dir-buf t) | 2188 (vc-call-backend backend 'state))) |
2245 (let ((ddir (expand-file-name default-directory))) | 2189 |
2246 ;; This test is cvs-string-prefix-p | 2190 (defun vc-generic-status-fileinfo-extra (file) |
2247 (when (eq t (compare-strings file nil (length ddir) ddir nil nil)) | 2191 (let ((backend (vc-responsible-backend file))) |
2248 (let* | 2192 (vc-call-backend backend 'status-fileinfo-extra))) |
2249 ((file-short (substring file (length ddir))) | 2193 |
2250 (backend (vc-backend file)) | 2194 (defun vc-generic-dir-headers (dir) |
2251 (state (and backend (vc-state file))) | 2195 (let ((backend (vc-responsible-backend dir))) |
2252 (extra | 2196 (vc-dir-headers backend dir))) |
2253 (and backend | 2197 |
2254 (vc-call-backend backend 'status-fileinfo-extra file))) | 2198 (defun vc-make-backend-object (file-or-dir) |
2255 (entry | 2199 (vc-create-client-object |
2256 (list file-short (if state state 'unregistered) extra))) | 2200 "VC status" |
2257 (vc-dir-update (list entry) status-buf)))))) | 2201 (let ((backend (vc-responsible-backend file-or-dir))) |
2258 ;; We didn't find any vc-dir buffers, remove the hook, it is | 2202 (vc-dir-headers backend file-or-dir)) |
2259 ;; not needed. | 2203 #'vc-generic-status-printer |
2260 (unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-dir-mark-buffer-changed))))) | 2204 #'vc-generic-state |
2205 #'vc-generic-status-fileinfo-extra | |
2206 #'vc-dir-refresh)) | |
2207 | |
2208 ;;;###autoload | |
2209 (defun vc-dir (dir) | |
2210 "Show the VC status for DIR." | |
2211 (interactive "DVC status for directory: ") | |
2212 (pop-to-buffer (vc-dir-prepare-status-buffer dir)) | |
2213 (if (eq major-mode 'vc-dir-mode) | |
2214 (vc-dir-refresh) | |
2215 ;; Otherwise, initialize a new view using the dispatcher layer | |
2216 (progn | |
2217 ;; Build a capability object and hand it to the dispatcher initializer | |
2218 (vc-dir-mode (vc-make-backend-object backend)) | |
2219 ;; Add VC-specific keybindings | |
2220 (let ((map (current-local-map))) | |
2221 (define-key map "=" 'vc-diff) ;; C-x v = | |
2222 (define-key map "a" 'vc-dir-register) | |
2223 (define-key map "+" 'vc-update) ;; C-x v + | |
2224 (define-key map "R" 'vc-revert) ;; u is taken by dispatcher unmark. | |
2225 (define-key map "A" 'vc-annotate) ;; g is taken by dispatcher referesh | |
2226 (define-key map "l" 'vc-print-log) ;; C-x v l | |
2227 (define-key map "x" 'vc-dir-hide-up-to-date) | |
2228 )))) | |
2261 | 2229 |
2262 ;; Named-configuration entry points | 2230 ;; Named-configuration entry points |
2263 | 2231 |
2264 (defun vc-snapshot-precondition (dir) | 2232 (defun vc-snapshot-precondition (dir) |
2265 "Scan the tree below DIR, looking for files not up-to-date. | 2233 "Scan the tree below DIR, looking for files not up-to-date. |