Mercurial > emacs
annotate lisp/vc-dir.el @ 97190:2d8df19f85d3
(mh-send-letter, mh-redistribute): Mention mh-annotate-msg-hook in
docstring.
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Fri, 01 Aug 2008 04:41:38 +0000 |
parents | 48b4d1b43ea2 |
children | 50d4090b5c35 |
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] |
96964
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
160 '(menu-item "Query Replace in Files..." vc-dir-query-replace-regexp |
96500
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")) |
96963
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
162 (define-key map [se] |
96964
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
163 '(menu-item "Search Files..." vc-dir-search |
96963
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
164 :help "Search a regexp in the marked files")) |
96964
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
165 (define-key map [ires] |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
166 '(menu-item "Isearch Regexp Files..." vc-dir-isearch-regexp |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
167 :help "Incremental search a regexp in the marked files")) |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
168 (define-key map [ise] |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
169 '(menu-item "Isearch Files..." vc-dir-isearch |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
170 :help "Incremental search a string in the marked files")) |
96203 | 171 (define-key map [open-other] |
172 '(menu-item "Open in other window" vc-dir-find-file-other-window | |
173 :help "Find the file on the current line, in another window")) | |
174 (define-key map [open] | |
175 '(menu-item "Open file" vc-dir-find-file | |
176 :help "Find the file on the current line")) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
177 (define-key map [sepvcdet] '("--")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
178 ;; 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
|
179 ;; ("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
|
180 (define-key map [ins] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
181 '(menu-item "Show File" vc-dir-show-fileentry |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
182 :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
|
183 (define-key map [annotate] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
184 '(menu-item "Annotate" vc-annotate |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
185 :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
|
186 (define-key map [diff] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
187 '(menu-item "Compare with Base Version" vc-diff |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
188 :help "Compare file set with the base version")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
189 (define-key map [log] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
190 '(menu-item "Show history" vc-print-log |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
191 :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
|
192 ;; VC commands. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
193 (define-key map [sepvccmd] '("--")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
194 (define-key map [update] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
195 '(menu-item "Update to latest version" vc-update |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
196 :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
|
197 (define-key map [revert] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
198 '(menu-item "Revert to base version" vc-revert |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
199 :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
|
200 (define-key map [next-action] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
201 ;; FIXME: This really really really needs a better name! |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
202 ;; And a key binding too. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
203 '(menu-item "Check In/Out" vc-next-action |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
204 :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
|
205 (define-key map [register] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
206 '(menu-item "Register" vc-register |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
207 :help "Register file set into the version control system")) |
96203 | 208 map) |
97118
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
209 "Menu for dispatcher status") |
96203 | 210 |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
211 ;; 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
|
212 ;; vc-dir-menu-map. |
96203 | 213 (defun vc-dir-menu-map-filter (orig-binding) |
214 (when (and (symbolp orig-binding) (fboundp orig-binding)) | |
215 (setq orig-binding (indirect-function orig-binding))) | |
216 (let ((ext-binding | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
217 (when (derived-mode-p 'vc-dir-mode) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
218 (vc-call-backend vc-dir-backend 'extra-status-menu)))) |
96203 | 219 (if (null ext-binding) |
220 orig-binding | |
221 (append orig-binding | |
222 '("----") | |
223 ext-binding)))) | |
224 | |
225 (defvar vc-dir-mode-map | |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
226 (let ((map (make-sparse-keymap))) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
227 ;; VC commands |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
228 (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
|
229 (define-key map "=" 'vc-diff) ;; C-x v = |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
230 (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
|
231 (define-key map "+" 'vc-update) ;; C-x v + |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
232 (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
|
233 ;; More confusing than helpful, probably |
97118
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
234 ;;(define-key map "R" 'vc-revert) ;; u is taken by dispatcher unmark. |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
235 ;;(define-key map "A" 'vc-annotate) ;; g is taken by dispatcher refresh |
96203 | 236 ;; Marking. |
237 (define-key map "m" 'vc-dir-mark) | |
238 (define-key map "M" 'vc-dir-mark-all-files) | |
239 (define-key map "u" 'vc-dir-unmark) | |
240 (define-key map "U" 'vc-dir-unmark-all-files) | |
241 (define-key map "\C-?" 'vc-dir-unmark-file-up) | |
242 (define-key map "\M-\C-?" 'vc-dir-unmark-all-files) | |
243 ;; Movement. | |
244 (define-key map "n" 'vc-dir-next-line) | |
245 (define-key map " " 'vc-dir-next-line) | |
246 (define-key map "\t" 'vc-dir-next-directory) | |
247 (define-key map "p" 'vc-dir-previous-line) | |
248 (define-key map [backtab] 'vc-dir-previous-directory) | |
249 ;;; Rebind paragraph-movement commands. | |
250 (define-key map "\M-}" 'vc-dir-next-directory) | |
251 (define-key map "\M-{" 'vc-dir-previous-directory) | |
252 (define-key map [C-down] 'vc-dir-next-directory) | |
253 (define-key map [C-up] 'vc-dir-previous-directory) | |
254 ;; The remainder. | |
255 (define-key map "f" 'vc-dir-find-file) | |
256 (define-key map "\C-m" 'vc-dir-find-file) | |
257 (define-key map "o" 'vc-dir-find-file-other-window) | |
258 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) | |
259 (define-key map [down-mouse-3] 'vc-dir-menu) | |
260 (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
|
261 (define-key map "x" 'vc-dir-hide-up-to-date) |
96963
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
262 (define-key map "S" 'vc-dir-search) ;; FIXME: Maybe use A like dired? |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
263 (define-key map "Q" 'vc-dir-query-replace-regexp) |
96964
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
264 (define-key map (kbd "M-s a C-s") 'vc-dir-isearch) |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
265 (define-key map (kbd "M-s a M-C-s") 'vc-dir-isearch-regexp) |
96203 | 266 |
267 ;; Hook up the menu. | |
268 (define-key map [menu-bar vc-dir-mode] | |
269 `(menu-item | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
270 ;; 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
|
271 ;; vc-dir-menu-map. |
96203 | 272 "VC-dir" ,vc-dir-menu-map :filter vc-dir-menu-map-filter)) |
273 map) | |
274 "Keymap for directory buffer.") | |
275 | |
276 (defmacro vc-at-event (event &rest body) | |
277 "Evaluate `body' with point located at event-start of `event'. | |
278 If `body' uses `event', it should be a variable, | |
279 otherwise it will be evaluated twice." | |
280 (let ((posn (make-symbol "vc-at-event-posn"))) | |
281 `(let ((,posn (event-start ,event))) | |
282 (save-excursion | |
283 (set-buffer (window-buffer (posn-window ,posn))) | |
284 (goto-char (posn-point ,posn)) | |
285 ,@body)))) | |
286 | |
287 (defun vc-dir-menu (e) | |
97118
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
288 "Popup the dispatcher status menu." |
96203 | 289 (interactive "e") |
290 (vc-at-event e (popup-menu vc-dir-menu-map e))) | |
291 | |
292 (defvar vc-dir-tool-bar-map | |
293 (let ((map (make-sparse-keymap))) | |
294 (tool-bar-local-item-from-menu 'vc-dir-find-file "open" | |
295 map vc-dir-mode-map) | |
296 (tool-bar-local-item "bookmark_add" | |
297 'vc-dir-toggle-mark 'vc-dir-toggle-mark map | |
298 :help "Toggle mark on current item") | |
299 (tool-bar-local-item-from-menu 'vc-dir-previous-line "left-arrow" | |
300 map vc-dir-mode-map | |
301 :rtl "right-arrow") | |
302 (tool-bar-local-item-from-menu 'vc-dir-next-line "right-arrow" | |
303 map vc-dir-mode-map | |
304 :rtl "left-arrow") | |
305 (tool-bar-local-item-from-menu 'vc-print-log "info" | |
306 map vc-dir-mode-map) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
307 (tool-bar-local-item-from-menu 'revert-buffer "refresh" |
96203 | 308 map vc-dir-mode-map) |
309 (tool-bar-local-item-from-menu 'nonincremental-search-forward | |
310 "search" map) | |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
311 (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
|
312 "search-replace" map vc-dir-mode-map) |
96203 | 313 (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel" |
314 map vc-dir-mode-map) | |
315 (tool-bar-local-item-from-menu 'quit-window "exit" | |
316 map vc-dir-mode-map) | |
317 map)) | |
318 | |
319 (defun vc-dir-node-directory (node) | |
320 ;; Compute the directory for NODE. | |
321 ;; If it's a directory node, get it from the the node. | |
322 (let ((data (ewoc-data node))) | |
323 (or (vc-dir-fileinfo->directory data) | |
324 ;; Otherwise compute it from the file name. | |
325 (file-name-directory | |
326 (expand-file-name | |
327 (vc-dir-fileinfo->name data)))))) | |
328 | |
329 (defun vc-dir-update (entries buffer &optional noinsert) | |
330 "Update BUFFER's ewoc from the list of ENTRIES. | |
331 If NOINSERT, ignore elements on ENTRIES which are not in the ewoc." | |
332 ;; Add ENTRIES to the vc-dir buffer BUFFER. | |
333 (with-current-buffer buffer | |
334 ;; Insert the entries sorted by name into the ewoc. | |
335 ;; We assume the ewoc is sorted too, which should be the | |
336 ;; case if we always add entries with vc-dir-update. | |
337 (setq entries | |
338 ;; Sort: first files and then subdirectories. | |
339 ;; XXX: this is VERY inefficient, it computes the directory | |
340 ;; names too many times | |
341 (sort entries | |
342 (lambda (entry1 entry2) | |
343 (let ((dir1 (file-name-directory (expand-file-name (car entry1)))) | |
344 (dir2 (file-name-directory (expand-file-name (car entry2))))) | |
345 (cond | |
346 ((string< dir1 dir2) t) | |
347 ((not (string= dir1 dir2)) nil) | |
348 ((string< (car entry1) (car entry2)))))))) | |
349 ;; Insert directory entries in the right places. | |
350 (let ((entry (car entries)) | |
351 (node (ewoc-nth vc-ewoc 0))) | |
352 ;; Insert . if it is not present. | |
353 (unless node | |
354 (let ((rd (file-relative-name default-directory))) | |
355 (ewoc-enter-last | |
356 vc-ewoc (vc-dir-create-fileinfo | |
357 rd nil nil nil (expand-file-name default-directory)))) | |
358 (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
|
359 |
96203 | 360 (while (and entry node) |
361 (let* ((entryfile (car entry)) | |
362 (entrydir (file-name-directory (expand-file-name entryfile))) | |
363 (nodedir (vc-dir-node-directory node))) | |
364 (cond | |
365 ;; First try to find the directory. | |
366 ((string-lessp nodedir entrydir) | |
367 (setq node (ewoc-next vc-ewoc node))) | |
368 ((string-equal nodedir entrydir) | |
369 ;; Found the directory, find the place for the file name. | |
370 (let ((nodefile (vc-dir-fileinfo->name (ewoc-data node)))) | |
371 (cond | |
372 ((string-lessp nodefile entryfile) | |
373 (setq node (ewoc-next vc-ewoc node))) | |
374 ((string-equal nodefile entryfile) | |
375 (setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry)) | |
376 (setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry)) | |
377 (setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil) | |
378 (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
|
379 (setq entries (cdr entries)) |
96203 | 380 (setq entry (car entries)) |
381 (setq node (ewoc-next vc-ewoc node))) | |
382 (t | |
383 (ewoc-enter-before vc-ewoc node | |
384 (apply 'vc-dir-create-fileinfo entry)) | |
385 (setq entries (cdr entries)) | |
386 (setq entry (car entries)))))) | |
387 (t | |
388 ;; We might need to insert a directory node if the | |
389 ;; previous node was in a different directory. | |
390 (let* ((rd (file-relative-name entrydir)) | |
391 (prev-node (ewoc-prev vc-ewoc node)) | |
392 (prev-dir (vc-dir-node-directory prev-node))) | |
393 (unless (string-equal entrydir prev-dir) | |
394 (ewoc-enter-before | |
395 vc-ewoc node (vc-dir-create-fileinfo rd nil nil nil entrydir)))) | |
396 ;; Now insert the node itself. | |
397 (ewoc-enter-before vc-ewoc node | |
398 (apply 'vc-dir-create-fileinfo entry)) | |
399 (setq entries (cdr entries) entry (car entries)))))) | |
400 ;; We're past the last node, all remaining entries go to the end. | |
401 (unless (or node noinsert) | |
402 (let ((lastdir (vc-dir-node-directory (ewoc-nth vc-ewoc -1)))) | |
403 (dolist (entry entries) | |
404 (let ((entrydir (file-name-directory (expand-file-name (car entry))))) | |
405 ;; Insert a directory node if needed. | |
406 (unless (string-equal lastdir entrydir) | |
407 (setq lastdir entrydir) | |
408 (let ((rd (file-relative-name entrydir))) | |
409 (ewoc-enter-last | |
410 vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir)))) | |
411 ;; Now insert the node itself. | |
412 (ewoc-enter-last vc-ewoc | |
413 (apply 'vc-dir-create-fileinfo entry))))))))) | |
414 | |
415 (defun vc-dir-busy () | |
416 (and (buffer-live-p vc-dir-process-buffer) | |
417 (get-buffer-process vc-dir-process-buffer))) | |
418 | |
419 (defun vc-dir-kill-dir-status-process () | |
420 "Kill the temporary buffer and associated process." | |
421 (interactive) | |
422 (when (buffer-live-p vc-dir-process-buffer) | |
423 (let ((proc (get-buffer-process vc-dir-process-buffer))) | |
424 (when proc (delete-process proc)) | |
425 (setq vc-dir-process-buffer nil) | |
426 (setq mode-line-process nil)))) | |
427 | |
428 (defun vc-dir-kill-query () | |
429 ;; Make sure that when the status buffer is killed the update | |
430 ;; process running in background is also killed. | |
431 (if (vc-dir-busy) | |
432 (when (y-or-n-p "Status update process running, really kill status buffer? ") | |
433 (vc-dir-kill-dir-status-process) | |
434 t) | |
435 t)) | |
436 | |
437 (defun vc-dir-next-line (arg) | |
438 "Go to the next line. | |
439 If a prefix argument is given, move by that many lines." | |
440 (interactive "p") | |
441 (with-no-warnings | |
442 (ewoc-goto-next vc-ewoc arg) | |
443 (vc-dir-move-to-goal-column))) | |
444 | |
445 (defun vc-dir-previous-line (arg) | |
446 "Go to the previous line. | |
447 If a prefix argument is given, move by that many lines." | |
448 (interactive "p") | |
449 (ewoc-goto-prev vc-ewoc arg) | |
450 (vc-dir-move-to-goal-column)) | |
451 | |
452 (defun vc-dir-next-directory () | |
453 "Go to the next directory." | |
454 (interactive) | |
455 (let ((orig (point))) | |
456 (if | |
457 (catch 'foundit | |
458 (while t | |
459 (let* ((next (ewoc-next vc-ewoc (ewoc-locate vc-ewoc)))) | |
460 (cond ((not next) | |
461 (throw 'foundit t)) | |
462 (t | |
463 (progn | |
464 (ewoc-goto-node vc-ewoc next) | |
465 (vc-dir-move-to-goal-column) | |
466 (if (vc-dir-fileinfo->directory (ewoc-data next)) | |
467 (throw 'foundit nil)))))))) | |
468 (goto-char orig)))) | |
469 | |
470 (defun vc-dir-previous-directory () | |
471 "Go to the previous directory." | |
472 (interactive) | |
473 (let ((orig (point))) | |
474 (if | |
475 (catch 'foundit | |
476 (while t | |
477 (let* ((prev (ewoc-prev vc-ewoc (ewoc-locate vc-ewoc)))) | |
478 (cond ((not prev) | |
479 (throw 'foundit t)) | |
480 (t | |
481 (progn | |
482 (ewoc-goto-node vc-ewoc prev) | |
483 (vc-dir-move-to-goal-column) | |
484 (if (vc-dir-fileinfo->directory (ewoc-data prev)) | |
485 (throw 'foundit nil)))))))) | |
486 (goto-char orig)))) | |
487 | |
488 (defun vc-dir-mark-unmark (mark-unmark-function) | |
489 (if (use-region-p) | |
490 (let ((firstl (line-number-at-pos (region-beginning))) | |
491 (lastl (line-number-at-pos (region-end)))) | |
492 (save-excursion | |
493 (goto-char (region-beginning)) | |
494 (while (<= (line-number-at-pos) lastl) | |
495 (funcall mark-unmark-function)))) | |
496 (funcall mark-unmark-function))) | |
497 | |
498 (defun vc-dir-parent-marked-p (arg) | |
499 ;; Return nil if none of the parent directories of arg is marked. | |
500 (let* ((argdir (vc-dir-node-directory arg)) | |
501 (arglen (length argdir)) | |
502 (crt arg) | |
503 data dir) | |
504 ;; Go through the predecessors, checking if any directory that is | |
505 ;; a parent is marked. | |
506 (while (setq crt (ewoc-prev vc-ewoc crt)) | |
507 (setq data (ewoc-data crt)) | |
508 (setq dir (vc-dir-node-directory crt)) | |
509 (when (and (vc-dir-fileinfo->directory data) | |
510 (vc-string-prefix-p dir argdir)) | |
511 (when (vc-dir-fileinfo->marked data) | |
512 (error "Cannot mark `%s', parent directory `%s' marked" | |
513 (vc-dir-fileinfo->name (ewoc-data arg)) | |
514 (vc-dir-fileinfo->name data))))) | |
515 nil)) | |
516 | |
517 (defun vc-dir-children-marked-p (arg) | |
518 ;; Return nil if none of the children of arg is marked. | |
519 (let* ((argdir-re (concat "\\`" (regexp-quote (vc-dir-node-directory arg)))) | |
520 (is-child t) | |
521 (crt arg) | |
522 data dir) | |
523 (while (and is-child (setq crt (ewoc-next vc-ewoc crt))) | |
524 (setq data (ewoc-data crt)) | |
525 (setq dir (vc-dir-node-directory crt)) | |
526 (if (string-match argdir-re dir) | |
527 (when (vc-dir-fileinfo->marked data) | |
528 (error "Cannot mark `%s', child `%s' marked" | |
529 (vc-dir-fileinfo->name (ewoc-data arg)) | |
530 (vc-dir-fileinfo->name data))) | |
531 ;; We are done, we got to an entry that is not a child of `arg'. | |
532 (setq is-child nil))) | |
533 nil)) | |
534 | |
535 (defun vc-dir-mark-file (&optional arg) | |
536 ;; Mark ARG or the current file and move to the next line. | |
537 (let* ((crt (or arg (ewoc-locate vc-ewoc))) | |
538 (file (ewoc-data crt)) | |
539 (isdir (vc-dir-fileinfo->directory file))) | |
540 (when (or (and isdir (not (vc-dir-children-marked-p crt))) | |
541 (and (not isdir) (not (vc-dir-parent-marked-p crt)))) | |
542 (setf (vc-dir-fileinfo->marked file) t) | |
543 (ewoc-invalidate vc-ewoc crt) | |
544 (unless (or arg (mouse-event-p last-command-event)) | |
545 (vc-dir-next-line 1))))) | |
546 | |
547 (defun vc-dir-mark () | |
548 "Mark the current file or all files in the region. | |
549 If the region is active, mark all the files in the region. | |
550 Otherwise mark the file on the current line and move to the next | |
551 line." | |
552 (interactive) | |
553 (vc-dir-mark-unmark 'vc-dir-mark-file)) | |
554 | |
555 (defun vc-dir-mark-all-files (arg) | |
556 "Mark all files with the same state as the current one. | |
557 With a prefix argument mark all files. | |
558 If the current entry is a directory, mark all child files. | |
559 | |
560 The commands operate on files that are on the same state. | |
561 This command is intended to make it easy to select all files that | |
562 share the same state." | |
563 (interactive "P") | |
564 (if arg | |
565 ;; Mark all files. | |
566 (progn | |
567 ;; First check that no directory is marked, we can't mark | |
568 ;; files in that case. | |
569 (ewoc-map | |
570 (lambda (filearg) | |
571 (when (and (vc-dir-fileinfo->directory filearg) | |
572 (vc-dir-fileinfo->marked filearg)) | |
573 (error "Cannot mark all files, directory `%s' marked" | |
574 (vc-dir-fileinfo->name filearg)))) | |
575 vc-ewoc) | |
576 (ewoc-map | |
577 (lambda (filearg) | |
578 (unless (vc-dir-fileinfo->marked filearg) | |
579 (setf (vc-dir-fileinfo->marked filearg) t) | |
580 t)) | |
581 vc-ewoc)) | |
582 (let ((data (ewoc-data (ewoc-locate vc-ewoc)))) | |
583 (if (vc-dir-fileinfo->directory data) | |
584 ;; It's a directory, mark child files. | |
585 (let ((crt (ewoc-locate vc-ewoc))) | |
586 (unless (vc-dir-children-marked-p crt) | |
587 (while (setq crt (ewoc-next vc-ewoc crt)) | |
588 (let ((crt-data (ewoc-data crt))) | |
589 (unless (vc-dir-fileinfo->directory crt-data) | |
590 (setf (vc-dir-fileinfo->marked crt-data) t) | |
591 (ewoc-invalidate vc-ewoc crt)))))) | |
592 ;; It's a file | |
593 (let ((state (vc-dir-fileinfo->state data)) | |
594 (crt (ewoc-nth vc-ewoc 0))) | |
595 (while crt | |
596 (let ((crt-data (ewoc-data crt))) | |
597 (when (and (not (vc-dir-fileinfo->marked crt-data)) | |
598 (eq (vc-dir-fileinfo->state crt-data) state) | |
599 (not (vc-dir-fileinfo->directory crt-data))) | |
600 (vc-dir-mark-file crt))) | |
601 (setq crt (ewoc-next vc-ewoc crt)))))))) | |
602 | |
603 (defun vc-dir-unmark-file () | |
604 ;; Unmark the current file and move to the next line. | |
605 (let* ((crt (ewoc-locate vc-ewoc)) | |
606 (file (ewoc-data crt))) | |
607 (setf (vc-dir-fileinfo->marked file) nil) | |
608 (ewoc-invalidate vc-ewoc crt) | |
609 (unless (mouse-event-p last-command-event) | |
610 (vc-dir-next-line 1)))) | |
611 | |
612 (defun vc-dir-unmark () | |
613 "Unmark the current file or all files in the region. | |
614 If the region is active, unmark all the files in the region. | |
615 Otherwise mark the file on the current line and move to the next | |
616 line." | |
617 (interactive) | |
618 (vc-dir-mark-unmark 'vc-dir-unmark-file)) | |
619 | |
620 (defun vc-dir-unmark-file-up () | |
621 "Move to the previous line and unmark the file." | |
622 (interactive) | |
623 ;; If we're on the first line, we won't move up, but we will still | |
624 ;; remove the mark. This seems a bit odd but it is what buffer-menu | |
625 ;; does. | |
626 (let* ((prev (ewoc-goto-prev vc-ewoc 1)) | |
627 (file (ewoc-data prev))) | |
628 (setf (vc-dir-fileinfo->marked file) nil) | |
629 (ewoc-invalidate vc-ewoc prev) | |
630 (vc-dir-move-to-goal-column))) | |
631 | |
632 (defun vc-dir-unmark-all-files (arg) | |
633 "Unmark all files with the same state as the current one. | |
634 With a prefix argument unmark all files. | |
635 If the current entry is a directory, unmark all the child files. | |
636 | |
637 The commands operate on files that are on the same state. | |
638 This command is intended to make it easy to deselect all files | |
639 that share the same state." | |
640 (interactive "P") | |
641 (if arg | |
642 (ewoc-map | |
643 (lambda (filearg) | |
644 (when (vc-dir-fileinfo->marked filearg) | |
645 (setf (vc-dir-fileinfo->marked filearg) nil) | |
646 t)) | |
647 vc-ewoc) | |
648 (let* ((crt (ewoc-locate vc-ewoc)) | |
649 (data (ewoc-data crt))) | |
650 (if (vc-dir-fileinfo->directory data) | |
651 ;; It's a directory, unmark child files. | |
652 (while (setq crt (ewoc-next vc-ewoc crt)) | |
653 (let ((crt-data (ewoc-data crt))) | |
654 (unless (vc-dir-fileinfo->directory crt-data) | |
655 (setf (vc-dir-fileinfo->marked crt-data) nil) | |
656 (ewoc-invalidate vc-ewoc crt)))) | |
657 ;; It's a file | |
658 (let ((crt-state (vc-dir-fileinfo->state (ewoc-data crt)))) | |
659 (ewoc-map | |
660 (lambda (filearg) | |
661 (when (and (vc-dir-fileinfo->marked filearg) | |
662 (eq (vc-dir-fileinfo->state filearg) crt-state)) | |
663 (setf (vc-dir-fileinfo->marked filearg) nil) | |
664 t)) | |
665 vc-ewoc)))))) | |
666 | |
667 (defun vc-dir-toggle-mark-file () | |
668 (let* ((crt (ewoc-locate vc-ewoc)) | |
669 (file (ewoc-data crt))) | |
670 (if (vc-dir-fileinfo->marked file) | |
671 (vc-dir-unmark-file) | |
672 (vc-dir-mark-file)))) | |
673 | |
674 (defun vc-dir-toggle-mark (e) | |
675 (interactive "e") | |
676 (vc-at-event e (vc-dir-mark-unmark 'vc-dir-toggle-mark-file))) | |
677 | |
678 (defun vc-dir-delete-file () | |
679 "Delete the marked files, or the current file if no marks." | |
680 (interactive) | |
681 (mapc 'vc-delete-file (or (vc-dir-marked-files) | |
682 (list (vc-dir-current-file))))) | |
683 | |
684 (defun vc-dir-find-file () | |
685 "Find the file on the current line." | |
686 (interactive) | |
687 (find-file (vc-dir-current-file))) | |
688 | |
689 (defun vc-dir-find-file-other-window () | |
690 "Find the file on the current line, in another window." | |
691 (interactive) | |
692 (find-file-other-window (vc-dir-current-file))) | |
693 | |
96964
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
694 (defun vc-dir-isearch () |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
695 "Search for a string through all marked buffers using Isearch." |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
696 (interactive) |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
697 (multi-isearch-files |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
698 (mapcar 'car (vc-dir-marked-only-files-and-states)))) |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
699 |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
700 (defun vc-dir-isearch-regexp () |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
701 "Search for a regexp through all marked buffers using Isearch." |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
702 (interactive) |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
703 (multi-isearch-files-regexp |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
704 (mapcar 'car (vc-dir-marked-only-files-and-states)))) |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
705 |
96963
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
706 (defun vc-dir-search (regexp) |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
707 "Search through all marked files for a match for REGEXP. |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
708 For marked directories, use the files displayed from those directories. |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
709 Stops when a match is found. |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
710 To continue searching for next match, use command \\[tags-loop-continue]." |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
711 (interactive "sSearch marked files (regexp): ") |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
712 (tags-search regexp '(mapcar 'car (vc-dir-marked-only-files-and-states)))) |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
713 |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
714 (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
|
715 "Do `query-replace-regexp' of FROM with TO, on all marked files. |
96963
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
716 For marked directories, use the files displayed from those directories. |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
717 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
|
718 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
|
719 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
|
720 with the command \\[tags-loop-continue]." |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
721 ;; 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
|
722 ;; 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
|
723 ;; duplicating it here. |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
724 (interactive |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
725 (let ((common |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
726 (query-replace-read-args |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
727 "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
|
728 (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
|
729 (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
|
730 (let ((buffer (get-file-buffer file))) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
731 (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
|
732 buffer-read-only)) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
733 (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
|
734 (tags-query-replace from to delimited |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
735 '(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
|
736 |
96203 | 737 (defun vc-dir-current-file () |
738 (let ((node (ewoc-locate vc-ewoc))) | |
739 (unless node | |
740 (error "No file available")) | |
741 (expand-file-name (vc-dir-fileinfo->name (ewoc-data node))))) | |
742 | |
743 (defun vc-dir-marked-files () | |
744 "Return the list of marked files." | |
745 (mapcar | |
746 (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) | |
747 (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) | |
748 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
749 (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
|
750 "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
|
751 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
|
752 child files." |
96203 | 753 (let ((crt (ewoc-nth vc-ewoc 0)) |
754 result) | |
755 (while crt | |
756 (let ((crt-data (ewoc-data crt))) | |
757 (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
|
758 ;; FIXME: use vc-dir-child-files-and-states here instead of duplicating it. |
96203 | 759 (if (vc-dir-fileinfo->directory crt-data) |
760 (let* ((dir (vc-dir-fileinfo->directory crt-data)) | |
761 (dirlen (length dir)) | |
762 data) | |
763 (while | |
764 (and (setq crt (ewoc-next vc-ewoc crt)) | |
765 (vc-string-prefix-p dir | |
766 (progn | |
767 (setq data (ewoc-data crt)) | |
768 (vc-dir-node-directory crt)))) | |
769 (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
|
770 (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
|
771 (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
|
772 (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
|
773 result)))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
774 (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
|
775 (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
|
776 result) |
96203 | 777 (setq crt (ewoc-next vc-ewoc crt))) |
778 (setq crt (ewoc-next vc-ewoc crt))))) | |
779 result)) | |
780 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
781 (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
|
782 "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
|
783 If it is a file, return the corresponding cons for the file itself." |
96203 | 784 (let* ((crt (ewoc-locate vc-ewoc)) |
785 (crt-data (ewoc-data crt)) | |
786 result) | |
787 (if (vc-dir-fileinfo->directory crt-data) | |
788 (let* ((dir (vc-dir-fileinfo->directory crt-data)) | |
789 (dirlen (length dir)) | |
790 data) | |
791 (while | |
792 (and (setq crt (ewoc-next vc-ewoc crt)) | |
793 (vc-string-prefix-p dir (progn | |
794 (setq data (ewoc-data crt)) | |
795 (vc-dir-node-directory crt)))) | |
796 (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
|
797 (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
|
798 (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
|
799 (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
|
800 result)))) |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
801 (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
|
802 (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
|
803 (vc-dir-fileinfo->state crt-data)) result)) |
96203 | 804 result)) |
805 | |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
806 (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
|
807 (let* ((file-short (file-relative-name fname def-dir)) |
96880
938dd02137bc
(vc-dir-recompute-file-state): Add workaround for CVS.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96541
diff
changeset
|
808 (remove-me-when-CVS-works |
938dd02137bc
(vc-dir-recompute-file-state): Add workaround for CVS.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96541
diff
changeset
|
809 (when (eq vc-dir-backend 'CVS) |
938dd02137bc
(vc-dir-recompute-file-state): Add workaround for CVS.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96541
diff
changeset
|
810 ;; FIXME: Warning: UGLY HACK. The CVS backend caches the state |
938dd02137bc
(vc-dir-recompute-file-state): Add workaround for CVS.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96541
diff
changeset
|
811 ;; info, this forces the backend to update it. |
96888
32da3745adc8
Fixed mismatched parenthesis in vc-dir.el.
Bastien Guerry <bzg@altern.org>
parents:
96880
diff
changeset
|
812 (vc-call-backend vc-dir-backend 'registered fname))) |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
813 (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
|
814 (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
|
815 '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
|
816 (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
|
817 |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
818 (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
|
819 ;; 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
|
820 ;; 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
|
821 (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
|
822 children |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
823 dname) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
824 ;; Find DIR |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
825 (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
|
826 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
|
827 (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
|
828 (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
|
829 dirname |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
830 (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
|
831 (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
|
832 (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
|
833 (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
|
834 (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
|
835 children)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
836 |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
837 (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
|
838 ;; 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
|
839 ;; 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
|
840 (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
|
841 (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
|
842 fileentries) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
843 (when files |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
844 (dolist (crt files) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
845 (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
|
846 fileentries)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
847 (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
|
848 |
96203 | 849 (defun vc-dir-resynch-file (&optional fname) |
850 "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
|
851 (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
|
852 (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
|
853 (save-excursion |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
854 (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
|
855 (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
|
856 ;; 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
|
857 (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
|
858 (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
|
859 (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
|
860 (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
|
861 (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
|
862 (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
|
863 (vc-dir-update |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
864 (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
|
865 status-buf))))))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
866 ;; 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
|
867 ;; not needed. |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
868 (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
|
869 (remove-hook 'after-save-hook 'vc-dir-resynch-file)))) |
96203 | 870 |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
871 (defvar use-vc-backend) ;; dynamically bound |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
872 |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
873 (define-derived-mode vc-dir-mode special-mode "VC dir" |
97118
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
874 "Major mode for dispatcher directory buffers. |
96203 | 875 Marking/Unmarking key bindings and actions: |
876 m - marks a file/directory or if the region is active, mark all the files | |
877 in region. | |
878 Restrictions: - a file cannot be marked if any parent directory is marked | |
879 - a directory cannot be marked if any child file or | |
880 directory is marked | |
881 u - marks a file/directory or if the region is active, unmark all the files | |
882 in region. | |
883 M - if the cursor is on a file: mark all the files with the same state as | |
884 the current file | |
885 - if the cursor is on a directory: mark all child files | |
886 - with a prefix argument: mark all files | |
887 U - if the cursor is on a file: unmark all the files with the same state | |
888 as the current file | |
889 - if the cursor is on a directory: unmark all child files | |
890 - with a prefix argument: unmark all files | |
891 | |
892 | |
893 \\{vc-dir-mode-map}" | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
894 (set (make-local-variable 'vc-dir-backend) use-vc-backend) |
96203 | 895 (setq buffer-read-only t) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
896 (when (boundp 'tool-bar-map) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
897 (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)) |
96203 | 898 (let ((buffer-read-only nil)) |
899 (erase-buffer) | |
900 (set (make-local-variable 'vc-dir-process-buffer) nil) | |
901 (set (make-local-variable 'vc-ewoc) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
902 (ewoc-create #'vc-dir-status-printer |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
903 (vc-dir-headers vc-dir-backend default-directory))) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
904 (set (make-local-variable 'revert-buffer-function) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
905 'vc-dir-revert-buffer-function) |
96474
9a72b6660355
(vc-dir-mode): Set list-buffers-function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96411
diff
changeset
|
906 (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
|
907 (expand-file-name default-directory)) |
96203 | 908 (add-hook 'after-save-hook 'vc-dir-resynch-file) |
909 ;; Make sure that if the directory buffer is killed, the update | |
910 ;; process running in the background is also killed. | |
911 (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
|
912 (vc-dir-refresh))) |
96203 | 913 |
914 (defun vc-dir-headers (backend dir) | |
915 "Display the headers in the *VC dir* buffer. | |
916 It calls the `status-extra-headers' backend method to display backend | |
917 specific headers." | |
918 (concat | |
919 (propertize "VC backend : " 'face 'font-lock-type-face) | |
920 (propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face) | |
921 (propertize "Working dir: " 'face 'font-lock-type-face) | |
922 (propertize (format "%s\n" dir) 'face 'font-lock-variable-name-face) | |
923 (vc-call-backend backend 'status-extra-headers dir) | |
924 "\n")) | |
925 | |
926 (defun vc-dir-refresh-files (files default-state) | |
927 "Refresh some files in the *VC-dir* buffer." | |
928 (let ((def-dir default-directory) | |
929 (backend vc-dir-backend)) | |
930 (vc-set-mode-line-busy-indicator) | |
931 ;; Call the `dir-status-file' backend function. | |
932 ;; `dir-status-file' is supposed to be asynchronous. | |
933 ;; It should compute the results, and then call the function | |
934 ;; passed as an argument in order to update the vc-dir buffer | |
935 ;; with the results. | |
936 (unless (buffer-live-p vc-dir-process-buffer) | |
937 (setq vc-dir-process-buffer | |
938 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) | |
939 (lexical-let ((buffer (current-buffer))) | |
940 (with-current-buffer vc-dir-process-buffer | |
941 (cd def-dir) | |
942 (erase-buffer) | |
943 (vc-call-backend | |
944 backend 'dir-status-files def-dir files default-state | |
945 (lambda (entries &optional more-to-come) | |
946 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. | |
947 ;; If MORE-TO-COME is true, then more updates will come from | |
948 ;; the asynchronous process. | |
949 (with-current-buffer buffer | |
950 (vc-dir-update entries buffer) | |
951 (unless more-to-come | |
952 (setq mode-line-process nil) | |
953 ;; Remove the ones that haven't been updated at all. | |
954 ;; Those not-updated are those whose state is nil because the | |
955 ;; file/dir doesn't exist and isn't versioned. | |
956 (ewoc-filter vc-ewoc | |
957 (lambda (info) | |
958 ;; The state for directory entries might | |
959 ;; have been changed to 'up-to-date, | |
960 ;; reset it, othewise it will be removed when doing 'x' | |
961 ;; next time. | |
962 ;; FIXME: There should be a more elegant way to do this. | |
963 (when (and (vc-dir-fileinfo->directory info) | |
964 (eq (vc-dir-fileinfo->state info) | |
965 'up-to-date)) | |
966 (setf (vc-dir-fileinfo->state info) nil)) | |
967 | |
968 (not (vc-dir-fileinfo->needs-update info)))))))))))) | |
969 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
970 (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
|
971 (vc-dir-refresh)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
972 |
96203 | 973 (defun vc-dir-refresh () |
974 "Refresh the contents of the *VC-dir* buffer. | |
975 Throw an error if another update process is in progress." | |
976 (interactive) | |
977 (if (vc-dir-busy) | |
978 (error "Another update process is in progress, cannot run two at a time") | |
979 (let ((def-dir default-directory) | |
980 (backend vc-dir-backend)) | |
981 (vc-set-mode-line-busy-indicator) | |
982 ;; Call the `dir-status' backend function. | |
983 ;; `dir-status' is supposed to be asynchronous. | |
984 ;; It should compute the results, and then call the function | |
985 ;; passed as an argument in order to update the vc-dir buffer | |
986 ;; with the results. | |
987 | |
988 ;; Create a buffer that can be used by `dir-status' and call | |
989 ;; `dir-status' with this buffer as the current buffer. Use | |
990 ;; `vc-dir-process-buffer' to remember this buffer, so that | |
991 ;; it can be used later to kill the update process in case it | |
992 ;; takes too long. | |
993 (unless (buffer-live-p vc-dir-process-buffer) | |
994 (setq vc-dir-process-buffer | |
995 (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
|
996 ;; 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
|
997 (ewoc-map (lambda (info) |
d39625535543
(vc-dir-refresh): Only update files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96520
diff
changeset
|
998 (unless (vc-dir-fileinfo->directory info) |
d39625535543
(vc-dir-refresh): Only update files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96520
diff
changeset
|
999 (setf (vc-dir-fileinfo->needs-update info) t) nil)) |
96203 | 1000 vc-ewoc) |
1001 (lexical-let ((buffer (current-buffer))) | |
1002 (with-current-buffer vc-dir-process-buffer | |
1003 (cd def-dir) | |
1004 (erase-buffer) | |
1005 (vc-call-backend | |
1006 backend 'dir-status def-dir | |
1007 (lambda (entries &optional more-to-come) | |
1008 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. | |
1009 ;; If MORE-TO-COME is true, then more updates will come from | |
1010 ;; the asynchronous process. | |
1011 (with-current-buffer buffer | |
1012 (vc-dir-update entries buffer) | |
1013 (unless more-to-come | |
1014 (let ((remaining | |
1015 (ewoc-collect | |
1016 vc-ewoc 'vc-dir-fileinfo->needs-update))) | |
1017 (if remaining | |
1018 (vc-dir-refresh-files | |
1019 (mapcar 'vc-dir-fileinfo->name remaining) | |
1020 'up-to-date) | |
1021 (setq mode-line-process nil)))))))))))) | |
1022 | |
1023 (defun vc-dir-show-fileentry (file) | |
1024 "Insert an entry for a specific file into the current *VC-dir* listing. | |
1025 This is typically used if the file is up-to-date (or has been added | |
1026 outside of VC) and one wants to do some operation on it." | |
1027 (interactive "fShow file: ") | |
1028 (vc-dir-update (list (list (file-relative-name file) (vc-state file))) (current-buffer))) | |
1029 | |
1030 (defun vc-dir-hide-up-to-date () | |
1031 "Hide up-to-date items from display." | |
1032 (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
|
1033 (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
|
1034 (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
|
1035 ;; 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
|
1036 ;; 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
|
1037 (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
|
1038 (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
|
1039 (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
|
1040 (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
|
1041 (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
|
1042 ;; 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
|
1043 (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
|
1044 (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
|
1045 ;; 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
|
1046 (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
|
1047 (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
|
1048 ;; 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
|
1049 (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
|
1050 ;; 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
|
1051 (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
|
1052 ;; 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
|
1053 (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
|
1054 (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
|
1055 (setq crt prev))))) |
96203 | 1056 |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1057 (defun vc-dir-status-printer (fileentry) |
96203 | 1058 (vc-call-backend vc-dir-backend 'status-printer fileentry)) |
1059 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1060 (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
|
1061 (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
|
1062 files |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1063 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
|
1064 state |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1065 model) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1066 (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
|
1067 (progn |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1068 (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
|
1069 (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
|
1070 (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
|
1071 (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
|
1072 (setq files (list crt)) |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1073 (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
|
1074 (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
|
1075 |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1076 (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
|
1077 (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
|
1078 ;; 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
|
1079 ;; 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
|
1080 (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
|
1081 (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
|
1082 (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
|
1083 (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
|
1084 (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
|
1085 (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
|
1086 (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
|
1087 (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
|
1088 |
96203 | 1089 ;;;###autoload |
96411
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1090 (defun vc-dir (dir &optional backend) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1091 "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
|
1092 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
|
1093 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
|
1094 (interactive |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1095 (list |
97118
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1096 ;; When you hit C-x v d in a visited VC file, |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1097 ;; the *vc-dir* buffer visits the directory under its truename; |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1098 ;; therefore it makes sense to always do that. |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1099 ;; Otherwise if you do C-x v d -> C-x C-f -> C-c v d |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1100 ;; you may get a new *vc-dir* buffer, different from the original |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1101 (file-truename (read-file-name "VC status for directory: " |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1102 default-directory default-directory t |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1103 nil #'file-directory-p)) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1104 (if current-prefix-arg |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1105 (intern |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1106 (completing-read |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1107 "Use VC backend: " |
96411
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1108 (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
|
1109 vc-handled-backends) |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1110 nil t nil nil))))) |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1111 (unless backend |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1112 (setq backend (vc-responsible-backend dir))) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1113 (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
|
1114 (if (derived-mode-p 'vc-dir-mode) |
96203 | 1115 (vc-dir-refresh) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1116 ;; 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
|
1117 (let ((use-vc-backend backend)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1118 (vc-dir-mode)))) |
96203 | 1119 |
1120 (defun vc-default-status-extra-headers (backend dir) | |
1121 ;; Be loud by default to remind people to add code to display | |
1122 ;; backend specific headers. | |
1123 ;; XXX: change this to return nil before the release. | |
1124 (concat | |
1125 (propertize "Extra : " 'face 'font-lock-type-face) | |
1126 (propertize "Please add backend specific headers here. It's easy!" | |
1127 'face 'font-lock-warning-face))) | |
1128 | |
1129 (defun vc-default-status-printer (backend fileentry) | |
1130 "Pretty print FILEENTRY." | |
1131 ;; If you change the layout here, change vc-dir-move-to-goal-column. | |
1132 (let* ((isdir (vc-dir-fileinfo->directory fileentry)) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1133 (state (if isdir "" (vc-dir-fileinfo->state fileentry))) |
96203 | 1134 (filename (vc-dir-fileinfo->name fileentry))) |
1135 (insert | |
1136 (propertize | |
1137 (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? )) | |
1138 'face 'font-lock-type-face) | |
1139 " " | |
1140 (propertize | |
1141 (format "%-20s" state) | |
1142 'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face) | |
1143 ((memq state '(missing conflict)) 'font-lock-warning-face) | |
1144 (t 'font-lock-variable-name-face)) | |
1145 'mouse-face 'highlight) | |
1146 " " | |
1147 (propertize | |
1148 (format "%s" filename) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1149 'face |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1150 (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
|
1151 'help-echo |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1152 (if isdir |
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1153 "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
|
1154 "File\nmouse-3: Pop-up menu") |
96203 | 1155 'mouse-face 'highlight)))) |
1156 | |
1157 (defun vc-default-extra-status-menu (backend) | |
1158 nil) | |
1159 | |
1160 (defun vc-default-status-fileinfo-extra (backend file) | |
1161 "Default absence of extra information returned for a file." | |
1162 nil) | |
1163 | |
1164 (provide 'vc-dir) | |
1165 | |
96204 | 1166 ;; arch-tag: 0274a2e3-e8e9-4b1a-a73c-e8b9129d5d15 |
96203 | 1167 ;;; vc-dir.el ends here |