Mercurial > emacs
annotate lisp/vc-dir.el @ 96384:59d141ae8c74
cc-mode.el (c-mode-base-map): Don't bind C-M-[ae] to the CC Mode specific
functions; this is no longer needed, since {beginning,end}-of-defun now
pass ARG to ...-of-defun-function.
cc-defs.el (c-emacs-features): new feature 'argumentative-bod-function.
----------------------------------------------------------------------
cc-defs.el cc-mode.el CVS:
----------------------------------------------------------------------
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Fri, 27 Jun 2008 21:12:46 +0000 |
parents | ba295cada06b |
children | 7ed97437d100 |
rev | line source |
---|---|
96203 | 1 ;;; vc-dir.el --- Directory status display under VC |
2 | |
3 ;; Copyright (C) 2007, 2008 | |
4 ;; Free Software Foundation, Inc. | |
5 | |
6 ;; Author: Dan Nicolaescu <dann@ics.uci.edu> | |
7 ;; Keywords: tools | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software: you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation, either version 3 of the License, or | |
14 ;; (at your option) any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
23 | |
24 ;;; Credits: | |
25 | |
26 ;; The original VC directory status implementation was based on dired. | |
27 ;; This implementation was inspired by PCL-CVS. | |
28 ;; Many people contributed comments, ideas and code to this | |
29 ;; implementation. These include: | |
30 ;; | |
31 ;; Alexandre Julliard <julliard@winehq.org> | |
32 ;; Stefan Monnier <monnier@iro.umontreal.ca> | |
33 ;; Tom Tromey <tromey@redhat.com> | |
34 | |
35 ;;; Commentary: | |
36 ;; | |
37 | |
38 ;;; Todo: see vc.el. | |
39 | |
40 (require 'vc-hooks) | |
41 (require 'vc) | |
96310
ba295cada06b
* vc-dir.el (tool-bar): Require.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96256
diff
changeset
|
42 (require 'tool-bar) |
96203 | 43 (require 'ewoc) |
44 | |
45 ;;; Code: | |
46 (eval-when-compile | |
47 (require 'cl)) | |
48 | |
49 (defcustom vc-dir-mode-hook nil | |
50 "Normal hook run by `vc-dir-mode'. | |
51 See `run-hooks'." | |
52 :type 'hook | |
53 :group 'vc) | |
54 | |
55 ;; Used to store information for the files displayed in the directory buffer. | |
56 ;; Each item displayed corresponds to one of these defstructs. | |
57 (defstruct (vc-dir-fileinfo | |
58 (:copier nil) | |
59 (:type list) ;So we can use `member' on lists of FIs. | |
60 (:constructor | |
61 ;; We could define it as an alias for `list'. | |
62 vc-dir-create-fileinfo (name state &optional extra marked directory)) | |
63 (:conc-name vc-dir-fileinfo->)) | |
64 name ;Keep it as first, for `member'. | |
65 state | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
66 ;; For storing backend specific information. |
96203 | 67 extra |
68 marked | |
69 ;; To keep track of not updated files during a global refresh | |
70 needs-update | |
71 ;; To distinguish files and directories. | |
72 directory) | |
73 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
74 (defvar vc-ewoc nil) |
96203 | 75 |
76 (defvar vc-dir-process-buffer nil | |
77 "The buffer used for the asynchronous call that computes status.") | |
78 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
79 (defvar vc-dir-backend nil |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
80 "The backend used by the current *vc-dir* buffer.") |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
81 |
96203 | 82 (defun vc-dir-move-to-goal-column () |
83 ;; Used to keep the cursor on the file name column. | |
84 (beginning-of-line) | |
85 (unless (eolp) | |
86 ;; Must be in sync with vc-default-status-printer. | |
87 (forward-char 25))) | |
88 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
89 (defun vc-dir-prepare-status-buffer (bname dir backend &optional create-new) |
96203 | 90 "Find a buffer named BNAME showing DIR, or create a new one." |
91 (setq dir (expand-file-name dir)) | |
92 (let* | |
93 ;; Look for another buffer name BNAME visiting the same directory. | |
94 ((buf (save-excursion | |
95 (unless create-new | |
96 (dolist (buffer (buffer-list)) | |
97 (set-buffer buffer) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
98 (when (and (derived-mode-p 'vc-dir-mode) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
99 (eq vc-dir-backend backend) |
96203 | 100 (string= (expand-file-name default-directory) dir)) |
101 (return buffer))))))) | |
102 (or buf | |
103 ;; Create a new buffer named BNAME. | |
104 (with-current-buffer (create-file-buffer bname) | |
105 (cd dir) | |
106 (vc-setup-buffer (current-buffer)) | |
107 ;; Reset the vc-parent-buffer-name so that it does not appear | |
108 ;; in the mode-line. | |
109 (setq vc-parent-buffer-name nil) | |
110 (current-buffer))))) | |
111 | |
112 (defvar vc-dir-menu-map | |
113 (let ((map (make-sparse-keymap "VC-dir"))) | |
114 (define-key map [quit] | |
115 '(menu-item "Quit" quit-window | |
116 :help "Quit")) | |
117 (define-key map [kill] | |
118 '(menu-item "Kill Update Command" vc-dir-kill-dir-status-process | |
119 :enable (vc-dir-busy) | |
120 :help "Kill the command that updates the directory buffer")) | |
121 (define-key map [refresh] | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
122 '(menu-item "Refresh" revert-buffer |
96203 | 123 :enable (not (vc-dir-busy)) |
124 :help "Refresh the contents of the directory buffer")) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
125 (define-key map [remup] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
126 '(menu-item "Hide up-to-date" vc-dir-hide-up-to-date |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
127 :help "Hide up-to-date items from display")) |
96203 | 128 ;; Movement. |
129 (define-key map [sepmv] '("--")) | |
130 (define-key map [next-line] | |
131 '(menu-item "Next line" vc-dir-next-line | |
132 :help "Go to the next line" :keys "n")) | |
133 (define-key map [previous-line] | |
134 '(menu-item "Previous line" vc-dir-previous-line | |
135 :help "Go to the previous line")) | |
136 ;; Marking. | |
137 (define-key map [sepmrk] '("--")) | |
138 (define-key map [unmark-all] | |
139 '(menu-item "Unmark All" vc-dir-unmark-all-files | |
140 :help "Unmark all files that are in the same state as the current file\ | |
141 \nWith prefix argument unmark all files")) | |
142 (define-key map [unmark-previous] | |
143 '(menu-item "Unmark previous " vc-dir-unmark-file-up | |
144 :help "Move to the previous line and unmark the file")) | |
145 | |
146 (define-key map [mark-all] | |
147 '(menu-item "Mark All" vc-dir-mark-all-files | |
148 :help "Mark all files that are in the same state as the current file\ | |
149 \nWith prefix argument mark all files")) | |
150 (define-key map [unmark] | |
151 '(menu-item "Unmark" vc-dir-unmark | |
152 :help "Unmark the current file or all files in the region")) | |
153 | |
154 (define-key map [mark] | |
155 '(menu-item "Mark" vc-dir-mark | |
156 :help "Mark the current file or all files in the region")) | |
157 | |
158 (define-key map [sepopn] '("--")) | |
159 (define-key map [open-other] | |
160 '(menu-item "Open in other window" vc-dir-find-file-other-window | |
161 :help "Find the file on the current line, in another window")) | |
162 (define-key map [open] | |
163 '(menu-item "Open file" vc-dir-find-file | |
164 :help "Find the file on the current line")) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
165 (define-key map [sepvcdet] '("--")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
166 ;; FIXME: This needs a key binding. And maybe a better name |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
167 ;; ("Insert" like PCL-CVS uses does not sound that great either)... |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
168 (define-key map [ins] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
169 '(menu-item "Show File" vc-dir-show-fileentry |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
170 :help "Show a file in the VC status listing even though it might be up to date")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
171 (define-key map [annotate] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
172 '(menu-item "Annotate" vc-annotate |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
173 :help "Display the edit history of the current file using colors")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
174 (define-key map [diff] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
175 '(menu-item "Compare with Base Version" vc-diff |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
176 :help "Compare file set with the base version")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
177 (define-key map [log] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
178 '(menu-item "Show history" vc-print-log |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
179 :help "List the change log of the current file set in a window")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
180 ;; VC commands. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
181 (define-key map [sepvccmd] '("--")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
182 (define-key map [update] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
183 '(menu-item "Update to latest version" vc-update |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
184 :help "Update the current fileset's files to their tip revisions")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
185 (define-key map [revert] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
186 '(menu-item "Revert to base version" vc-revert |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
187 :help "Revert working copies of the selected fileset to their repository contents.")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
188 (define-key map [next-action] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
189 ;; FIXME: This really really really needs a better name! |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
190 ;; And a key binding too. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
191 '(menu-item "Check In/Out" vc-next-action |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
192 :help "Do the next logical version control operation on the current fileset")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
193 (define-key map [register] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
194 '(menu-item "Register" vc-register |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
195 :help "Register file set into the version control system")) |
96203 | 196 map) |
197 "Menu for dispatcher status") | |
198 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
199 ;; VC backends can use this to add mode-specific menu items to |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
200 ;; vc-dir-menu-map. |
96203 | 201 (defun vc-dir-menu-map-filter (orig-binding) |
202 (when (and (symbolp orig-binding) (fboundp orig-binding)) | |
203 (setq orig-binding (indirect-function orig-binding))) | |
204 (let ((ext-binding | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
205 (when (derived-mode-p 'vc-dir-mode) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
206 (vc-call-backend vc-dir-backend 'extra-status-menu)))) |
96203 | 207 (if (null ext-binding) |
208 orig-binding | |
209 (append orig-binding | |
210 '("----") | |
211 ext-binding)))) | |
212 | |
213 (defvar vc-dir-mode-map | |
214 (let ((map (make-keymap))) | |
215 (suppress-keymap map) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
216 ;; VC commands |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
217 (define-key map "v" 'vc-next-action) ;; C-x v v |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
218 (define-key map "=" 'vc-diff) ;; C-x v = |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
219 (define-key map "i" 'vc-register) ;; C-x v i |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
220 (define-key map "+" 'vc-update) ;; C-x v + |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
221 (define-key map "l" 'vc-print-log) ;; C-x v l |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
222 ;; More confusing than helpful, probably |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
223 ;;(define-key map "R" 'vc-revert) ;; u is taken by dispatcher unmark. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
224 ;;(define-key map "A" 'vc-annotate) ;; g is taken by dispatcher refresh |
96203 | 225 ;; Marking. |
226 (define-key map "m" 'vc-dir-mark) | |
227 (define-key map "M" 'vc-dir-mark-all-files) | |
228 (define-key map "u" 'vc-dir-unmark) | |
229 (define-key map "U" 'vc-dir-unmark-all-files) | |
230 (define-key map "\C-?" 'vc-dir-unmark-file-up) | |
231 (define-key map "\M-\C-?" 'vc-dir-unmark-all-files) | |
232 ;; Movement. | |
233 (define-key map "n" 'vc-dir-next-line) | |
234 (define-key map " " 'vc-dir-next-line) | |
235 (define-key map "\t" 'vc-dir-next-directory) | |
236 (define-key map "p" 'vc-dir-previous-line) | |
237 (define-key map [backtab] 'vc-dir-previous-directory) | |
238 ;;; Rebind paragraph-movement commands. | |
239 (define-key map "\M-}" 'vc-dir-next-directory) | |
240 (define-key map "\M-{" 'vc-dir-previous-directory) | |
241 (define-key map [C-down] 'vc-dir-next-directory) | |
242 (define-key map [C-up] 'vc-dir-previous-directory) | |
243 ;; The remainder. | |
244 (define-key map "f" 'vc-dir-find-file) | |
245 (define-key map "\C-m" 'vc-dir-find-file) | |
246 (define-key map "o" 'vc-dir-find-file-other-window) | |
247 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) | |
248 (define-key map [down-mouse-3] 'vc-dir-menu) | |
249 (define-key map [mouse-2] 'vc-dir-toggle-mark) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
250 (define-key map "x" 'vc-dir-hide-up-to-date) |
96203 | 251 |
252 ;; Hook up the menu. | |
253 (define-key map [menu-bar vc-dir-mode] | |
254 `(menu-item | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
255 ;; VC backends can use this to add mode-specific menu items to |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
256 ;; vc-dir-menu-map. |
96203 | 257 "VC-dir" ,vc-dir-menu-map :filter vc-dir-menu-map-filter)) |
258 map) | |
259 "Keymap for directory buffer.") | |
260 | |
261 (defmacro vc-at-event (event &rest body) | |
262 "Evaluate `body' with point located at event-start of `event'. | |
263 If `body' uses `event', it should be a variable, | |
264 otherwise it will be evaluated twice." | |
265 (let ((posn (make-symbol "vc-at-event-posn"))) | |
266 `(let ((,posn (event-start ,event))) | |
267 (save-excursion | |
268 (set-buffer (window-buffer (posn-window ,posn))) | |
269 (goto-char (posn-point ,posn)) | |
270 ,@body)))) | |
271 | |
272 (defun vc-dir-menu (e) | |
273 "Popup the dispatcher status menu." | |
274 (interactive "e") | |
275 (vc-at-event e (popup-menu vc-dir-menu-map e))) | |
276 | |
277 (defvar vc-dir-tool-bar-map | |
278 (let ((map (make-sparse-keymap))) | |
279 (tool-bar-local-item-from-menu 'vc-dir-find-file "open" | |
280 map vc-dir-mode-map) | |
281 (tool-bar-local-item "bookmark_add" | |
282 'vc-dir-toggle-mark 'vc-dir-toggle-mark map | |
283 :help "Toggle mark on current item") | |
284 (tool-bar-local-item-from-menu 'vc-dir-previous-line "left-arrow" | |
285 map vc-dir-mode-map | |
286 :rtl "right-arrow") | |
287 (tool-bar-local-item-from-menu 'vc-dir-next-line "right-arrow" | |
288 map vc-dir-mode-map | |
289 :rtl "left-arrow") | |
290 (tool-bar-local-item-from-menu 'vc-print-log "info" | |
291 map vc-dir-mode-map) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
292 (tool-bar-local-item-from-menu 'revert-buffer "refresh" |
96203 | 293 map vc-dir-mode-map) |
294 (tool-bar-local-item-from-menu 'nonincremental-search-forward | |
295 "search" map) | |
296 (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel" | |
297 map vc-dir-mode-map) | |
298 (tool-bar-local-item-from-menu 'quit-window "exit" | |
299 map vc-dir-mode-map) | |
300 map)) | |
301 | |
302 (defun vc-dir-node-directory (node) | |
303 ;; Compute the directory for NODE. | |
304 ;; If it's a directory node, get it from the the node. | |
305 (let ((data (ewoc-data node))) | |
306 (or (vc-dir-fileinfo->directory data) | |
307 ;; Otherwise compute it from the file name. | |
308 (file-name-directory | |
309 (expand-file-name | |
310 (vc-dir-fileinfo->name data)))))) | |
311 | |
312 (defun vc-dir-update (entries buffer &optional noinsert) | |
313 "Update BUFFER's ewoc from the list of ENTRIES. | |
314 If NOINSERT, ignore elements on ENTRIES which are not in the ewoc." | |
315 ;; Add ENTRIES to the vc-dir buffer BUFFER. | |
316 (with-current-buffer buffer | |
317 ;; Insert the entries sorted by name into the ewoc. | |
318 ;; We assume the ewoc is sorted too, which should be the | |
319 ;; case if we always add entries with vc-dir-update. | |
320 (setq entries | |
321 ;; Sort: first files and then subdirectories. | |
322 ;; XXX: this is VERY inefficient, it computes the directory | |
323 ;; names too many times | |
324 (sort entries | |
325 (lambda (entry1 entry2) | |
326 (let ((dir1 (file-name-directory (expand-file-name (car entry1)))) | |
327 (dir2 (file-name-directory (expand-file-name (car entry2))))) | |
328 (cond | |
329 ((string< dir1 dir2) t) | |
330 ((not (string= dir1 dir2)) nil) | |
331 ((string< (car entry1) (car entry2)))))))) | |
332 ;; Insert directory entries in the right places. | |
333 (let ((entry (car entries)) | |
334 (node (ewoc-nth vc-ewoc 0))) | |
335 ;; Insert . if it is not present. | |
336 (unless node | |
337 (let ((rd (file-relative-name default-directory))) | |
338 (ewoc-enter-last | |
339 vc-ewoc (vc-dir-create-fileinfo | |
340 rd nil nil nil (expand-file-name default-directory)))) | |
341 (setq node (ewoc-nth vc-ewoc 0))) | |
342 | |
343 (while (and entry node) | |
344 (let* ((entryfile (car entry)) | |
345 (entrydir (file-name-directory (expand-file-name entryfile))) | |
346 (nodedir (vc-dir-node-directory node))) | |
347 (cond | |
348 ;; First try to find the directory. | |
349 ((string-lessp nodedir entrydir) | |
350 (setq node (ewoc-next vc-ewoc node))) | |
351 ((string-equal nodedir entrydir) | |
352 ;; Found the directory, find the place for the file name. | |
353 (let ((nodefile (vc-dir-fileinfo->name (ewoc-data node)))) | |
354 (cond | |
355 ((string-lessp nodefile entryfile) | |
356 (setq node (ewoc-next vc-ewoc node))) | |
357 ((string-equal nodefile entryfile) | |
358 (setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry)) | |
359 (setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry)) | |
360 (setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil) | |
361 (ewoc-invalidate vc-ewoc node) | |
362 (setq entries (cdr entries)) | |
363 (setq entry (car entries)) | |
364 (setq node (ewoc-next vc-ewoc node))) | |
365 (t | |
366 (ewoc-enter-before vc-ewoc node | |
367 (apply 'vc-dir-create-fileinfo entry)) | |
368 (setq entries (cdr entries)) | |
369 (setq entry (car entries)))))) | |
370 (t | |
371 ;; We might need to insert a directory node if the | |
372 ;; previous node was in a different directory. | |
373 (let* ((rd (file-relative-name entrydir)) | |
374 (prev-node (ewoc-prev vc-ewoc node)) | |
375 (prev-dir (vc-dir-node-directory prev-node))) | |
376 (unless (string-equal entrydir prev-dir) | |
377 (ewoc-enter-before | |
378 vc-ewoc node (vc-dir-create-fileinfo rd nil nil nil entrydir)))) | |
379 ;; Now insert the node itself. | |
380 (ewoc-enter-before vc-ewoc node | |
381 (apply 'vc-dir-create-fileinfo entry)) | |
382 (setq entries (cdr entries) entry (car entries)))))) | |
383 ;; We're past the last node, all remaining entries go to the end. | |
384 (unless (or node noinsert) | |
385 (let ((lastdir (vc-dir-node-directory (ewoc-nth vc-ewoc -1)))) | |
386 (dolist (entry entries) | |
387 (let ((entrydir (file-name-directory (expand-file-name (car entry))))) | |
388 ;; Insert a directory node if needed. | |
389 (unless (string-equal lastdir entrydir) | |
390 (setq lastdir entrydir) | |
391 (let ((rd (file-relative-name entrydir))) | |
392 (ewoc-enter-last | |
393 vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir)))) | |
394 ;; Now insert the node itself. | |
395 (ewoc-enter-last vc-ewoc | |
396 (apply 'vc-dir-create-fileinfo entry))))))))) | |
397 | |
398 (defun vc-dir-busy () | |
399 (and (buffer-live-p vc-dir-process-buffer) | |
400 (get-buffer-process vc-dir-process-buffer))) | |
401 | |
402 (defun vc-dir-kill-dir-status-process () | |
403 "Kill the temporary buffer and associated process." | |
404 (interactive) | |
405 (when (buffer-live-p vc-dir-process-buffer) | |
406 (let ((proc (get-buffer-process vc-dir-process-buffer))) | |
407 (when proc (delete-process proc)) | |
408 (setq vc-dir-process-buffer nil) | |
409 (setq mode-line-process nil)))) | |
410 | |
411 (defun vc-dir-kill-query () | |
412 ;; Make sure that when the status buffer is killed the update | |
413 ;; process running in background is also killed. | |
414 (if (vc-dir-busy) | |
415 (when (y-or-n-p "Status update process running, really kill status buffer? ") | |
416 (vc-dir-kill-dir-status-process) | |
417 t) | |
418 t)) | |
419 | |
420 (defun vc-dir-next-line (arg) | |
421 "Go to the next line. | |
422 If a prefix argument is given, move by that many lines." | |
423 (interactive "p") | |
424 (with-no-warnings | |
425 (ewoc-goto-next vc-ewoc arg) | |
426 (vc-dir-move-to-goal-column))) | |
427 | |
428 (defun vc-dir-previous-line (arg) | |
429 "Go to the previous line. | |
430 If a prefix argument is given, move by that many lines." | |
431 (interactive "p") | |
432 (ewoc-goto-prev vc-ewoc arg) | |
433 (vc-dir-move-to-goal-column)) | |
434 | |
435 (defun vc-dir-next-directory () | |
436 "Go to the next directory." | |
437 (interactive) | |
438 (let ((orig (point))) | |
439 (if | |
440 (catch 'foundit | |
441 (while t | |
442 (let* ((next (ewoc-next vc-ewoc (ewoc-locate vc-ewoc)))) | |
443 (cond ((not next) | |
444 (throw 'foundit t)) | |
445 (t | |
446 (progn | |
447 (ewoc-goto-node vc-ewoc next) | |
448 (vc-dir-move-to-goal-column) | |
449 (if (vc-dir-fileinfo->directory (ewoc-data next)) | |
450 (throw 'foundit nil)))))))) | |
451 (goto-char orig)))) | |
452 | |
453 (defun vc-dir-previous-directory () | |
454 "Go to the previous directory." | |
455 (interactive) | |
456 (let ((orig (point))) | |
457 (if | |
458 (catch 'foundit | |
459 (while t | |
460 (let* ((prev (ewoc-prev vc-ewoc (ewoc-locate vc-ewoc)))) | |
461 (cond ((not prev) | |
462 (throw 'foundit t)) | |
463 (t | |
464 (progn | |
465 (ewoc-goto-node vc-ewoc prev) | |
466 (vc-dir-move-to-goal-column) | |
467 (if (vc-dir-fileinfo->directory (ewoc-data prev)) | |
468 (throw 'foundit nil)))))))) | |
469 (goto-char orig)))) | |
470 | |
471 (defun vc-dir-mark-unmark (mark-unmark-function) | |
472 (if (use-region-p) | |
473 (let ((firstl (line-number-at-pos (region-beginning))) | |
474 (lastl (line-number-at-pos (region-end)))) | |
475 (save-excursion | |
476 (goto-char (region-beginning)) | |
477 (while (<= (line-number-at-pos) lastl) | |
478 (funcall mark-unmark-function)))) | |
479 (funcall mark-unmark-function))) | |
480 | |
481 (defun vc-string-prefix-p (prefix string) | |
482 (let ((lpref (length prefix))) | |
483 (and (>= (length string) lpref) | |
484 (eq t (compare-strings prefix nil nil string nil lpref))))) | |
485 | |
486 (defun vc-dir-parent-marked-p (arg) | |
487 ;; Return nil if none of the parent directories of arg is marked. | |
488 (let* ((argdir (vc-dir-node-directory arg)) | |
489 (arglen (length argdir)) | |
490 (crt arg) | |
491 data dir) | |
492 ;; Go through the predecessors, checking if any directory that is | |
493 ;; a parent is marked. | |
494 (while (setq crt (ewoc-prev vc-ewoc crt)) | |
495 (setq data (ewoc-data crt)) | |
496 (setq dir (vc-dir-node-directory crt)) | |
497 (when (and (vc-dir-fileinfo->directory data) | |
498 (vc-string-prefix-p dir argdir)) | |
499 (when (vc-dir-fileinfo->marked data) | |
500 (error "Cannot mark `%s', parent directory `%s' marked" | |
501 (vc-dir-fileinfo->name (ewoc-data arg)) | |
502 (vc-dir-fileinfo->name data))))) | |
503 nil)) | |
504 | |
505 (defun vc-dir-children-marked-p (arg) | |
506 ;; Return nil if none of the children of arg is marked. | |
507 (let* ((argdir-re (concat "\\`" (regexp-quote (vc-dir-node-directory arg)))) | |
508 (is-child t) | |
509 (crt arg) | |
510 data dir) | |
511 (while (and is-child (setq crt (ewoc-next vc-ewoc crt))) | |
512 (setq data (ewoc-data crt)) | |
513 (setq dir (vc-dir-node-directory crt)) | |
514 (if (string-match argdir-re dir) | |
515 (when (vc-dir-fileinfo->marked data) | |
516 (error "Cannot mark `%s', child `%s' marked" | |
517 (vc-dir-fileinfo->name (ewoc-data arg)) | |
518 (vc-dir-fileinfo->name data))) | |
519 ;; We are done, we got to an entry that is not a child of `arg'. | |
520 (setq is-child nil))) | |
521 nil)) | |
522 | |
523 (defun vc-dir-mark-file (&optional arg) | |
524 ;; Mark ARG or the current file and move to the next line. | |
525 (let* ((crt (or arg (ewoc-locate vc-ewoc))) | |
526 (file (ewoc-data crt)) | |
527 (isdir (vc-dir-fileinfo->directory file))) | |
528 (when (or (and isdir (not (vc-dir-children-marked-p crt))) | |
529 (and (not isdir) (not (vc-dir-parent-marked-p crt)))) | |
530 (setf (vc-dir-fileinfo->marked file) t) | |
531 (ewoc-invalidate vc-ewoc crt) | |
532 (unless (or arg (mouse-event-p last-command-event)) | |
533 (vc-dir-next-line 1))))) | |
534 | |
535 (defun vc-dir-mark () | |
536 "Mark the current file or all files in the region. | |
537 If the region is active, mark all the files in the region. | |
538 Otherwise mark the file on the current line and move to the next | |
539 line." | |
540 (interactive) | |
541 (vc-dir-mark-unmark 'vc-dir-mark-file)) | |
542 | |
543 (defun vc-dir-mark-all-files (arg) | |
544 "Mark all files with the same state as the current one. | |
545 With a prefix argument mark all files. | |
546 If the current entry is a directory, mark all child files. | |
547 | |
548 The commands operate on files that are on the same state. | |
549 This command is intended to make it easy to select all files that | |
550 share the same state." | |
551 (interactive "P") | |
552 (if arg | |
553 ;; Mark all files. | |
554 (progn | |
555 ;; First check that no directory is marked, we can't mark | |
556 ;; files in that case. | |
557 (ewoc-map | |
558 (lambda (filearg) | |
559 (when (and (vc-dir-fileinfo->directory filearg) | |
560 (vc-dir-fileinfo->marked filearg)) | |
561 (error "Cannot mark all files, directory `%s' marked" | |
562 (vc-dir-fileinfo->name filearg)))) | |
563 vc-ewoc) | |
564 (ewoc-map | |
565 (lambda (filearg) | |
566 (unless (vc-dir-fileinfo->marked filearg) | |
567 (setf (vc-dir-fileinfo->marked filearg) t) | |
568 t)) | |
569 vc-ewoc)) | |
570 (let ((data (ewoc-data (ewoc-locate vc-ewoc)))) | |
571 (if (vc-dir-fileinfo->directory data) | |
572 ;; It's a directory, mark child files. | |
573 (let ((crt (ewoc-locate vc-ewoc))) | |
574 (unless (vc-dir-children-marked-p crt) | |
575 (while (setq crt (ewoc-next vc-ewoc crt)) | |
576 (let ((crt-data (ewoc-data crt))) | |
577 (unless (vc-dir-fileinfo->directory crt-data) | |
578 (setf (vc-dir-fileinfo->marked crt-data) t) | |
579 (ewoc-invalidate vc-ewoc crt)))))) | |
580 ;; It's a file | |
581 (let ((state (vc-dir-fileinfo->state data)) | |
582 (crt (ewoc-nth vc-ewoc 0))) | |
583 (while crt | |
584 (let ((crt-data (ewoc-data crt))) | |
585 (when (and (not (vc-dir-fileinfo->marked crt-data)) | |
586 (eq (vc-dir-fileinfo->state crt-data) state) | |
587 (not (vc-dir-fileinfo->directory crt-data))) | |
588 (vc-dir-mark-file crt))) | |
589 (setq crt (ewoc-next vc-ewoc crt)))))))) | |
590 | |
591 (defun vc-dir-unmark-file () | |
592 ;; Unmark the current file and move to the next line. | |
593 (let* ((crt (ewoc-locate vc-ewoc)) | |
594 (file (ewoc-data crt))) | |
595 (setf (vc-dir-fileinfo->marked file) nil) | |
596 (ewoc-invalidate vc-ewoc crt) | |
597 (unless (mouse-event-p last-command-event) | |
598 (vc-dir-next-line 1)))) | |
599 | |
600 (defun vc-dir-unmark () | |
601 "Unmark the current file or all files in the region. | |
602 If the region is active, unmark all the files in the region. | |
603 Otherwise mark the file on the current line and move to the next | |
604 line." | |
605 (interactive) | |
606 (vc-dir-mark-unmark 'vc-dir-unmark-file)) | |
607 | |
608 (defun vc-dir-unmark-file-up () | |
609 "Move to the previous line and unmark the file." | |
610 (interactive) | |
611 ;; If we're on the first line, we won't move up, but we will still | |
612 ;; remove the mark. This seems a bit odd but it is what buffer-menu | |
613 ;; does. | |
614 (let* ((prev (ewoc-goto-prev vc-ewoc 1)) | |
615 (file (ewoc-data prev))) | |
616 (setf (vc-dir-fileinfo->marked file) nil) | |
617 (ewoc-invalidate vc-ewoc prev) | |
618 (vc-dir-move-to-goal-column))) | |
619 | |
620 (defun vc-dir-unmark-all-files (arg) | |
621 "Unmark all files with the same state as the current one. | |
622 With a prefix argument unmark all files. | |
623 If the current entry is a directory, unmark all the child files. | |
624 | |
625 The commands operate on files that are on the same state. | |
626 This command is intended to make it easy to deselect all files | |
627 that share the same state." | |
628 (interactive "P") | |
629 (if arg | |
630 (ewoc-map | |
631 (lambda (filearg) | |
632 (when (vc-dir-fileinfo->marked filearg) | |
633 (setf (vc-dir-fileinfo->marked filearg) nil) | |
634 t)) | |
635 vc-ewoc) | |
636 (let* ((crt (ewoc-locate vc-ewoc)) | |
637 (data (ewoc-data crt))) | |
638 (if (vc-dir-fileinfo->directory data) | |
639 ;; It's a directory, unmark child files. | |
640 (while (setq crt (ewoc-next vc-ewoc crt)) | |
641 (let ((crt-data (ewoc-data crt))) | |
642 (unless (vc-dir-fileinfo->directory crt-data) | |
643 (setf (vc-dir-fileinfo->marked crt-data) nil) | |
644 (ewoc-invalidate vc-ewoc crt)))) | |
645 ;; It's a file | |
646 (let ((crt-state (vc-dir-fileinfo->state (ewoc-data crt)))) | |
647 (ewoc-map | |
648 (lambda (filearg) | |
649 (when (and (vc-dir-fileinfo->marked filearg) | |
650 (eq (vc-dir-fileinfo->state filearg) crt-state)) | |
651 (setf (vc-dir-fileinfo->marked filearg) nil) | |
652 t)) | |
653 vc-ewoc)))))) | |
654 | |
655 (defun vc-dir-toggle-mark-file () | |
656 (let* ((crt (ewoc-locate vc-ewoc)) | |
657 (file (ewoc-data crt))) | |
658 (if (vc-dir-fileinfo->marked file) | |
659 (vc-dir-unmark-file) | |
660 (vc-dir-mark-file)))) | |
661 | |
662 (defun vc-dir-toggle-mark (e) | |
663 (interactive "e") | |
664 (vc-at-event e (vc-dir-mark-unmark 'vc-dir-toggle-mark-file))) | |
665 | |
666 (defun vc-dir-delete-file () | |
667 "Delete the marked files, or the current file if no marks." | |
668 (interactive) | |
669 (mapc 'vc-delete-file (or (vc-dir-marked-files) | |
670 (list (vc-dir-current-file))))) | |
671 | |
672 (defun vc-dir-find-file () | |
673 "Find the file on the current line." | |
674 (interactive) | |
675 (find-file (vc-dir-current-file))) | |
676 | |
677 (defun vc-dir-find-file-other-window () | |
678 "Find the file on the current line, in another window." | |
679 (interactive) | |
680 (find-file-other-window (vc-dir-current-file))) | |
681 | |
682 (defun vc-dir-current-file () | |
683 (let ((node (ewoc-locate vc-ewoc))) | |
684 (unless node | |
685 (error "No file available")) | |
686 (expand-file-name (vc-dir-fileinfo->name (ewoc-data node))))) | |
687 | |
688 (defun vc-dir-marked-files () | |
689 "Return the list of marked files." | |
690 (mapcar | |
691 (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) | |
692 (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) | |
693 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
694 (defun vc-dir-marked-only-files-and-states () |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
695 "Return the list of conses (FILE . STATE) for the marked files. |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
696 For marked directories return the corresponding conses for the |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
697 child files." |
96203 | 698 (let ((crt (ewoc-nth vc-ewoc 0)) |
699 result) | |
700 (while crt | |
701 (let ((crt-data (ewoc-data crt))) | |
702 (if (vc-dir-fileinfo->marked crt-data) | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
703 ;; FIXME: use vc-dir-child-files-and-states here instead of duplicating it. |
96203 | 704 (if (vc-dir-fileinfo->directory crt-data) |
705 (let* ((dir (vc-dir-fileinfo->directory crt-data)) | |
706 (dirlen (length dir)) | |
707 data) | |
708 (while | |
709 (and (setq crt (ewoc-next vc-ewoc crt)) | |
710 (vc-string-prefix-p dir | |
711 (progn | |
712 (setq data (ewoc-data crt)) | |
713 (vc-dir-node-directory crt)))) | |
714 (unless (vc-dir-fileinfo->directory data) | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
715 (push |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
716 (cons (expand-file-name (vc-dir-fileinfo->name data)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
717 (vc-dir-fileinfo->state data)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
718 result)))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
719 (push (cons (expand-file-name (vc-dir-fileinfo->name crt-data)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
720 (vc-dir-fileinfo->state crt-data)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
721 result) |
96203 | 722 (setq crt (ewoc-next vc-ewoc crt))) |
723 (setq crt (ewoc-next vc-ewoc crt))))) | |
724 result)) | |
725 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
726 (defun vc-dir-child-files-and-states () |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
727 "Return the list of conses (FILE . STATE) for child files of the current entry if it's a directory. |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
728 If it is a file, return the corresponding cons for the file itself." |
96203 | 729 (let* ((crt (ewoc-locate vc-ewoc)) |
730 (crt-data (ewoc-data crt)) | |
731 result) | |
732 (if (vc-dir-fileinfo->directory crt-data) | |
733 (let* ((dir (vc-dir-fileinfo->directory crt-data)) | |
734 (dirlen (length dir)) | |
735 data) | |
736 (while | |
737 (and (setq crt (ewoc-next vc-ewoc crt)) | |
738 (vc-string-prefix-p dir (progn | |
739 (setq data (ewoc-data crt)) | |
740 (vc-dir-node-directory crt)))) | |
741 (unless (vc-dir-fileinfo->directory data) | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
742 (push |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
743 (cons (expand-file-name (vc-dir-fileinfo->name data)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
744 (vc-dir-fileinfo->state data)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
745 result)))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
746 (push |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
747 (cons (expand-file-name (vc-dir-fileinfo->name crt-data)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
748 (vc-dir-fileinfo->state crt-data)) result)) |
96203 | 749 result)) |
750 | |
751 (defun vc-dir-resynch-file (&optional fname) | |
752 "Update the entries for FILE in any directory buffers that list it." | |
753 (let ((file (or fname (expand-file-name buffer-file-name)))) | |
754 (if (file-directory-p file) | |
755 ;; FIXME: Maybe this should never happen? | |
756 ;; FIXME: But it is useful to update the state of a directory | |
757 ;; (more precisely the files in the directory) after some VC | |
758 ;; operations. | |
759 nil | |
760 (let ((found-vc-dir-buf nil)) | |
761 (save-excursion | |
762 (dolist (status-buf (buffer-list)) | |
763 (set-buffer status-buf) | |
764 ;; look for a vc-dir buffer that might show this file. | |
765 (when (derived-mode-p 'vc-dir-mode) | |
766 (setq found-vc-dir-buf t) | |
767 (let ((ddir (expand-file-name default-directory))) | |
768 (when (vc-string-prefix-p ddir file) | |
769 (let* | |
770 ;; FIXME: Any reason we don't use file-relative-name? | |
771 ((file-short (substring file (length ddir))) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
772 (state (vc-call-backend vc-dir-backend 'state file)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
773 (extra (vc-call-backend vc-dir-backend |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
774 'status-fileinfo-extra file)) |
96203 | 775 (entry |
776 (list file-short state extra))) | |
777 (vc-dir-update (list entry) status-buf)))))) | |
778 ;; We didn't find any vc-dir buffers, remove the hook, it is | |
779 ;; not needed. | |
780 (unless found-vc-dir-buf | |
781 (remove-hook 'after-save-hook 'vc-dir-resynch-file))))))) | |
782 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
783 (defvar use-vc-backend) ;; dynamically bound |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
784 |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
785 (define-derived-mode vc-dir-mode special-mode "VC dir" |
96203 | 786 "Major mode for dispatcher directory buffers. |
787 Marking/Unmarking key bindings and actions: | |
788 m - marks a file/directory or if the region is active, mark all the files | |
789 in region. | |
790 Restrictions: - a file cannot be marked if any parent directory is marked | |
791 - a directory cannot be marked if any child file or | |
792 directory is marked | |
793 u - marks a file/directory or if the region is active, unmark all the files | |
794 in region. | |
795 M - if the cursor is on a file: mark all the files with the same state as | |
796 the current file | |
797 - if the cursor is on a directory: mark all child files | |
798 - with a prefix argument: mark all files | |
799 U - if the cursor is on a file: unmark all the files with the same state | |
800 as the current file | |
801 - if the cursor is on a directory: unmark all child files | |
802 - with a prefix argument: unmark all files | |
803 | |
804 | |
805 \\{vc-dir-mode-map}" | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
806 (set (make-local-variable 'vc-dir-backend) use-vc-backend) |
96203 | 807 (setq buffer-read-only t) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
808 (when (boundp 'tool-bar-map) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
809 (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)) |
96203 | 810 (let ((buffer-read-only nil)) |
811 (erase-buffer) | |
812 (set (make-local-variable 'vc-dir-process-buffer) nil) | |
813 (set (make-local-variable 'vc-ewoc) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
814 (ewoc-create #'vc-dir-status-printer |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
815 (vc-dir-headers vc-dir-backend default-directory))) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
816 (set (make-local-variable 'revert-buffer-function) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
817 'vc-dir-revert-buffer-function) |
96203 | 818 (add-hook 'after-save-hook 'vc-dir-resynch-file) |
819 ;; Make sure that if the directory buffer is killed, the update | |
820 ;; process running in the background is also killed. | |
821 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
822 (vc-dir-refresh))) |
96203 | 823 |
824 (defun vc-dir-headers (backend dir) | |
825 "Display the headers in the *VC dir* buffer. | |
826 It calls the `status-extra-headers' backend method to display backend | |
827 specific headers." | |
828 (concat | |
829 (propertize "VC backend : " 'face 'font-lock-type-face) | |
830 (propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face) | |
831 (propertize "Working dir: " 'face 'font-lock-type-face) | |
832 (propertize (format "%s\n" dir) 'face 'font-lock-variable-name-face) | |
833 (vc-call-backend backend 'status-extra-headers dir) | |
834 "\n")) | |
835 | |
836 (defun vc-dir-refresh-files (files default-state) | |
837 "Refresh some files in the *VC-dir* buffer." | |
838 (let ((def-dir default-directory) | |
839 (backend vc-dir-backend)) | |
840 (vc-set-mode-line-busy-indicator) | |
841 ;; Call the `dir-status-file' backend function. | |
842 ;; `dir-status-file' is supposed to be asynchronous. | |
843 ;; It should compute the results, and then call the function | |
844 ;; passed as an argument in order to update the vc-dir buffer | |
845 ;; with the results. | |
846 (unless (buffer-live-p vc-dir-process-buffer) | |
847 (setq vc-dir-process-buffer | |
848 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) | |
849 (lexical-let ((buffer (current-buffer))) | |
850 (with-current-buffer vc-dir-process-buffer | |
851 (cd def-dir) | |
852 (erase-buffer) | |
853 (vc-call-backend | |
854 backend 'dir-status-files def-dir files default-state | |
855 (lambda (entries &optional more-to-come) | |
856 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. | |
857 ;; If MORE-TO-COME is true, then more updates will come from | |
858 ;; the asynchronous process. | |
859 (with-current-buffer buffer | |
860 (vc-dir-update entries buffer) | |
861 (unless more-to-come | |
862 (setq mode-line-process nil) | |
863 ;; Remove the ones that haven't been updated at all. | |
864 ;; Those not-updated are those whose state is nil because the | |
865 ;; file/dir doesn't exist and isn't versioned. | |
866 (ewoc-filter vc-ewoc | |
867 (lambda (info) | |
868 ;; The state for directory entries might | |
869 ;; have been changed to 'up-to-date, | |
870 ;; reset it, othewise it will be removed when doing 'x' | |
871 ;; next time. | |
872 ;; FIXME: There should be a more elegant way to do this. | |
873 (when (and (vc-dir-fileinfo->directory info) | |
874 (eq (vc-dir-fileinfo->state info) | |
875 'up-to-date)) | |
876 (setf (vc-dir-fileinfo->state info) nil)) | |
877 | |
878 (not (vc-dir-fileinfo->needs-update info)))))))))))) | |
879 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
880 (defun vc-dir-revert-buffer-function (&optional ignore-auto noconfirm) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
881 (vc-dir-refresh)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
882 |
96203 | 883 (defun vc-dir-refresh () |
884 "Refresh the contents of the *VC-dir* buffer. | |
885 Throw an error if another update process is in progress." | |
886 (interactive) | |
887 (if (vc-dir-busy) | |
888 (error "Another update process is in progress, cannot run two at a time") | |
889 (let ((def-dir default-directory) | |
890 (backend vc-dir-backend)) | |
891 (vc-set-mode-line-busy-indicator) | |
892 ;; Call the `dir-status' backend function. | |
893 ;; `dir-status' is supposed to be asynchronous. | |
894 ;; It should compute the results, and then call the function | |
895 ;; passed as an argument in order to update the vc-dir buffer | |
896 ;; with the results. | |
897 | |
898 ;; Create a buffer that can be used by `dir-status' and call | |
899 ;; `dir-status' with this buffer as the current buffer. Use | |
900 ;; `vc-dir-process-buffer' to remember this buffer, so that | |
901 ;; it can be used later to kill the update process in case it | |
902 ;; takes too long. | |
903 (unless (buffer-live-p vc-dir-process-buffer) | |
904 (setq vc-dir-process-buffer | |
905 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) | |
906 ;; set the needs-update flag on all entries | |
907 (ewoc-map (lambda (info) (setf (vc-dir-fileinfo->needs-update info) t) nil) | |
908 vc-ewoc) | |
909 (lexical-let ((buffer (current-buffer))) | |
910 (with-current-buffer vc-dir-process-buffer | |
911 (cd def-dir) | |
912 (erase-buffer) | |
913 (vc-call-backend | |
914 backend 'dir-status def-dir | |
915 (lambda (entries &optional more-to-come) | |
916 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. | |
917 ;; If MORE-TO-COME is true, then more updates will come from | |
918 ;; the asynchronous process. | |
919 (with-current-buffer buffer | |
920 (vc-dir-update entries buffer) | |
921 (unless more-to-come | |
922 (let ((remaining | |
923 (ewoc-collect | |
924 vc-ewoc 'vc-dir-fileinfo->needs-update))) | |
925 (if remaining | |
926 (vc-dir-refresh-files | |
927 (mapcar 'vc-dir-fileinfo->name remaining) | |
928 'up-to-date) | |
929 (setq mode-line-process nil)))))))))))) | |
930 | |
931 (defun vc-dir-show-fileentry (file) | |
932 "Insert an entry for a specific file into the current *VC-dir* listing. | |
933 This is typically used if the file is up-to-date (or has been added | |
934 outside of VC) and one wants to do some operation on it." | |
935 (interactive "fShow file: ") | |
936 (vc-dir-update (list (list (file-relative-name file) (vc-state file))) (current-buffer))) | |
937 | |
938 (defun vc-dir-hide-up-to-date () | |
939 "Hide up-to-date items from display." | |
940 (interactive) | |
941 (ewoc-filter | |
942 vc-ewoc | |
943 (lambda (crt) (not (eq (vc-dir-fileinfo->state crt) 'up-to-date))))) | |
944 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
945 (defun vc-dir-status-printer (fileentry) |
96203 | 946 (vc-call-backend vc-dir-backend 'status-printer fileentry)) |
947 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
948 (defun vc-dir-deduce-fileset (&optional state-model-only-files) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
949 (let ((marked (vc-dir-marked-files)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
950 files |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
951 only-files-list |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
952 state |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
953 model) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
954 (if marked |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
955 (progn |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
956 (setq files marked) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
957 (when state-model-only-files |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
958 (setq only-files-list (vc-dir-marked-only-files-and-states)))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
959 (let ((crt (vc-dir-current-file))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
960 (setq files (list crt)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
961 (when state-model-only-files |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
962 (setq only-files-list (vc-dir-child-files-and-states))))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
963 |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
964 (when state-model-only-files |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
965 (setq state (cdar only-files-list)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
966 ;; Check that all files are in a consistent state, since we use that |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
967 ;; state to decide which operation to perform. |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
968 (dolist (crt (cdr only-files-list)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
969 (unless (vc-compatible-state (cdr crt) state) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
970 (error "%s:%s clashes with %s:%s" |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
971 (car crt) (cdr crt) (caar only-files-list) state))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
972 (setq only-files-list (mapcar 'car only-files-list)) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
973 (when (and state (not (eq state 'unregistered))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
974 (setq model (vc-checkout-model vc-dir-backend only-files-list)))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
975 (list vc-dir-backend files only-files-list state model))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
976 |
96203 | 977 ;;;###autoload |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
978 (defun vc-dir (dir backend) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
979 "Show the VC status for DIR. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
980 With a prefix argument ask what VC backend to use." |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
981 (interactive |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
982 (list |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
983 (read-file-name "VC status for directory: " |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
984 default-directory default-directory t) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
985 (if current-prefix-arg |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
986 (intern |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
987 (completing-read |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
988 "Use VC backend: " |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
989 (mapcar (lambda (b) (list (symbol-name b))) vc-handled-backends) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
990 nil t nil nil)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
991 (vc-responsible-backend default-directory)))) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
992 (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
993 (if (derived-mode-p 'vc-dir-mode) |
96203 | 994 (vc-dir-refresh) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
995 ;; FIXME: find a better way to pass the backend to `vc-dir-mode'. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
996 (let ((use-vc-backend backend)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
997 (vc-dir-mode)))) |
96203 | 998 |
999 (defun vc-default-status-extra-headers (backend dir) | |
1000 ;; Be loud by default to remind people to add code to display | |
1001 ;; backend specific headers. | |
1002 ;; XXX: change this to return nil before the release. | |
1003 (concat | |
1004 (propertize "Extra : " 'face 'font-lock-type-face) | |
1005 (propertize "Please add backend specific headers here. It's easy!" | |
1006 'face 'font-lock-warning-face))) | |
1007 | |
1008 (defun vc-default-status-printer (backend fileentry) | |
1009 "Pretty print FILEENTRY." | |
1010 ;; If you change the layout here, change vc-dir-move-to-goal-column. | |
1011 (let* ((isdir (vc-dir-fileinfo->directory fileentry)) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1012 (state (if isdir "" (vc-dir-fileinfo->state fileentry))) |
96203 | 1013 (filename (vc-dir-fileinfo->name fileentry))) |
1014 (insert | |
1015 (propertize | |
1016 (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? )) | |
1017 'face 'font-lock-type-face) | |
1018 " " | |
1019 (propertize | |
1020 (format "%-20s" state) | |
1021 'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face) | |
1022 ((memq state '(missing conflict)) 'font-lock-warning-face) | |
1023 (t 'font-lock-variable-name-face)) | |
1024 'mouse-face 'highlight) | |
1025 " " | |
1026 (propertize | |
1027 (format "%s" filename) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1028 'face |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1029 (if isdir 'font-lock-comment-delimiter-face 'font-lock-function-name-face) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1030 'help-echo |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1031 (if isdir |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1032 "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu" |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1033 "File\nmouse-3: Pop-up menu") |
96203 | 1034 'mouse-face 'highlight)))) |
1035 | |
1036 (defun vc-default-extra-status-menu (backend) | |
1037 nil) | |
1038 | |
1039 (defun vc-default-status-fileinfo-extra (backend file) | |
1040 "Default absence of extra information returned for a file." | |
1041 nil) | |
1042 | |
1043 (provide 'vc-dir) | |
1044 | |
96204 | 1045 ;; arch-tag: 0274a2e3-e8e9-4b1a-a73c-e8b9129d5d15 |
96203 | 1046 ;;; vc-dir.el ends here |