Mercurial > emacs
annotate lisp/vc-dir.el @ 96727:a7401c5a0faa
* sysdep.c: Remove code depending on NEED_PTEM_H, unused. Remove
if 0-ed code.
(baud_convert): Don't depend on BAUD_CONVERT, all definitions the
were the same as the default.
* s/vms.h (BAUD_CONVERT): Remove, same as the default.
Remove boilerplate comments.
* s/hpux10-20.h (BAUD_CONVERT): Remove, same as the default.
(HAVE_SYSVIPC): Remove, unused.
(LD_SWITCH_SYSTEM_TEMACS): Simplify, hp9000s700 not supported anymore.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Wed, 16 Jul 2008 07:45:52 +0000 |
parents | d39625535543 |
children | 938dd02137bc |
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: | |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
30 ;; |
96203 | 31 ;; Alexandre Julliard <julliard@winehq.org> |
32 ;; Stefan Monnier <monnier@iro.umontreal.ca> | |
33 ;; Tom Tromey <tromey@redhat.com> | |
34 | |
35 ;;; Commentary: | |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
36 ;; |
96203 | 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] '("--")) | |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
159 (define-key map [qr] |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
160 '(menu-item "Query Replace in Files" vc-dir-query-replace-regexp |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
161 :help "Replace a string in the marked files")) |
96203 | 162 (define-key map [open-other] |
163 '(menu-item "Open in other window" vc-dir-find-file-other-window | |
164 :help "Find the file on the current line, in another window")) | |
165 (define-key map [open] | |
166 '(menu-item "Open file" vc-dir-find-file | |
167 :help "Find the file on the current line")) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
168 (define-key map [sepvcdet] '("--")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
169 ;; 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
|
170 ;; ("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
|
171 (define-key map [ins] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
172 '(menu-item "Show File" vc-dir-show-fileentry |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
173 :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
|
174 (define-key map [annotate] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
175 '(menu-item "Annotate" vc-annotate |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
176 :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
|
177 (define-key map [diff] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
178 '(menu-item "Compare with Base Version" vc-diff |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
179 :help "Compare file set with the base version")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
180 (define-key map [log] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
181 '(menu-item "Show history" vc-print-log |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
182 :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
|
183 ;; VC commands. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
184 (define-key map [sepvccmd] '("--")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
185 (define-key map [update] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
186 '(menu-item "Update to latest version" vc-update |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
187 :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
|
188 (define-key map [revert] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
189 '(menu-item "Revert to base version" vc-revert |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
190 :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
|
191 (define-key map [next-action] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
192 ;; FIXME: This really really really needs a better name! |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
193 ;; And a key binding too. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
194 '(menu-item "Check In/Out" vc-next-action |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
195 :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
|
196 (define-key map [register] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
197 '(menu-item "Register" vc-register |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
198 :help "Register file set into the version control system")) |
96203 | 199 map) |
200 "Menu for dispatcher status") | |
201 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
202 ;; 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
|
203 ;; vc-dir-menu-map. |
96203 | 204 (defun vc-dir-menu-map-filter (orig-binding) |
205 (when (and (symbolp orig-binding) (fboundp orig-binding)) | |
206 (setq orig-binding (indirect-function orig-binding))) | |
207 (let ((ext-binding | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
208 (when (derived-mode-p 'vc-dir-mode) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
209 (vc-call-backend vc-dir-backend 'extra-status-menu)))) |
96203 | 210 (if (null ext-binding) |
211 orig-binding | |
212 (append orig-binding | |
213 '("----") | |
214 ext-binding)))) | |
215 | |
216 (defvar vc-dir-mode-map | |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
217 (let ((map (make-sparse-keymap))) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
218 ;; VC commands |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
219 (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
|
220 (define-key map "=" 'vc-diff) ;; C-x v = |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
221 (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
|
222 (define-key map "+" 'vc-update) ;; C-x v + |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
223 (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
|
224 ;; More confusing than helpful, probably |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
225 ;;(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
|
226 ;;(define-key map "A" 'vc-annotate) ;; g is taken by dispatcher refresh |
96203 | 227 ;; Marking. |
228 (define-key map "m" 'vc-dir-mark) | |
229 (define-key map "M" 'vc-dir-mark-all-files) | |
230 (define-key map "u" 'vc-dir-unmark) | |
231 (define-key map "U" 'vc-dir-unmark-all-files) | |
232 (define-key map "\C-?" 'vc-dir-unmark-file-up) | |
233 (define-key map "\M-\C-?" 'vc-dir-unmark-all-files) | |
234 ;; Movement. | |
235 (define-key map "n" 'vc-dir-next-line) | |
236 (define-key map " " 'vc-dir-next-line) | |
237 (define-key map "\t" 'vc-dir-next-directory) | |
238 (define-key map "p" 'vc-dir-previous-line) | |
239 (define-key map [backtab] 'vc-dir-previous-directory) | |
240 ;;; Rebind paragraph-movement commands. | |
241 (define-key map "\M-}" 'vc-dir-next-directory) | |
242 (define-key map "\M-{" 'vc-dir-previous-directory) | |
243 (define-key map [C-down] 'vc-dir-next-directory) | |
244 (define-key map [C-up] 'vc-dir-previous-directory) | |
245 ;; The remainder. | |
246 (define-key map "f" 'vc-dir-find-file) | |
247 (define-key map "\C-m" 'vc-dir-find-file) | |
248 (define-key map "o" 'vc-dir-find-file-other-window) | |
249 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) | |
250 (define-key map [down-mouse-3] 'vc-dir-menu) | |
251 (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
|
252 (define-key map "x" 'vc-dir-hide-up-to-date) |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
253 (define-key map "Q" 'vc-dir-query-replace-regexp) |
96203 | 254 |
255 ;; Hook up the menu. | |
256 (define-key map [menu-bar vc-dir-mode] | |
257 `(menu-item | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
258 ;; 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
|
259 ;; vc-dir-menu-map. |
96203 | 260 "VC-dir" ,vc-dir-menu-map :filter vc-dir-menu-map-filter)) |
261 map) | |
262 "Keymap for directory buffer.") | |
263 | |
264 (defmacro vc-at-event (event &rest body) | |
265 "Evaluate `body' with point located at event-start of `event'. | |
266 If `body' uses `event', it should be a variable, | |
267 otherwise it will be evaluated twice." | |
268 (let ((posn (make-symbol "vc-at-event-posn"))) | |
269 `(let ((,posn (event-start ,event))) | |
270 (save-excursion | |
271 (set-buffer (window-buffer (posn-window ,posn))) | |
272 (goto-char (posn-point ,posn)) | |
273 ,@body)))) | |
274 | |
275 (defun vc-dir-menu (e) | |
276 "Popup the dispatcher status menu." | |
277 (interactive "e") | |
278 (vc-at-event e (popup-menu vc-dir-menu-map e))) | |
279 | |
280 (defvar vc-dir-tool-bar-map | |
281 (let ((map (make-sparse-keymap))) | |
282 (tool-bar-local-item-from-menu 'vc-dir-find-file "open" | |
283 map vc-dir-mode-map) | |
284 (tool-bar-local-item "bookmark_add" | |
285 'vc-dir-toggle-mark 'vc-dir-toggle-mark map | |
286 :help "Toggle mark on current item") | |
287 (tool-bar-local-item-from-menu 'vc-dir-previous-line "left-arrow" | |
288 map vc-dir-mode-map | |
289 :rtl "right-arrow") | |
290 (tool-bar-local-item-from-menu 'vc-dir-next-line "right-arrow" | |
291 map vc-dir-mode-map | |
292 :rtl "left-arrow") | |
293 (tool-bar-local-item-from-menu 'vc-print-log "info" | |
294 map vc-dir-mode-map) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
295 (tool-bar-local-item-from-menu 'revert-buffer "refresh" |
96203 | 296 map vc-dir-mode-map) |
297 (tool-bar-local-item-from-menu 'nonincremental-search-forward | |
298 "search" map) | |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
299 (tool-bar-local-item-from-menu 'vc-dir-query-replace-regexp |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
300 "search-replace" map vc-dir-mode-map) |
96203 | 301 (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel" |
302 map vc-dir-mode-map) | |
303 (tool-bar-local-item-from-menu 'quit-window "exit" | |
304 map vc-dir-mode-map) | |
305 map)) | |
306 | |
307 (defun vc-dir-node-directory (node) | |
308 ;; Compute the directory for NODE. | |
309 ;; If it's a directory node, get it from the the node. | |
310 (let ((data (ewoc-data node))) | |
311 (or (vc-dir-fileinfo->directory data) | |
312 ;; Otherwise compute it from the file name. | |
313 (file-name-directory | |
314 (expand-file-name | |
315 (vc-dir-fileinfo->name data)))))) | |
316 | |
317 (defun vc-dir-update (entries buffer &optional noinsert) | |
318 "Update BUFFER's ewoc from the list of ENTRIES. | |
319 If NOINSERT, ignore elements on ENTRIES which are not in the ewoc." | |
320 ;; Add ENTRIES to the vc-dir buffer BUFFER. | |
321 (with-current-buffer buffer | |
322 ;; Insert the entries sorted by name into the ewoc. | |
323 ;; We assume the ewoc is sorted too, which should be the | |
324 ;; case if we always add entries with vc-dir-update. | |
325 (setq entries | |
326 ;; Sort: first files and then subdirectories. | |
327 ;; XXX: this is VERY inefficient, it computes the directory | |
328 ;; names too many times | |
329 (sort entries | |
330 (lambda (entry1 entry2) | |
331 (let ((dir1 (file-name-directory (expand-file-name (car entry1)))) | |
332 (dir2 (file-name-directory (expand-file-name (car entry2))))) | |
333 (cond | |
334 ((string< dir1 dir2) t) | |
335 ((not (string= dir1 dir2)) nil) | |
336 ((string< (car entry1) (car entry2)))))))) | |
337 ;; Insert directory entries in the right places. | |
338 (let ((entry (car entries)) | |
339 (node (ewoc-nth vc-ewoc 0))) | |
340 ;; Insert . if it is not present. | |
341 (unless node | |
342 (let ((rd (file-relative-name default-directory))) | |
343 (ewoc-enter-last | |
344 vc-ewoc (vc-dir-create-fileinfo | |
345 rd nil nil nil (expand-file-name default-directory)))) | |
346 (setq node (ewoc-nth vc-ewoc 0))) | |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
347 |
96203 | 348 (while (and entry node) |
349 (let* ((entryfile (car entry)) | |
350 (entrydir (file-name-directory (expand-file-name entryfile))) | |
351 (nodedir (vc-dir-node-directory node))) | |
352 (cond | |
353 ;; First try to find the directory. | |
354 ((string-lessp nodedir entrydir) | |
355 (setq node (ewoc-next vc-ewoc node))) | |
356 ((string-equal nodedir entrydir) | |
357 ;; Found the directory, find the place for the file name. | |
358 (let ((nodefile (vc-dir-fileinfo->name (ewoc-data node)))) | |
359 (cond | |
360 ((string-lessp nodefile entryfile) | |
361 (setq node (ewoc-next vc-ewoc node))) | |
362 ((string-equal nodefile entryfile) | |
363 (setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry)) | |
364 (setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry)) | |
365 (setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil) | |
366 (ewoc-invalidate vc-ewoc node) | |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
367 (setq entries (cdr entries)) |
96203 | 368 (setq entry (car entries)) |
369 (setq node (ewoc-next vc-ewoc node))) | |
370 (t | |
371 (ewoc-enter-before vc-ewoc node | |
372 (apply 'vc-dir-create-fileinfo entry)) | |
373 (setq entries (cdr entries)) | |
374 (setq entry (car entries)))))) | |
375 (t | |
376 ;; We might need to insert a directory node if the | |
377 ;; previous node was in a different directory. | |
378 (let* ((rd (file-relative-name entrydir)) | |
379 (prev-node (ewoc-prev vc-ewoc node)) | |
380 (prev-dir (vc-dir-node-directory prev-node))) | |
381 (unless (string-equal entrydir prev-dir) | |
382 (ewoc-enter-before | |
383 vc-ewoc node (vc-dir-create-fileinfo rd nil nil nil entrydir)))) | |
384 ;; Now insert the node itself. | |
385 (ewoc-enter-before vc-ewoc node | |
386 (apply 'vc-dir-create-fileinfo entry)) | |
387 (setq entries (cdr entries) entry (car entries)))))) | |
388 ;; We're past the last node, all remaining entries go to the end. | |
389 (unless (or node noinsert) | |
390 (let ((lastdir (vc-dir-node-directory (ewoc-nth vc-ewoc -1)))) | |
391 (dolist (entry entries) | |
392 (let ((entrydir (file-name-directory (expand-file-name (car entry))))) | |
393 ;; Insert a directory node if needed. | |
394 (unless (string-equal lastdir entrydir) | |
395 (setq lastdir entrydir) | |
396 (let ((rd (file-relative-name entrydir))) | |
397 (ewoc-enter-last | |
398 vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir)))) | |
399 ;; Now insert the node itself. | |
400 (ewoc-enter-last vc-ewoc | |
401 (apply 'vc-dir-create-fileinfo entry))))))))) | |
402 | |
403 (defun vc-dir-busy () | |
404 (and (buffer-live-p vc-dir-process-buffer) | |
405 (get-buffer-process vc-dir-process-buffer))) | |
406 | |
407 (defun vc-dir-kill-dir-status-process () | |
408 "Kill the temporary buffer and associated process." | |
409 (interactive) | |
410 (when (buffer-live-p vc-dir-process-buffer) | |
411 (let ((proc (get-buffer-process vc-dir-process-buffer))) | |
412 (when proc (delete-process proc)) | |
413 (setq vc-dir-process-buffer nil) | |
414 (setq mode-line-process nil)))) | |
415 | |
416 (defun vc-dir-kill-query () | |
417 ;; Make sure that when the status buffer is killed the update | |
418 ;; process running in background is also killed. | |
419 (if (vc-dir-busy) | |
420 (when (y-or-n-p "Status update process running, really kill status buffer? ") | |
421 (vc-dir-kill-dir-status-process) | |
422 t) | |
423 t)) | |
424 | |
425 (defun vc-dir-next-line (arg) | |
426 "Go to the next line. | |
427 If a prefix argument is given, move by that many lines." | |
428 (interactive "p") | |
429 (with-no-warnings | |
430 (ewoc-goto-next vc-ewoc arg) | |
431 (vc-dir-move-to-goal-column))) | |
432 | |
433 (defun vc-dir-previous-line (arg) | |
434 "Go to the previous line. | |
435 If a prefix argument is given, move by that many lines." | |
436 (interactive "p") | |
437 (ewoc-goto-prev vc-ewoc arg) | |
438 (vc-dir-move-to-goal-column)) | |
439 | |
440 (defun vc-dir-next-directory () | |
441 "Go to the next directory." | |
442 (interactive) | |
443 (let ((orig (point))) | |
444 (if | |
445 (catch 'foundit | |
446 (while t | |
447 (let* ((next (ewoc-next vc-ewoc (ewoc-locate vc-ewoc)))) | |
448 (cond ((not next) | |
449 (throw 'foundit t)) | |
450 (t | |
451 (progn | |
452 (ewoc-goto-node vc-ewoc next) | |
453 (vc-dir-move-to-goal-column) | |
454 (if (vc-dir-fileinfo->directory (ewoc-data next)) | |
455 (throw 'foundit nil)))))))) | |
456 (goto-char orig)))) | |
457 | |
458 (defun vc-dir-previous-directory () | |
459 "Go to the previous directory." | |
460 (interactive) | |
461 (let ((orig (point))) | |
462 (if | |
463 (catch 'foundit | |
464 (while t | |
465 (let* ((prev (ewoc-prev vc-ewoc (ewoc-locate vc-ewoc)))) | |
466 (cond ((not prev) | |
467 (throw 'foundit t)) | |
468 (t | |
469 (progn | |
470 (ewoc-goto-node vc-ewoc prev) | |
471 (vc-dir-move-to-goal-column) | |
472 (if (vc-dir-fileinfo->directory (ewoc-data prev)) | |
473 (throw 'foundit nil)))))))) | |
474 (goto-char orig)))) | |
475 | |
476 (defun vc-dir-mark-unmark (mark-unmark-function) | |
477 (if (use-region-p) | |
478 (let ((firstl (line-number-at-pos (region-beginning))) | |
479 (lastl (line-number-at-pos (region-end)))) | |
480 (save-excursion | |
481 (goto-char (region-beginning)) | |
482 (while (<= (line-number-at-pos) lastl) | |
483 (funcall mark-unmark-function)))) | |
484 (funcall mark-unmark-function))) | |
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 | |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
682 (defun vc-dir-query-replace-regexp (from to &optional delimited) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
683 "Do `query-replace-regexp' of FROM with TO, on all marked files. |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
684 If a directory is marked, then use the files displayed for that directory. |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
685 Third arg DELIMITED (prefix arg) means replace only word-delimited matches. |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
686 If you exit (\\[keyboard-quit], RET or q), you can resume the query replace |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
687 with the command \\[tags-loop-continue]." |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
688 ;; FIXME: this is almost a copy of `dired-do-replace-regexp'. This |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
689 ;; should probably be made generic and used in both places instead of |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
690 ;; duplicating it here. |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
691 (interactive |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
692 (let ((common |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
693 (query-replace-read-args |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
694 "Query replace regexp in marked files" t t))) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
695 (list (nth 0 common) (nth 1 common) (nth 2 common)))) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
696 (dolist (file (mapcar 'car (vc-dir-marked-only-files-and-states))) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
697 (let ((buffer (get-file-buffer file))) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
698 (if (and buffer (with-current-buffer buffer |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
699 buffer-read-only)) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
700 (error "File `%s' is visited read-only" file)))) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
701 (tags-query-replace from to delimited |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
702 '(mapcar 'car (vc-dir-marked-only-files-and-states)))) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
703 |
96203 | 704 (defun vc-dir-current-file () |
705 (let ((node (ewoc-locate vc-ewoc))) | |
706 (unless node | |
707 (error "No file available")) | |
708 (expand-file-name (vc-dir-fileinfo->name (ewoc-data node))))) | |
709 | |
710 (defun vc-dir-marked-files () | |
711 "Return the list of marked files." | |
712 (mapcar | |
713 (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) | |
714 (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) | |
715 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
716 (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
|
717 "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
|
718 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
|
719 child files." |
96203 | 720 (let ((crt (ewoc-nth vc-ewoc 0)) |
721 result) | |
722 (while crt | |
723 (let ((crt-data (ewoc-data crt))) | |
724 (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
|
725 ;; FIXME: use vc-dir-child-files-and-states here instead of duplicating it. |
96203 | 726 (if (vc-dir-fileinfo->directory crt-data) |
727 (let* ((dir (vc-dir-fileinfo->directory crt-data)) | |
728 (dirlen (length dir)) | |
729 data) | |
730 (while | |
731 (and (setq crt (ewoc-next vc-ewoc crt)) | |
732 (vc-string-prefix-p dir | |
733 (progn | |
734 (setq data (ewoc-data crt)) | |
735 (vc-dir-node-directory crt)))) | |
736 (unless (vc-dir-fileinfo->directory data) | |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
737 (push |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
738 (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
|
739 (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
|
740 result)))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
741 (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
|
742 (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
|
743 result) |
96203 | 744 (setq crt (ewoc-next vc-ewoc crt))) |
745 (setq crt (ewoc-next vc-ewoc crt))))) | |
746 result)) | |
747 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
748 (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
|
749 "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
|
750 If it is a file, return the corresponding cons for the file itself." |
96203 | 751 (let* ((crt (ewoc-locate vc-ewoc)) |
752 (crt-data (ewoc-data crt)) | |
753 result) | |
754 (if (vc-dir-fileinfo->directory crt-data) | |
755 (let* ((dir (vc-dir-fileinfo->directory crt-data)) | |
756 (dirlen (length dir)) | |
757 data) | |
758 (while | |
759 (and (setq crt (ewoc-next vc-ewoc crt)) | |
760 (vc-string-prefix-p dir (progn | |
761 (setq data (ewoc-data crt)) | |
762 (vc-dir-node-directory crt)))) | |
763 (unless (vc-dir-fileinfo->directory data) | |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
764 (push |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
765 (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
|
766 (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
|
767 result)))) |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
768 (push |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
769 (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
|
770 (vc-dir-fileinfo->state crt-data)) result)) |
96203 | 771 result)) |
772 | |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
773 (defun vc-dir-recompute-file-state (fname def-dir) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
774 (let* ((file-short (file-relative-name fname def-dir)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
775 (state (vc-call-backend vc-dir-backend 'state fname)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
776 (extra (vc-call-backend vc-dir-backend |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
777 'status-fileinfo-extra fname))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
778 (list file-short state extra))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
779 |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
780 (defun vc-dir-find-child-files (dirname) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
781 ;; Give a DIRNAME string return the list of all child files shown in |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
782 ;; the current *vc-dir* buffer. |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
783 (let ((crt (ewoc-nth vc-ewoc 0)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
784 children |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
785 dname) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
786 ;; Find DIR |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
787 (while (and crt (not (vc-string-prefix-p |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
788 dirname (vc-dir-node-directory crt)))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
789 (setq crt (ewoc-next vc-ewoc crt))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
790 (while (and crt (vc-string-prefix-p |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
791 dirname |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
792 (setq dname (vc-dir-node-directory crt)))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
793 (let ((data (ewoc-data crt))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
794 (unless (vc-dir-fileinfo->directory data) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
795 (push (expand-file-name (vc-dir-fileinfo->name data)) children))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
796 (setq crt (ewoc-next vc-ewoc crt))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
797 children)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
798 |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
799 (defun vc-dir-resync-directory-files (dirname) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
800 ;; Update the entries for all the child files of DIRNAME shown in |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
801 ;; the current *vc-dir* buffer. |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
802 (let ((files (vc-dir-find-child-files dirname)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
803 (ddir (expand-file-name default-directory)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
804 fileentries) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
805 (when files |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
806 (dolist (crt files) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
807 (push (vc-dir-recompute-file-state crt ddir) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
808 fileentries)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
809 (vc-dir-update fileentries (current-buffer))))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
810 |
96203 | 811 (defun vc-dir-resynch-file (&optional fname) |
812 "Update the entries for FILE in any directory buffers that list it." | |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
813 (let ((file (or fname (expand-file-name buffer-file-name))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
814 (found-vc-dir-buf nil)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
815 (save-excursion |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
816 (dolist (status-buf (buffer-list)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
817 (set-buffer status-buf) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
818 ;; look for a vc-dir buffer that might show this file. |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
819 (when (derived-mode-p 'vc-dir-mode) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
820 (setq found-vc-dir-buf t) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
821 (let ((ddir (expand-file-name default-directory))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
822 (when (vc-string-prefix-p ddir file) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
823 (if (file-directory-p file) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
824 (vc-dir-resync-directory-files file) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
825 (vc-dir-update |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
826 (list (vc-dir-recompute-file-state file ddir)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
827 status-buf))))))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
828 ;; We didn't find any vc-dir buffers, remove the hook, it is |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
829 ;; not needed. |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
830 (unless found-vc-dir-buf |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
831 (remove-hook 'after-save-hook 'vc-dir-resynch-file)))) |
96203 | 832 |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
833 (defvar use-vc-backend) ;; dynamically bound |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
834 |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
835 (define-derived-mode vc-dir-mode special-mode "VC dir" |
96203 | 836 "Major mode for dispatcher directory buffers. |
837 Marking/Unmarking key bindings and actions: | |
838 m - marks a file/directory or if the region is active, mark all the files | |
839 in region. | |
840 Restrictions: - a file cannot be marked if any parent directory is marked | |
841 - a directory cannot be marked if any child file or | |
842 directory is marked | |
843 u - marks a file/directory or if the region is active, unmark all the files | |
844 in region. | |
845 M - if the cursor is on a file: mark all the files with the same state as | |
846 the current file | |
847 - if the cursor is on a directory: mark all child files | |
848 - with a prefix argument: mark all files | |
849 U - if the cursor is on a file: unmark all the files with the same state | |
850 as the current file | |
851 - if the cursor is on a directory: unmark all child files | |
852 - with a prefix argument: unmark all files | |
853 | |
854 | |
855 \\{vc-dir-mode-map}" | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
856 (set (make-local-variable 'vc-dir-backend) use-vc-backend) |
96203 | 857 (setq buffer-read-only t) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
858 (when (boundp 'tool-bar-map) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
859 (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)) |
96203 | 860 (let ((buffer-read-only nil)) |
861 (erase-buffer) | |
862 (set (make-local-variable 'vc-dir-process-buffer) nil) | |
863 (set (make-local-variable 'vc-ewoc) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
864 (ewoc-create #'vc-dir-status-printer |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
865 (vc-dir-headers vc-dir-backend default-directory))) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
866 (set (make-local-variable 'revert-buffer-function) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
867 'vc-dir-revert-buffer-function) |
96474
9a72b6660355
(vc-dir-mode): Set list-buffers-function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96411
diff
changeset
|
868 (set (make-local-variable 'list-buffers-directory) |
9a72b6660355
(vc-dir-mode): Set list-buffers-function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96411
diff
changeset
|
869 (expand-file-name default-directory)) |
96203 | 870 (add-hook 'after-save-hook 'vc-dir-resynch-file) |
871 ;; Make sure that if the directory buffer is killed, the update | |
872 ;; process running in the background is also killed. | |
873 (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
|
874 (vc-dir-refresh))) |
96203 | 875 |
876 (defun vc-dir-headers (backend dir) | |
877 "Display the headers in the *VC dir* buffer. | |
878 It calls the `status-extra-headers' backend method to display backend | |
879 specific headers." | |
880 (concat | |
881 (propertize "VC backend : " 'face 'font-lock-type-face) | |
882 (propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face) | |
883 (propertize "Working dir: " 'face 'font-lock-type-face) | |
884 (propertize (format "%s\n" dir) 'face 'font-lock-variable-name-face) | |
885 (vc-call-backend backend 'status-extra-headers dir) | |
886 "\n")) | |
887 | |
888 (defun vc-dir-refresh-files (files default-state) | |
889 "Refresh some files in the *VC-dir* buffer." | |
890 (let ((def-dir default-directory) | |
891 (backend vc-dir-backend)) | |
892 (vc-set-mode-line-busy-indicator) | |
893 ;; Call the `dir-status-file' backend function. | |
894 ;; `dir-status-file' is supposed to be asynchronous. | |
895 ;; It should compute the results, and then call the function | |
896 ;; passed as an argument in order to update the vc-dir buffer | |
897 ;; with the results. | |
898 (unless (buffer-live-p vc-dir-process-buffer) | |
899 (setq vc-dir-process-buffer | |
900 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) | |
901 (lexical-let ((buffer (current-buffer))) | |
902 (with-current-buffer vc-dir-process-buffer | |
903 (cd def-dir) | |
904 (erase-buffer) | |
905 (vc-call-backend | |
906 backend 'dir-status-files def-dir files default-state | |
907 (lambda (entries &optional more-to-come) | |
908 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. | |
909 ;; If MORE-TO-COME is true, then more updates will come from | |
910 ;; the asynchronous process. | |
911 (with-current-buffer buffer | |
912 (vc-dir-update entries buffer) | |
913 (unless more-to-come | |
914 (setq mode-line-process nil) | |
915 ;; Remove the ones that haven't been updated at all. | |
916 ;; Those not-updated are those whose state is nil because the | |
917 ;; file/dir doesn't exist and isn't versioned. | |
918 (ewoc-filter vc-ewoc | |
919 (lambda (info) | |
920 ;; The state for directory entries might | |
921 ;; have been changed to 'up-to-date, | |
922 ;; reset it, othewise it will be removed when doing 'x' | |
923 ;; next time. | |
924 ;; FIXME: There should be a more elegant way to do this. | |
925 (when (and (vc-dir-fileinfo->directory info) | |
926 (eq (vc-dir-fileinfo->state info) | |
927 'up-to-date)) | |
928 (setf (vc-dir-fileinfo->state info) nil)) | |
929 | |
930 (not (vc-dir-fileinfo->needs-update info)))))))))))) | |
931 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
932 (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
|
933 (vc-dir-refresh)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
934 |
96203 | 935 (defun vc-dir-refresh () |
936 "Refresh the contents of the *VC-dir* buffer. | |
937 Throw an error if another update process is in progress." | |
938 (interactive) | |
939 (if (vc-dir-busy) | |
940 (error "Another update process is in progress, cannot run two at a time") | |
941 (let ((def-dir default-directory) | |
942 (backend vc-dir-backend)) | |
943 (vc-set-mode-line-busy-indicator) | |
944 ;; Call the `dir-status' backend function. | |
945 ;; `dir-status' is supposed to be asynchronous. | |
946 ;; It should compute the results, and then call the function | |
947 ;; passed as an argument in order to update the vc-dir buffer | |
948 ;; with the results. | |
949 | |
950 ;; Create a buffer that can be used by `dir-status' and call | |
951 ;; `dir-status' with this buffer as the current buffer. Use | |
952 ;; `vc-dir-process-buffer' to remember this buffer, so that | |
953 ;; it can be used later to kill the update process in case it | |
954 ;; takes too long. | |
955 (unless (buffer-live-p vc-dir-process-buffer) | |
956 (setq vc-dir-process-buffer | |
957 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) | |
96541
d39625535543
(vc-dir-refresh): Only update files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96520
diff
changeset
|
958 ;; set the needs-update flag on all non-directory entries |
d39625535543
(vc-dir-refresh): Only update files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96520
diff
changeset
|
959 (ewoc-map (lambda (info) |
d39625535543
(vc-dir-refresh): Only update files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96520
diff
changeset
|
960 (unless (vc-dir-fileinfo->directory info) |
d39625535543
(vc-dir-refresh): Only update files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96520
diff
changeset
|
961 (setf (vc-dir-fileinfo->needs-update info) t) nil)) |
96203 | 962 vc-ewoc) |
963 (lexical-let ((buffer (current-buffer))) | |
964 (with-current-buffer vc-dir-process-buffer | |
965 (cd def-dir) | |
966 (erase-buffer) | |
967 (vc-call-backend | |
968 backend 'dir-status def-dir | |
969 (lambda (entries &optional more-to-come) | |
970 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. | |
971 ;; If MORE-TO-COME is true, then more updates will come from | |
972 ;; the asynchronous process. | |
973 (with-current-buffer buffer | |
974 (vc-dir-update entries buffer) | |
975 (unless more-to-come | |
976 (let ((remaining | |
977 (ewoc-collect | |
978 vc-ewoc 'vc-dir-fileinfo->needs-update))) | |
979 (if remaining | |
980 (vc-dir-refresh-files | |
981 (mapcar 'vc-dir-fileinfo->name remaining) | |
982 'up-to-date) | |
983 (setq mode-line-process nil)))))))))))) | |
984 | |
985 (defun vc-dir-show-fileentry (file) | |
986 "Insert an entry for a specific file into the current *VC-dir* listing. | |
987 This is typically used if the file is up-to-date (or has been added | |
988 outside of VC) and one wants to do some operation on it." | |
989 (interactive "fShow file: ") | |
990 (vc-dir-update (list (list (file-relative-name file) (vc-state file))) (current-buffer))) | |
991 | |
992 (defun vc-dir-hide-up-to-date () | |
993 "Hide up-to-date items from display." | |
994 (interactive) | |
96390
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
995 (let ((crt (ewoc-nth vc-ewoc -1)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
996 (first (ewoc-nth vc-ewoc 0))) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
997 ;; Go over from the last item to the first and remove the |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
998 ;; up-to-date files and directories with no child files. |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
999 (while (not (eq crt first)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1000 (let* ((data (ewoc-data crt)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1001 (dir (vc-dir-fileinfo->directory data)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1002 (next (ewoc-next vc-ewoc crt)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1003 (prev (ewoc-prev vc-ewoc crt)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1004 ;; ewoc-delete does not work without this... |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1005 (inhibit-read-only t)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1006 (when (or |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1007 ;; Remove directories with no child files. |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1008 (and dir |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1009 (or |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1010 ;; Nothing follows this directory. |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1011 (not next) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1012 ;; Next item is a directory. |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1013 (vc-dir-fileinfo->directory (ewoc-data next)))) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1014 ;; Remove files in the up-to-date state. |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1015 (eq (vc-dir-fileinfo->state data) 'up-to-date)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1016 (ewoc-delete vc-ewoc crt)) |
02d657f45045
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96388
diff
changeset
|
1017 (setq crt prev))))) |
96203 | 1018 |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1019 (defun vc-dir-status-printer (fileentry) |
96203 | 1020 (vc-call-backend vc-dir-backend 'status-printer fileentry)) |
1021 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1022 (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
|
1023 (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
|
1024 files |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1025 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
|
1026 state |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1027 model) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1028 (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
|
1029 (progn |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1030 (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
|
1031 (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
|
1032 (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
|
1033 (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
|
1034 (setq files (list crt)) |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1035 (when state-model-only-files |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1036 (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
|
1037 |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1038 (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
|
1039 (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
|
1040 ;; 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
|
1041 ;; 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
|
1042 (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
|
1043 (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
|
1044 (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
|
1045 (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
|
1046 (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
|
1047 (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
|
1048 (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
|
1049 (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
|
1050 |
96203 | 1051 ;;;###autoload |
96411
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1052 (defun vc-dir (dir &optional backend) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1053 "Show the VC status for DIR. |
96411
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1054 Optional second argument BACKEND specifies the VC backend to use. |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1055 Interactively, a prefix argument means to ask for the backend." |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1056 (interactive |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1057 (list |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1058 (read-file-name "VC status for directory: " |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1059 default-directory default-directory t |
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1060 nil #'file-directory-p) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1061 (if current-prefix-arg |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1062 (intern |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1063 (completing-read |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1064 "Use VC backend: " |
96411
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1065 (mapcar (lambda (b) (list (symbol-name b))) |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1066 vc-handled-backends) |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1067 nil t nil nil))))) |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1068 (unless backend |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1069 (setq backend (vc-responsible-backend dir))) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1070 (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
|
1071 (if (derived-mode-p 'vc-dir-mode) |
96203 | 1072 (vc-dir-refresh) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1073 ;; 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
|
1074 (let ((use-vc-backend backend)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1075 (vc-dir-mode)))) |
96203 | 1076 |
1077 (defun vc-default-status-extra-headers (backend dir) | |
1078 ;; Be loud by default to remind people to add code to display | |
1079 ;; backend specific headers. | |
1080 ;; XXX: change this to return nil before the release. | |
1081 (concat | |
1082 (propertize "Extra : " 'face 'font-lock-type-face) | |
1083 (propertize "Please add backend specific headers here. It's easy!" | |
1084 'face 'font-lock-warning-face))) | |
1085 | |
1086 (defun vc-default-status-printer (backend fileentry) | |
1087 "Pretty print FILEENTRY." | |
1088 ;; If you change the layout here, change vc-dir-move-to-goal-column. | |
1089 (let* ((isdir (vc-dir-fileinfo->directory fileentry)) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1090 (state (if isdir "" (vc-dir-fileinfo->state fileentry))) |
96203 | 1091 (filename (vc-dir-fileinfo->name fileentry))) |
1092 (insert | |
1093 (propertize | |
1094 (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? )) | |
1095 'face 'font-lock-type-face) | |
1096 " " | |
1097 (propertize | |
1098 (format "%-20s" state) | |
1099 'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face) | |
1100 ((memq state '(missing conflict)) 'font-lock-warning-face) | |
1101 (t 'font-lock-variable-name-face)) | |
1102 'mouse-face 'highlight) | |
1103 " " | |
1104 (propertize | |
1105 (format "%s" filename) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1106 'face |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1107 (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
|
1108 'help-echo |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1109 (if isdir |
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1110 "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu" |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1111 "File\nmouse-3: Pop-up menu") |
96203 | 1112 'mouse-face 'highlight)))) |
1113 | |
1114 (defun vc-default-extra-status-menu (backend) | |
1115 nil) | |
1116 | |
1117 (defun vc-default-status-fileinfo-extra (backend file) | |
1118 "Default absence of extra information returned for a file." | |
1119 nil) | |
1120 | |
1121 (provide 'vc-dir) | |
1122 | |
96204 | 1123 ;; arch-tag: 0274a2e3-e8e9-4b1a-a73c-e8b9129d5d15 |
96203 | 1124 ;;; vc-dir.el ends here |