Mercurial > emacs
annotate lisp/vc-dir.el @ 108221:0df783a4f40a
Fix some ChangeLog attributions.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sun, 02 May 2010 23:23:01 -0700 |
parents | 4d8277a44bb4 |
children | 136a119bc981 |
rev | line source |
---|---|
96203 | 1 ;;; vc-dir.el --- Directory status display under VC |
2 | |
106815 | 3 ;; Copyright (C) 2007, 2008, 2009, 2010 |
96203 | 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) | |
99159
b0dce7f34dda
* vc.el: Rename VC methods that were missed when vc-status was
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99133
diff
changeset
|
86 ;; Must be in sync with vc-default-dir-printer. |
96203 | 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." |
97660
cf2cf606d5d7
(vc-dir-prepare-status-buffer): Make sure we use a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97315
diff
changeset
|
91 (setq dir (file-name-as-directory (expand-file-name dir))) |
105293
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
92 (let* ;; Look for another buffer name BNAME visiting the same directory. |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
93 ((buf (save-excursion |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
94 (unless create-new |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
95 (dolist (buffer vc-dir-buffers) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
96 (when (buffer-live-p buffer) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
97 (set-buffer buffer) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
98 (when (and (derived-mode-p 'vc-dir-mode) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
99 (eq vc-dir-backend backend) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
100 (string= default-directory dir)) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
101 (return buffer)))))))) |
96203 | 102 (or buf |
103 ;; Create a new buffer named BNAME. | |
106759 | 104 ;; We pass a filename to create-file-buffer because it is what |
105 ;; the function expects, and also what uniquify needs (if active) | |
106 (with-current-buffer (create-file-buffer (expand-file-name bname dir)) | |
96203 | 107 (cd dir) |
108 (vc-setup-buffer (current-buffer)) | |
109 ;; Reset the vc-parent-buffer-name so that it does not appear | |
110 ;; in the mode-line. | |
111 (setq vc-parent-buffer-name nil) | |
112 (current-buffer))))) | |
113 | |
114 (defvar vc-dir-menu-map | |
115 (let ((map (make-sparse-keymap "VC-dir"))) | |
116 (define-key map [quit] | |
117 '(menu-item "Quit" quit-window | |
118 :help "Quit")) | |
119 (define-key map [kill] | |
120 '(menu-item "Kill Update Command" vc-dir-kill-dir-status-process | |
121 :enable (vc-dir-busy) | |
122 :help "Kill the command that updates the directory buffer")) | |
123 (define-key map [refresh] | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
124 '(menu-item "Refresh" revert-buffer |
96203 | 125 :enable (not (vc-dir-busy)) |
126 :help "Refresh the contents of the directory buffer")) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
127 (define-key map [remup] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
128 '(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
|
129 :help "Hide up-to-date items from display")) |
96203 | 130 ;; Movement. |
131 (define-key map [sepmv] '("--")) | |
132 (define-key map [next-line] | |
133 '(menu-item "Next line" vc-dir-next-line | |
134 :help "Go to the next line" :keys "n")) | |
135 (define-key map [previous-line] | |
136 '(menu-item "Previous line" vc-dir-previous-line | |
137 :help "Go to the previous line")) | |
138 ;; Marking. | |
139 (define-key map [sepmrk] '("--")) | |
140 (define-key map [unmark-all] | |
141 '(menu-item "Unmark All" vc-dir-unmark-all-files | |
142 :help "Unmark all files that are in the same state as the current file\ | |
143 \nWith prefix argument unmark all files")) | |
144 (define-key map [unmark-previous] | |
145 '(menu-item "Unmark previous " vc-dir-unmark-file-up | |
146 :help "Move to the previous line and unmark the file")) | |
147 | |
148 (define-key map [mark-all] | |
149 '(menu-item "Mark All" vc-dir-mark-all-files | |
150 :help "Mark all files that are in the same state as the current file\ | |
151 \nWith prefix argument mark all files")) | |
152 (define-key map [unmark] | |
153 '(menu-item "Unmark" vc-dir-unmark | |
154 :help "Unmark the current file or all files in the region")) | |
155 | |
156 (define-key map [mark] | |
157 '(menu-item "Mark" vc-dir-mark | |
158 :help "Mark the current file or all files in the region")) | |
159 | |
160 (define-key map [sepopn] '("--")) | |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
161 (define-key map [qr] |
96964
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
162 '(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
|
163 :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
|
164 (define-key map [se] |
96964
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
165 '(menu-item "Search Files..." vc-dir-search |
96963
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
166 :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
|
167 (define-key map [ires] |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
168 '(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
|
169 :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
|
170 (define-key map [ise] |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
171 '(menu-item "Isearch Files..." vc-dir-isearch |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
172 :help "Incremental search a string in the marked files")) |
96203 | 173 (define-key map [open-other] |
174 '(menu-item "Open in other window" vc-dir-find-file-other-window | |
175 :help "Find the file on the current line, in another window")) | |
176 (define-key map [open] | |
177 '(menu-item "Open file" vc-dir-find-file | |
178 :help "Find the file on the current line")) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
179 (define-key map [sepvcdet] '("--")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
180 ;; 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
|
181 ;; ("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
|
182 (define-key map [ins] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
183 '(menu-item "Show File" vc-dir-show-fileentry |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
184 :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
|
185 (define-key map [annotate] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
186 '(menu-item "Annotate" vc-annotate |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
187 :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
|
188 (define-key map [diff] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
189 '(menu-item "Compare with Base Version" vc-diff |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
190 :help "Compare file set with the base version")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
191 (define-key map [log] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
192 '(menu-item "Show history" vc-print-log |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
193 :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
|
194 ;; VC commands. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
195 (define-key map [sepvccmd] '("--")) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
196 (define-key map [update] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
197 '(menu-item "Update to latest version" vc-update |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
198 :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
|
199 (define-key map [revert] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
200 '(menu-item "Revert to base version" vc-revert |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
201 :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
|
202 (define-key map [next-action] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
203 ;; FIXME: This really really really needs a better name! |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
204 ;; And a key binding too. |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
205 '(menu-item "Check In/Out" vc-next-action |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
206 :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
|
207 (define-key map [register] |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
208 '(menu-item "Register" vc-register |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
209 :help "Register file set into the version control system")) |
96203 | 210 map) |
101642
a2281d8c22e0
* vc-dir.el (vc-dir-menu-map, vc-dir-at-event, vc-dir-resynch-file):
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
211 "Menu for VC dir.") |
96203 | 212 |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
213 ;; 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
|
214 ;; vc-dir-menu-map. |
96203 | 215 (defun vc-dir-menu-map-filter (orig-binding) |
216 (when (and (symbolp orig-binding) (fboundp orig-binding)) | |
217 (setq orig-binding (indirect-function orig-binding))) | |
218 (let ((ext-binding | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
219 (when (derived-mode-p 'vc-dir-mode) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
220 (vc-call-backend vc-dir-backend 'extra-status-menu)))) |
96203 | 221 (if (null ext-binding) |
222 orig-binding | |
223 (append orig-binding | |
224 '("----") | |
225 ext-binding)))) | |
226 | |
227 (defvar vc-dir-mode-map | |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
228 (let ((map (make-sparse-keymap))) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
229 ;; VC commands |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
230 (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
|
231 (define-key map "=" 'vc-diff) ;; C-x v = |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
232 (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
|
233 (define-key map "+" 'vc-update) ;; C-x v + |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
234 (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
|
235 ;; More confusing than helpful, probably |
97210 | 236 ;;(define-key map "R" 'vc-revert) ;; u is taken by vc-dir-unmark. |
237 ;;(define-key map "A" 'vc-annotate) ;; g is taken by revert-buffer | |
238 ;; bound by `special-mode'. | |
96203 | 239 ;; Marking. |
240 (define-key map "m" 'vc-dir-mark) | |
241 (define-key map "M" 'vc-dir-mark-all-files) | |
242 (define-key map "u" 'vc-dir-unmark) | |
243 (define-key map "U" 'vc-dir-unmark-all-files) | |
244 (define-key map "\C-?" 'vc-dir-unmark-file-up) | |
245 (define-key map "\M-\C-?" 'vc-dir-unmark-all-files) | |
246 ;; Movement. | |
247 (define-key map "n" 'vc-dir-next-line) | |
248 (define-key map " " 'vc-dir-next-line) | |
249 (define-key map "\t" 'vc-dir-next-directory) | |
250 (define-key map "p" 'vc-dir-previous-line) | |
251 (define-key map [backtab] 'vc-dir-previous-directory) | |
252 ;;; Rebind paragraph-movement commands. | |
253 (define-key map "\M-}" 'vc-dir-next-directory) | |
254 (define-key map "\M-{" 'vc-dir-previous-directory) | |
255 (define-key map [C-down] 'vc-dir-next-directory) | |
256 (define-key map [C-up] 'vc-dir-previous-directory) | |
257 ;; The remainder. | |
258 (define-key map "f" 'vc-dir-find-file) | |
259 (define-key map "\C-m" 'vc-dir-find-file) | |
260 (define-key map "o" 'vc-dir-find-file-other-window) | |
261 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) | |
262 (define-key map [down-mouse-3] 'vc-dir-menu) | |
263 (define-key map [mouse-2] 'vc-dir-toggle-mark) | |
99133
be46fd14df8a
(vc-dir-mode-map): Add follow-link behavior.
Chong Yidong <cyd@stupidchicken.com>
parents:
98471
diff
changeset
|
264 (define-key map [follow-link] 'mouse-face) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
265 (define-key map "x" 'vc-dir-hide-up-to-date) |
107841
2cdeb4c70d45
(vc-dir-kill-line): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107537
diff
changeset
|
266 (define-key map [?\C-k] 'vc-dir-kill-line) |
96963
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
267 (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
|
268 (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
|
269 (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
|
270 (define-key map (kbd "M-s a M-C-s") 'vc-dir-isearch-regexp) |
96203 | 271 |
272 ;; Hook up the menu. | |
273 (define-key map [menu-bar vc-dir-mode] | |
274 `(menu-item | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
275 ;; 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
|
276 ;; vc-dir-menu-map. |
96203 | 277 "VC-dir" ,vc-dir-menu-map :filter vc-dir-menu-map-filter)) |
278 map) | |
279 "Keymap for directory buffer.") | |
280 | |
100483
15455ea10b4a
(vc-dir-at-event): Rename from vc-at-event. Change
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100475
diff
changeset
|
281 (defmacro vc-dir-at-event (event &rest body) |
101642
a2281d8c22e0
* vc-dir.el (vc-dir-menu-map, vc-dir-at-event, vc-dir-resynch-file):
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
282 "Evaluate BODY with point located at event-start of EVENT. |
a2281d8c22e0
* vc-dir.el (vc-dir-menu-map, vc-dir-at-event, vc-dir-resynch-file):
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
283 If BODY uses EVENT, it should be a variable, |
96203 | 284 otherwise it will be evaluated twice." |
100483
15455ea10b4a
(vc-dir-at-event): Rename from vc-at-event. Change
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100475
diff
changeset
|
285 (let ((posn (make-symbol "vc-dir-at-event-posn"))) |
100475
75d8b06be81f
(vc-at-event): Handle (tool-bar) events. Fix bug#1585.
Sam Steingold <sds@gnu.org>
parents:
99367
diff
changeset
|
286 `(save-excursion |
75d8b06be81f
(vc-at-event): Handle (tool-bar) events. Fix bug#1585.
Sam Steingold <sds@gnu.org>
parents:
99367
diff
changeset
|
287 (unless (equal ,event '(tool-bar)) |
75d8b06be81f
(vc-at-event): Handle (tool-bar) events. Fix bug#1585.
Sam Steingold <sds@gnu.org>
parents:
99367
diff
changeset
|
288 (let ((,posn (event-start ,event))) |
75d8b06be81f
(vc-at-event): Handle (tool-bar) events. Fix bug#1585.
Sam Steingold <sds@gnu.org>
parents:
99367
diff
changeset
|
289 (set-buffer (window-buffer (posn-window ,posn))) |
75d8b06be81f
(vc-at-event): Handle (tool-bar) events. Fix bug#1585.
Sam Steingold <sds@gnu.org>
parents:
99367
diff
changeset
|
290 (goto-char (posn-point ,posn)))) |
75d8b06be81f
(vc-at-event): Handle (tool-bar) events. Fix bug#1585.
Sam Steingold <sds@gnu.org>
parents:
99367
diff
changeset
|
291 ,@body))) |
96203 | 292 |
293 (defun vc-dir-menu (e) | |
97210 | 294 "Popup the VC dir menu." |
96203 | 295 (interactive "e") |
100483
15455ea10b4a
(vc-dir-at-event): Rename from vc-at-event. Change
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100475
diff
changeset
|
296 (vc-dir-at-event e (popup-menu vc-dir-menu-map e))) |
96203 | 297 |
298 (defvar vc-dir-tool-bar-map | |
299 (let ((map (make-sparse-keymap))) | |
300 (tool-bar-local-item-from-menu 'vc-dir-find-file "open" | |
301 map vc-dir-mode-map) | |
302 (tool-bar-local-item "bookmark_add" | |
303 'vc-dir-toggle-mark 'vc-dir-toggle-mark map | |
108024
4d8277a44bb4
Gtk tool bars can be text, icons with text or just icons.
Jan D. <jan.h.d@swipnet.se>
parents:
107841
diff
changeset
|
304 :help "Toggle mark on current item" |
4d8277a44bb4
Gtk tool bars can be text, icons with text or just icons.
Jan D. <jan.h.d@swipnet.se>
parents:
107841
diff
changeset
|
305 :label "Toggle Mark") |
96203 | 306 (tool-bar-local-item-from-menu 'vc-dir-previous-line "left-arrow" |
307 map vc-dir-mode-map | |
308 :rtl "right-arrow") | |
309 (tool-bar-local-item-from-menu 'vc-dir-next-line "right-arrow" | |
310 map vc-dir-mode-map | |
311 :rtl "left-arrow") | |
312 (tool-bar-local-item-from-menu 'vc-print-log "info" | |
313 map vc-dir-mode-map) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
314 (tool-bar-local-item-from-menu 'revert-buffer "refresh" |
96203 | 315 map vc-dir-mode-map) |
316 (tool-bar-local-item-from-menu 'nonincremental-search-forward | |
108024
4d8277a44bb4
Gtk tool bars can be text, icons with text or just icons.
Jan D. <jan.h.d@swipnet.se>
parents:
107841
diff
changeset
|
317 "search" map nil |
4d8277a44bb4
Gtk tool bars can be text, icons with text or just icons.
Jan D. <jan.h.d@swipnet.se>
parents:
107841
diff
changeset
|
318 :label "Search") |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
319 (tool-bar-local-item-from-menu 'vc-dir-query-replace-regexp |
108024
4d8277a44bb4
Gtk tool bars can be text, icons with text or just icons.
Jan D. <jan.h.d@swipnet.se>
parents:
107841
diff
changeset
|
320 "search-replace" map vc-dir-mode-map |
4d8277a44bb4
Gtk tool bars can be text, icons with text or just icons.
Jan D. <jan.h.d@swipnet.se>
parents:
107841
diff
changeset
|
321 :label "Replace") |
96203 | 322 (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel" |
108024
4d8277a44bb4
Gtk tool bars can be text, icons with text or just icons.
Jan D. <jan.h.d@swipnet.se>
parents:
107841
diff
changeset
|
323 map vc-dir-mode-map |
4d8277a44bb4
Gtk tool bars can be text, icons with text or just icons.
Jan D. <jan.h.d@swipnet.se>
parents:
107841
diff
changeset
|
324 :label "Cancel") |
96203 | 325 (tool-bar-local-item-from-menu 'quit-window "exit" |
326 map vc-dir-mode-map) | |
327 map)) | |
328 | |
329 (defun vc-dir-node-directory (node) | |
330 ;; Compute the directory for NODE. | |
105424
098f8a47a308
Fix typos in comments.
Juanma Barranquero <lekktu@gmail.com>
parents:
105293
diff
changeset
|
331 ;; If it's a directory node, get it from the node. |
96203 | 332 (let ((data (ewoc-data node))) |
333 (or (vc-dir-fileinfo->directory data) | |
334 ;; Otherwise compute it from the file name. | |
335 (file-name-directory | |
104615
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
336 (directory-file-name |
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
337 (expand-file-name |
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
338 (vc-dir-fileinfo->name data))))))) |
96203 | 339 |
340 (defun vc-dir-update (entries buffer &optional noinsert) | |
341 "Update BUFFER's ewoc from the list of ENTRIES. | |
342 If NOINSERT, ignore elements on ENTRIES which are not in the ewoc." | |
343 ;; Add ENTRIES to the vc-dir buffer BUFFER. | |
344 (with-current-buffer buffer | |
345 ;; Insert the entries sorted by name into the ewoc. | |
346 ;; We assume the ewoc is sorted too, which should be the | |
347 ;; case if we always add entries with vc-dir-update. | |
348 (setq entries | |
349 ;; Sort: first files and then subdirectories. | |
350 ;; XXX: this is VERY inefficient, it computes the directory | |
351 ;; names too many times | |
352 (sort entries | |
353 (lambda (entry1 entry2) | |
104615
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
354 (let ((dir1 (file-name-directory |
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
355 (directory-file-name (expand-file-name (car entry1))))) |
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
356 (dir2 (file-name-directory |
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
357 (directory-file-name (expand-file-name (car entry2)))))) |
96203 | 358 (cond |
359 ((string< dir1 dir2) t) | |
360 ((not (string= dir1 dir2)) nil) | |
361 ((string< (car entry1) (car entry2)))))))) | |
362 ;; Insert directory entries in the right places. | |
363 (let ((entry (car entries)) | |
102260
a52c9332c41c
(vc-dir-update): Make sure ./ is always first in the listing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101940
diff
changeset
|
364 (node (ewoc-nth vc-ewoc 0)) |
a52c9332c41c
(vc-dir-update): Make sure ./ is always first in the listing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101940
diff
changeset
|
365 (dotname (file-relative-name default-directory))) |
96203 | 366 ;; Insert . if it is not present. |
367 (unless node | |
102260
a52c9332c41c
(vc-dir-update): Make sure ./ is always first in the listing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101940
diff
changeset
|
368 (ewoc-enter-last |
a52c9332c41c
(vc-dir-update): Make sure ./ is always first in the listing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101940
diff
changeset
|
369 vc-ewoc (vc-dir-create-fileinfo |
105293
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
370 dotname nil nil nil default-directory)) |
96203 | 371 (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
|
372 |
96203 | 373 (while (and entry node) |
374 (let* ((entryfile (car entry)) | |
104615
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
375 (entrydir (file-name-directory (directory-file-name |
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
376 (expand-file-name entryfile)))) |
96203 | 377 (nodedir (vc-dir-node-directory node))) |
378 (cond | |
379 ;; First try to find the directory. | |
380 ((string-lessp nodedir entrydir) | |
381 (setq node (ewoc-next vc-ewoc node))) | |
382 ((string-equal nodedir entrydir) | |
383 ;; Found the directory, find the place for the file name. | |
384 (let ((nodefile (vc-dir-fileinfo->name (ewoc-data node)))) | |
385 (cond | |
102260
a52c9332c41c
(vc-dir-update): Make sure ./ is always first in the listing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101940
diff
changeset
|
386 ((string= nodefile dotname) |
a52c9332c41c
(vc-dir-update): Make sure ./ is always first in the listing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101940
diff
changeset
|
387 (setq node (ewoc-next vc-ewoc node))) |
96203 | 388 ((string-lessp nodefile entryfile) |
389 (setq node (ewoc-next vc-ewoc node))) | |
390 ((string-equal nodefile entryfile) | |
391 (setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry)) | |
392 (setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry)) | |
393 (setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil) | |
394 (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
|
395 (setq entries (cdr entries)) |
96203 | 396 (setq entry (car entries)) |
397 (setq node (ewoc-next vc-ewoc node))) | |
398 (t | |
399 (ewoc-enter-before vc-ewoc node | |
400 (apply 'vc-dir-create-fileinfo entry)) | |
401 (setq entries (cdr entries)) | |
402 (setq entry (car entries)))))) | |
403 (t | |
404 ;; We might need to insert a directory node if the | |
405 ;; previous node was in a different directory. | |
406 (let* ((rd (file-relative-name entrydir)) | |
407 (prev-node (ewoc-prev vc-ewoc node)) | |
408 (prev-dir (vc-dir-node-directory prev-node))) | |
409 (unless (string-equal entrydir prev-dir) | |
410 (ewoc-enter-before | |
411 vc-ewoc node (vc-dir-create-fileinfo rd nil nil nil entrydir)))) | |
412 ;; Now insert the node itself. | |
413 (ewoc-enter-before vc-ewoc node | |
414 (apply 'vc-dir-create-fileinfo entry)) | |
415 (setq entries (cdr entries) entry (car entries)))))) | |
416 ;; We're past the last node, all remaining entries go to the end. | |
417 (unless (or node noinsert) | |
418 (let ((lastdir (vc-dir-node-directory (ewoc-nth vc-ewoc -1)))) | |
419 (dolist (entry entries) | |
104615
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
420 (let ((entrydir (file-name-directory |
6915f976dcd2
(vc-dir-node-directory, vc-dir-update): Get the parent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
421 (directory-file-name (expand-file-name (car entry)))))) |
96203 | 422 ;; Insert a directory node if needed. |
423 (unless (string-equal lastdir entrydir) | |
424 (setq lastdir entrydir) | |
425 (let ((rd (file-relative-name entrydir))) | |
426 (ewoc-enter-last | |
427 vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir)))) | |
428 ;; Now insert the node itself. | |
429 (ewoc-enter-last vc-ewoc | |
430 (apply 'vc-dir-create-fileinfo entry))))))))) | |
431 | |
432 (defun vc-dir-busy () | |
433 (and (buffer-live-p vc-dir-process-buffer) | |
434 (get-buffer-process vc-dir-process-buffer))) | |
435 | |
436 (defun vc-dir-kill-dir-status-process () | |
437 "Kill the temporary buffer and associated process." | |
438 (interactive) | |
439 (when (buffer-live-p vc-dir-process-buffer) | |
440 (let ((proc (get-buffer-process vc-dir-process-buffer))) | |
441 (when proc (delete-process proc)) | |
442 (setq vc-dir-process-buffer nil) | |
443 (setq mode-line-process nil)))) | |
444 | |
445 (defun vc-dir-kill-query () | |
446 ;; Make sure that when the status buffer is killed the update | |
447 ;; process running in background is also killed. | |
448 (if (vc-dir-busy) | |
449 (when (y-or-n-p "Status update process running, really kill status buffer? ") | |
450 (vc-dir-kill-dir-status-process) | |
451 t) | |
452 t)) | |
453 | |
454 (defun vc-dir-next-line (arg) | |
455 "Go to the next line. | |
456 If a prefix argument is given, move by that many lines." | |
457 (interactive "p") | |
458 (with-no-warnings | |
459 (ewoc-goto-next vc-ewoc arg) | |
460 (vc-dir-move-to-goal-column))) | |
461 | |
462 (defun vc-dir-previous-line (arg) | |
463 "Go to the previous line. | |
464 If a prefix argument is given, move by that many lines." | |
465 (interactive "p") | |
466 (ewoc-goto-prev vc-ewoc arg) | |
467 (vc-dir-move-to-goal-column)) | |
468 | |
469 (defun vc-dir-next-directory () | |
470 "Go to the next directory." | |
471 (interactive) | |
472 (let ((orig (point))) | |
473 (if | |
474 (catch 'foundit | |
475 (while t | |
476 (let* ((next (ewoc-next vc-ewoc (ewoc-locate vc-ewoc)))) | |
477 (cond ((not next) | |
478 (throw 'foundit t)) | |
479 (t | |
480 (progn | |
481 (ewoc-goto-node vc-ewoc next) | |
482 (vc-dir-move-to-goal-column) | |
483 (if (vc-dir-fileinfo->directory (ewoc-data next)) | |
484 (throw 'foundit nil)))))))) | |
485 (goto-char orig)))) | |
486 | |
487 (defun vc-dir-previous-directory () | |
488 "Go to the previous directory." | |
489 (interactive) | |
490 (let ((orig (point))) | |
491 (if | |
492 (catch 'foundit | |
493 (while t | |
494 (let* ((prev (ewoc-prev vc-ewoc (ewoc-locate vc-ewoc)))) | |
495 (cond ((not prev) | |
496 (throw 'foundit t)) | |
497 (t | |
498 (progn | |
499 (ewoc-goto-node vc-ewoc prev) | |
500 (vc-dir-move-to-goal-column) | |
501 (if (vc-dir-fileinfo->directory (ewoc-data prev)) | |
502 (throw 'foundit nil)))))))) | |
503 (goto-char orig)))) | |
504 | |
505 (defun vc-dir-mark-unmark (mark-unmark-function) | |
506 (if (use-region-p) | |
507 (let ((firstl (line-number-at-pos (region-beginning))) | |
508 (lastl (line-number-at-pos (region-end)))) | |
509 (save-excursion | |
510 (goto-char (region-beginning)) | |
511 (while (<= (line-number-at-pos) lastl) | |
512 (funcall mark-unmark-function)))) | |
513 (funcall mark-unmark-function))) | |
514 | |
515 (defun vc-dir-parent-marked-p (arg) | |
516 ;; Return nil if none of the parent directories of arg is marked. | |
517 (let* ((argdir (vc-dir-node-directory arg)) | |
518 (arglen (length argdir)) | |
519 (crt arg) | |
520 data dir) | |
521 ;; Go through the predecessors, checking if any directory that is | |
522 ;; a parent is marked. | |
523 (while (setq crt (ewoc-prev vc-ewoc crt)) | |
524 (setq data (ewoc-data crt)) | |
525 (setq dir (vc-dir-node-directory crt)) | |
526 (when (and (vc-dir-fileinfo->directory data) | |
527 (vc-string-prefix-p dir argdir)) | |
528 (when (vc-dir-fileinfo->marked data) | |
529 (error "Cannot mark `%s', parent directory `%s' marked" | |
530 (vc-dir-fileinfo->name (ewoc-data arg)) | |
531 (vc-dir-fileinfo->name data))))) | |
532 nil)) | |
533 | |
534 (defun vc-dir-children-marked-p (arg) | |
535 ;; Return nil if none of the children of arg is marked. | |
536 (let* ((argdir-re (concat "\\`" (regexp-quote (vc-dir-node-directory arg)))) | |
537 (is-child t) | |
538 (crt arg) | |
539 data dir) | |
540 (while (and is-child (setq crt (ewoc-next vc-ewoc crt))) | |
541 (setq data (ewoc-data crt)) | |
542 (setq dir (vc-dir-node-directory crt)) | |
543 (if (string-match argdir-re dir) | |
544 (when (vc-dir-fileinfo->marked data) | |
545 (error "Cannot mark `%s', child `%s' marked" | |
546 (vc-dir-fileinfo->name (ewoc-data arg)) | |
547 (vc-dir-fileinfo->name data))) | |
548 ;; We are done, we got to an entry that is not a child of `arg'. | |
549 (setq is-child nil))) | |
550 nil)) | |
551 | |
552 (defun vc-dir-mark-file (&optional arg) | |
553 ;; Mark ARG or the current file and move to the next line. | |
554 (let* ((crt (or arg (ewoc-locate vc-ewoc))) | |
555 (file (ewoc-data crt)) | |
556 (isdir (vc-dir-fileinfo->directory file))) | |
557 (when (or (and isdir (not (vc-dir-children-marked-p crt))) | |
558 (and (not isdir) (not (vc-dir-parent-marked-p crt)))) | |
559 (setf (vc-dir-fileinfo->marked file) t) | |
560 (ewoc-invalidate vc-ewoc crt) | |
561 (unless (or arg (mouse-event-p last-command-event)) | |
562 (vc-dir-next-line 1))))) | |
563 | |
564 (defun vc-dir-mark () | |
565 "Mark the current file or all files in the region. | |
566 If the region is active, mark all the files in the region. | |
567 Otherwise mark the file on the current line and move to the next | |
568 line." | |
569 (interactive) | |
570 (vc-dir-mark-unmark 'vc-dir-mark-file)) | |
571 | |
572 (defun vc-dir-mark-all-files (arg) | |
573 "Mark all files with the same state as the current one. | |
574 With a prefix argument mark all files. | |
575 If the current entry is a directory, mark all child files. | |
576 | |
577 The commands operate on files that are on the same state. | |
578 This command is intended to make it easy to select all files that | |
579 share the same state." | |
580 (interactive "P") | |
581 (if arg | |
582 ;; Mark all files. | |
583 (progn | |
584 ;; First check that no directory is marked, we can't mark | |
585 ;; files in that case. | |
586 (ewoc-map | |
587 (lambda (filearg) | |
588 (when (and (vc-dir-fileinfo->directory filearg) | |
589 (vc-dir-fileinfo->marked filearg)) | |
590 (error "Cannot mark all files, directory `%s' marked" | |
591 (vc-dir-fileinfo->name filearg)))) | |
592 vc-ewoc) | |
593 (ewoc-map | |
594 (lambda (filearg) | |
595 (unless (vc-dir-fileinfo->marked filearg) | |
596 (setf (vc-dir-fileinfo->marked filearg) t) | |
597 t)) | |
598 vc-ewoc)) | |
599 (let ((data (ewoc-data (ewoc-locate vc-ewoc)))) | |
600 (if (vc-dir-fileinfo->directory data) | |
601 ;; It's a directory, mark child files. | |
602 (let ((crt (ewoc-locate vc-ewoc))) | |
603 (unless (vc-dir-children-marked-p crt) | |
604 (while (setq crt (ewoc-next vc-ewoc crt)) | |
605 (let ((crt-data (ewoc-data crt))) | |
606 (unless (vc-dir-fileinfo->directory crt-data) | |
607 (setf (vc-dir-fileinfo->marked crt-data) t) | |
608 (ewoc-invalidate vc-ewoc crt)))))) | |
609 ;; It's a file | |
610 (let ((state (vc-dir-fileinfo->state data)) | |
611 (crt (ewoc-nth vc-ewoc 0))) | |
612 (while crt | |
613 (let ((crt-data (ewoc-data crt))) | |
614 (when (and (not (vc-dir-fileinfo->marked crt-data)) | |
615 (eq (vc-dir-fileinfo->state crt-data) state) | |
616 (not (vc-dir-fileinfo->directory crt-data))) | |
617 (vc-dir-mark-file crt))) | |
618 (setq crt (ewoc-next vc-ewoc crt)))))))) | |
619 | |
620 (defun vc-dir-unmark-file () | |
621 ;; Unmark the current file and move to the next line. | |
622 (let* ((crt (ewoc-locate vc-ewoc)) | |
623 (file (ewoc-data crt))) | |
624 (setf (vc-dir-fileinfo->marked file) nil) | |
625 (ewoc-invalidate vc-ewoc crt) | |
626 (unless (mouse-event-p last-command-event) | |
627 (vc-dir-next-line 1)))) | |
628 | |
629 (defun vc-dir-unmark () | |
630 "Unmark the current file or all files in the region. | |
631 If the region is active, unmark all the files in the region. | |
632 Otherwise mark the file on the current line and move to the next | |
633 line." | |
634 (interactive) | |
635 (vc-dir-mark-unmark 'vc-dir-unmark-file)) | |
636 | |
637 (defun vc-dir-unmark-file-up () | |
638 "Move to the previous line and unmark the file." | |
639 (interactive) | |
640 ;; If we're on the first line, we won't move up, but we will still | |
641 ;; remove the mark. This seems a bit odd but it is what buffer-menu | |
642 ;; does. | |
643 (let* ((prev (ewoc-goto-prev vc-ewoc 1)) | |
644 (file (ewoc-data prev))) | |
645 (setf (vc-dir-fileinfo->marked file) nil) | |
646 (ewoc-invalidate vc-ewoc prev) | |
647 (vc-dir-move-to-goal-column))) | |
648 | |
649 (defun vc-dir-unmark-all-files (arg) | |
650 "Unmark all files with the same state as the current one. | |
651 With a prefix argument unmark all files. | |
652 If the current entry is a directory, unmark all the child files. | |
653 | |
654 The commands operate on files that are on the same state. | |
655 This command is intended to make it easy to deselect all files | |
656 that share the same state." | |
657 (interactive "P") | |
658 (if arg | |
659 (ewoc-map | |
660 (lambda (filearg) | |
661 (when (vc-dir-fileinfo->marked filearg) | |
662 (setf (vc-dir-fileinfo->marked filearg) nil) | |
663 t)) | |
664 vc-ewoc) | |
665 (let* ((crt (ewoc-locate vc-ewoc)) | |
666 (data (ewoc-data crt))) | |
667 (if (vc-dir-fileinfo->directory data) | |
668 ;; It's a directory, unmark child files. | |
669 (while (setq crt (ewoc-next vc-ewoc crt)) | |
670 (let ((crt-data (ewoc-data crt))) | |
671 (unless (vc-dir-fileinfo->directory crt-data) | |
672 (setf (vc-dir-fileinfo->marked crt-data) nil) | |
673 (ewoc-invalidate vc-ewoc crt)))) | |
674 ;; It's a file | |
675 (let ((crt-state (vc-dir-fileinfo->state (ewoc-data crt)))) | |
676 (ewoc-map | |
677 (lambda (filearg) | |
678 (when (and (vc-dir-fileinfo->marked filearg) | |
679 (eq (vc-dir-fileinfo->state filearg) crt-state)) | |
680 (setf (vc-dir-fileinfo->marked filearg) nil) | |
681 t)) | |
682 vc-ewoc)))))) | |
683 | |
684 (defun vc-dir-toggle-mark-file () | |
685 (let* ((crt (ewoc-locate vc-ewoc)) | |
686 (file (ewoc-data crt))) | |
687 (if (vc-dir-fileinfo->marked file) | |
688 (vc-dir-unmark-file) | |
689 (vc-dir-mark-file)))) | |
690 | |
691 (defun vc-dir-toggle-mark (e) | |
692 (interactive "e") | |
100483
15455ea10b4a
(vc-dir-at-event): Rename from vc-at-event. Change
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100475
diff
changeset
|
693 (vc-dir-at-event e (vc-dir-mark-unmark 'vc-dir-toggle-mark-file))) |
96203 | 694 |
695 (defun vc-dir-delete-file () | |
696 "Delete the marked files, or the current file if no marks." | |
697 (interactive) | |
698 (mapc 'vc-delete-file (or (vc-dir-marked-files) | |
699 (list (vc-dir-current-file))))) | |
700 | |
701 (defun vc-dir-find-file () | |
702 "Find the file on the current line." | |
703 (interactive) | |
704 (find-file (vc-dir-current-file))) | |
705 | |
101924
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
706 (defun vc-dir-find-file-other-window (&optional event) |
96203 | 707 "Find the file on the current line, in another window." |
101924
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
708 (interactive (list last-nonmenu-event)) |
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
709 (if event (posn-set-point (event-end event))) |
96203 | 710 (find-file-other-window (vc-dir-current-file))) |
711 | |
96964
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
712 (defun vc-dir-isearch () |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
713 "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
|
714 (interactive) |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
715 (multi-isearch-files |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
716 (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
|
717 |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
718 (defun vc-dir-isearch-regexp () |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
719 "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
|
720 (interactive) |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
721 (multi-isearch-files-regexp |
bd2850789ce2
(vc-dir-search, vc-dir-isearch)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96963
diff
changeset
|
722 (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
|
723 |
96963
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
724 (defun vc-dir-search (regexp) |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
725 "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
|
726 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
|
727 Stops when a match is found. |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
728 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
|
729 (interactive "sSearch marked files (regexp): ") |
4abff057d348
(vc-dir-search): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96888
diff
changeset
|
730 (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
|
731 |
96500
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
732 (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
|
733 "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
|
734 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
|
735 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
|
736 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
|
737 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
|
738 with the command \\[tags-loop-continue]." |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
739 ;; 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
|
740 ;; 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
|
741 ;; duplicating it here. |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
742 (interactive |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
743 (let ((common |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
744 (query-replace-read-args |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
745 "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
|
746 (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
|
747 (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
|
748 (let ((buffer (get-file-buffer file))) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
749 (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
|
750 buffer-read-only)) |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
751 (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
|
752 (tags-query-replace from to delimited |
4c68d664c39b
(vc-dir-query-replace-regexp): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96474
diff
changeset
|
753 '(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
|
754 |
96203 | 755 (defun vc-dir-current-file () |
756 (let ((node (ewoc-locate vc-ewoc))) | |
757 (unless node | |
758 (error "No file available")) | |
759 (expand-file-name (vc-dir-fileinfo->name (ewoc-data node))))) | |
760 | |
761 (defun vc-dir-marked-files () | |
762 "Return the list of marked files." | |
763 (mapcar | |
764 (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) | |
765 (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) | |
766 | |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
767 (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
|
768 "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
|
769 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
|
770 child files." |
96203 | 771 (let ((crt (ewoc-nth vc-ewoc 0)) |
772 result) | |
773 (while crt | |
774 (let ((crt-data (ewoc-data crt))) | |
775 (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
|
776 ;; FIXME: use vc-dir-child-files-and-states here instead of duplicating it. |
96203 | 777 (if (vc-dir-fileinfo->directory crt-data) |
778 (let* ((dir (vc-dir-fileinfo->directory crt-data)) | |
779 (dirlen (length dir)) | |
780 data) | |
781 (while | |
782 (and (setq crt (ewoc-next vc-ewoc crt)) | |
783 (vc-string-prefix-p dir | |
784 (progn | |
785 (setq data (ewoc-data crt)) | |
786 (vc-dir-node-directory crt)))) | |
787 (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
|
788 (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
|
789 (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
|
790 (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
|
791 result)))) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
792 (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
|
793 (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
|
794 result) |
96203 | 795 (setq crt (ewoc-next vc-ewoc crt))) |
796 (setq crt (ewoc-next vc-ewoc crt))))) | |
97696
5d466e3c0ab7
(vc-dir-marked-only-files-and-states):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97660
diff
changeset
|
797 (nreverse result))) |
96203 | 798 |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
799 (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
|
800 "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
|
801 If it is a file, return the corresponding cons for the file itself." |
96203 | 802 (let* ((crt (ewoc-locate vc-ewoc)) |
803 (crt-data (ewoc-data crt)) | |
804 result) | |
805 (if (vc-dir-fileinfo->directory crt-data) | |
806 (let* ((dir (vc-dir-fileinfo->directory crt-data)) | |
807 (dirlen (length dir)) | |
808 data) | |
809 (while | |
810 (and (setq crt (ewoc-next vc-ewoc crt)) | |
811 (vc-string-prefix-p dir (progn | |
812 (setq data (ewoc-data crt)) | |
813 (vc-dir-node-directory crt)))) | |
814 (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
|
815 (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
|
816 (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
|
817 (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
|
818 result)))) |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
819 (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
|
820 (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
|
821 (vc-dir-fileinfo->state crt-data)) result)) |
97696
5d466e3c0ab7
(vc-dir-marked-only-files-and-states):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97660
diff
changeset
|
822 (nreverse result))) |
96203 | 823 |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
824 (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
|
825 (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
|
826 (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
|
827 (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
|
828 ;; 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
|
829 ;; 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
|
830 (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
|
831 (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
|
832 (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
|
833 '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
|
834 (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
|
835 |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
836 (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
|
837 ;; 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
|
838 ;; 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
|
839 (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
|
840 children |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
841 dname) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
842 ;; Find DIR |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
843 (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
|
844 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
|
845 (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
|
846 (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
|
847 dirname |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
848 (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
|
849 (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
|
850 (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
|
851 (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
|
852 (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
|
853 children)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
854 |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
855 (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
|
856 ;; 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
|
857 ;; 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
|
858 (let ((files (vc-dir-find-child-files dirname)) |
105293
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
859 (ddir default-directory) |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
860 fileentries) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
861 (when files |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
862 (dolist (crt files) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
863 (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
|
864 fileentries)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96500
diff
changeset
|
865 (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
|
866 |
96203 | 867 (defun vc-dir-resynch-file (&optional fname) |
101642
a2281d8c22e0
* vc-dir.el (vc-dir-menu-map, vc-dir-at-event, vc-dir-resynch-file):
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
868 "Update the entries for FNAME 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
|
869 (let ((file (or fname (expand-file-name buffer-file-name))) |
105293
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
870 (drop '())) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
871 (save-current-buffer |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
872 ;; look for a vc-dir buffer that might show this file. |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
873 (dolist (status-buf vc-dir-buffers) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
874 (if (not (buffer-live-p status-buf)) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
875 (push status-buf drop) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
876 (set-buffer status-buf) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
877 (if (not (derived-mode-p 'vc-dir-mode)) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
878 (push status-buf drop) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
879 (let ((ddir default-directory)) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
880 (when (vc-string-prefix-p ddir file) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
881 (if (file-directory-p file) |
106887
b9c9ec129ae5
(vc-dir-resynch-file): Update the vc-dir header when
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
882 (progn |
b9c9ec129ae5
(vc-dir-resynch-file): Update the vc-dir header when
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
883 (vc-dir-resync-directory-files file) |
b9c9ec129ae5
(vc-dir-resynch-file): Update the vc-dir header when
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
884 (ewoc-set-hf vc-ewoc |
b9c9ec129ae5
(vc-dir-resynch-file): Update the vc-dir header when
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
885 (vc-dir-headers vc-dir-backend default-directory) "")) |
105293
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
886 (let ((state (vc-dir-recompute-file-state file ddir))) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
887 (vc-dir-update |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
888 (list state) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
889 status-buf (eq (cadr state) 'up-to-date)))))))))) |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
890 ;; Remove out-of-date entries from vc-dir-buffers. |
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
891 (dolist (b drop) (setq vc-dir-buffers (delq b vc-dir-buffers))))) |
96203 | 892 |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
893 (defvar use-vc-backend) ;; dynamically bound |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
894 |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
895 (define-derived-mode vc-dir-mode special-mode "VC dir" |
97210 | 896 "Major mode for VC directory buffers. |
96203 | 897 Marking/Unmarking key bindings and actions: |
101718
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
898 m - mark a file/directory |
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
899 - if the region is active, mark all the files in region. |
96203 | 900 Restrictions: - a file cannot be marked if any parent directory is marked |
901 - a directory cannot be marked if any child file or | |
902 directory is marked | |
101718
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
903 u - unmark a file/directory |
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
904 - if the region is active, unmark all the files in region. |
96203 | 905 M - if the cursor is on a file: mark all the files with the same state as |
906 the current file | |
907 - if the cursor is on a directory: mark all child files | |
908 - with a prefix argument: mark all files | |
909 U - if the cursor is on a file: unmark all the files with the same state | |
910 as the current file | |
911 - if the cursor is on a directory: unmark all child files | |
912 - with a prefix argument: unmark all files | |
101718
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
913 mouse-2 - toggles the mark state |
96203 | 914 |
97210 | 915 VC commands |
101718
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
916 VC commands in the `C-x v' prefix can be used. |
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
917 VC commands act on the marked entries. If nothing is marked, VC |
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
918 commands act on the current entry. |
97210 | 919 |
920 Search & Replace | |
921 S - searches the marked files | |
922 Q - does a query replace on the marked files | |
923 M-s a C-s - does an isearch on the marked files | |
97315
b51913497dd3
(vc-dir-mode): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97210
diff
changeset
|
924 M-s a C-M-s - does a regexp isearch on the marked files |
97210 | 925 If nothing is marked, these commands act on the current entry. |
926 When a directory is current or marked, the Search & Replace | |
101718
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
927 commands act on the child files of that directory that are displayed in |
e5e2e4109ea1
(vc-dir-mode): Fix docstring.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101717
diff
changeset
|
928 the *vc-dir* buffer. |
96203 | 929 |
930 \\{vc-dir-mode-map}" | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
931 (set (make-local-variable 'vc-dir-backend) use-vc-backend) |
96203 | 932 (setq buffer-read-only t) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
933 (when (boundp 'tool-bar-map) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
934 (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)) |
96203 | 935 (let ((buffer-read-only nil)) |
936 (erase-buffer) | |
937 (set (make-local-variable 'vc-dir-process-buffer) nil) | |
99159
b0dce7f34dda
* vc.el: Rename VC methods that were missed when vc-status was
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99133
diff
changeset
|
938 (set (make-local-variable 'vc-ewoc) (ewoc-create #'vc-dir-printer)) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
939 (set (make-local-variable 'revert-buffer-function) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
940 'vc-dir-revert-buffer-function) |
106759 | 941 (setq list-buffers-directory (expand-file-name "*vc-dir*" default-directory)) |
105293
8bfe20e0336c
* vc-hooks.el (vc-dir-buffers): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105196
diff
changeset
|
942 (add-to-list 'vc-dir-buffers (current-buffer)) |
96203 | 943 ;; Make sure that if the directory buffer is killed, the update |
944 ;; process running in the background is also killed. | |
945 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) | |
107374
dc9565b08f10
Add .dir-locals.el support for file-less buffers.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106887
diff
changeset
|
946 (hack-dir-local-variables-non-file-buffer) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
947 (vc-dir-refresh))) |
96203 | 948 |
949 (defun vc-dir-headers (backend dir) | |
950 "Display the headers in the *VC dir* buffer. | |
99159
b0dce7f34dda
* vc.el: Rename VC methods that were missed when vc-status was
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99133
diff
changeset
|
951 It calls the `dir-extra-headers' backend method to display backend |
96203 | 952 specific headers." |
953 (concat | |
99367
ce0076e88ed4
(vc-dir-headers): Undo previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99361
diff
changeset
|
954 ;; First layout the common headers. |
96203 | 955 (propertize "VC backend : " 'face 'font-lock-type-face) |
956 (propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face) | |
957 (propertize "Working dir: " 'face 'font-lock-type-face) | |
107537
7c9abe9e21d1
* vc-dir.el (vc-dir-headers): Abbreviate the working dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107374
diff
changeset
|
958 (propertize (format "%s\n" (abbreviate-file-name dir)) |
7c9abe9e21d1
* vc-dir.el (vc-dir-headers): Abbreviate the working dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107374
diff
changeset
|
959 'face 'font-lock-variable-name-face) |
99367
ce0076e88ed4
(vc-dir-headers): Undo previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99361
diff
changeset
|
960 ;; Then the backend specific ones. |
ce0076e88ed4
(vc-dir-headers): Undo previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99361
diff
changeset
|
961 (vc-call-backend backend 'dir-extra-headers dir) |
ce0076e88ed4
(vc-dir-headers): Undo previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99361
diff
changeset
|
962 "\n")) |
96203 | 963 |
964 (defun vc-dir-refresh-files (files default-state) | |
965 "Refresh some files in the *VC-dir* buffer." | |
966 (let ((def-dir default-directory) | |
967 (backend vc-dir-backend)) | |
968 (vc-set-mode-line-busy-indicator) | |
969 ;; Call the `dir-status-file' backend function. | |
970 ;; `dir-status-file' is supposed to be asynchronous. | |
971 ;; It should compute the results, and then call the function | |
972 ;; passed as an argument in order to update the vc-dir buffer | |
973 ;; with the results. | |
974 (unless (buffer-live-p vc-dir-process-buffer) | |
975 (setq vc-dir-process-buffer | |
976 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) | |
977 (lexical-let ((buffer (current-buffer))) | |
978 (with-current-buffer vc-dir-process-buffer | |
979 (cd def-dir) | |
980 (erase-buffer) | |
981 (vc-call-backend | |
982 backend 'dir-status-files def-dir files default-state | |
983 (lambda (entries &optional more-to-come) | |
984 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. | |
985 ;; If MORE-TO-COME is true, then more updates will come from | |
986 ;; the asynchronous process. | |
987 (with-current-buffer buffer | |
988 (vc-dir-update entries buffer) | |
989 (unless more-to-come | |
990 (setq mode-line-process nil) | |
991 ;; Remove the ones that haven't been updated at all. | |
992 ;; Those not-updated are those whose state is nil because the | |
993 ;; file/dir doesn't exist and isn't versioned. | |
994 (ewoc-filter vc-ewoc | |
995 (lambda (info) | |
996 ;; The state for directory entries might | |
997 ;; have been changed to 'up-to-date, | |
998 ;; reset it, othewise it will be removed when doing 'x' | |
999 ;; next time. | |
1000 ;; FIXME: There should be a more elegant way to do this. | |
1001 (when (and (vc-dir-fileinfo->directory info) | |
1002 (eq (vc-dir-fileinfo->state info) | |
1003 'up-to-date)) | |
1004 (setf (vc-dir-fileinfo->state info) nil)) | |
1005 | |
1006 (not (vc-dir-fileinfo->needs-update info)))))))))))) | |
1007 | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1008 (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
|
1009 (vc-dir-refresh)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1010 |
96203 | 1011 (defun vc-dir-refresh () |
1012 "Refresh the contents of the *VC-dir* buffer. | |
1013 Throw an error if another update process is in progress." | |
1014 (interactive) | |
1015 (if (vc-dir-busy) | |
1016 (error "Another update process is in progress, cannot run two at a time") | |
1017 (let ((def-dir default-directory) | |
1018 (backend vc-dir-backend)) | |
1019 (vc-set-mode-line-busy-indicator) | |
1020 ;; Call the `dir-status' backend function. | |
1021 ;; `dir-status' is supposed to be asynchronous. | |
1022 ;; It should compute the results, and then call the function | |
1023 ;; passed as an argument in order to update the vc-dir buffer | |
1024 ;; with the results. | |
1025 | |
1026 ;; Create a buffer that can be used by `dir-status' and call | |
1027 ;; `dir-status' with this buffer as the current buffer. Use | |
1028 ;; `vc-dir-process-buffer' to remember this buffer, so that | |
1029 ;; it can be used later to kill the update process in case it | |
1030 ;; takes too long. | |
1031 (unless (buffer-live-p vc-dir-process-buffer) | |
1032 (setq vc-dir-process-buffer | |
1033 (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
|
1034 ;; 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
|
1035 (ewoc-map (lambda (info) |
d39625535543
(vc-dir-refresh): Only update files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96520
diff
changeset
|
1036 (unless (vc-dir-fileinfo->directory info) |
d39625535543
(vc-dir-refresh): Only update files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96520
diff
changeset
|
1037 (setf (vc-dir-fileinfo->needs-update info) t) nil)) |
96203 | 1038 vc-ewoc) |
1039 (lexical-let ((buffer (current-buffer))) | |
1040 (with-current-buffer vc-dir-process-buffer | |
1041 (cd def-dir) | |
1042 (erase-buffer) | |
1043 (vc-call-backend | |
1044 backend 'dir-status def-dir | |
1045 (lambda (entries &optional more-to-come) | |
1046 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. | |
1047 ;; If MORE-TO-COME is true, then more updates will come from | |
1048 ;; the asynchronous process. | |
1049 (with-current-buffer buffer | |
1050 (vc-dir-update entries buffer) | |
1051 (unless more-to-come | |
1052 (let ((remaining | |
1053 (ewoc-collect | |
1054 vc-ewoc 'vc-dir-fileinfo->needs-update))) | |
1055 (if remaining | |
1056 (vc-dir-refresh-files | |
1057 (mapcar 'vc-dir-fileinfo->name remaining) | |
1058 'up-to-date) | |
98471
497018549116
(vc-dir-mode): Don't create the ewoc header here.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97696
diff
changeset
|
1059 (setq mode-line-process nil))))))))) |
497018549116
(vc-dir-mode): Don't create the ewoc header here.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97696
diff
changeset
|
1060 (ewoc-set-hf vc-ewoc (vc-dir-headers backend def-dir) "")))) |
96203 | 1061 |
1062 (defun vc-dir-show-fileentry (file) | |
1063 "Insert an entry for a specific file into the current *VC-dir* listing. | |
1064 This is typically used if the file is up-to-date (or has been added | |
1065 outside of VC) and one wants to do some operation on it." | |
1066 (interactive "fShow file: ") | |
1067 (vc-dir-update (list (list (file-relative-name file) (vc-state file))) (current-buffer))) | |
1068 | |
1069 (defun vc-dir-hide-up-to-date () | |
1070 "Hide up-to-date items from display." | |
1071 (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
|
1072 (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
|
1073 (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
|
1074 ;; 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
|
1075 ;; 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
|
1076 (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
|
1077 (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
|
1078 (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
|
1079 (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
|
1080 (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
|
1081 ;; 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
|
1082 (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
|
1083 (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
|
1084 ;; 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
|
1085 (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
|
1086 (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
|
1087 ;; 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
|
1088 (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
|
1089 ;; 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
|
1090 (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
|
1091 ;; 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
|
1092 (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
|
1093 (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
|
1094 (setq crt prev))))) |
96203 | 1095 |
107841
2cdeb4c70d45
(vc-dir-kill-line): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107537
diff
changeset
|
1096 (defun vc-dir-kill-line () |
2cdeb4c70d45
(vc-dir-kill-line): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107537
diff
changeset
|
1097 "Remove the current line from display." |
2cdeb4c70d45
(vc-dir-kill-line): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107537
diff
changeset
|
1098 (interactive) |
2cdeb4c70d45
(vc-dir-kill-line): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107537
diff
changeset
|
1099 (let ((crt (ewoc-locate vc-ewoc)) |
2cdeb4c70d45
(vc-dir-kill-line): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107537
diff
changeset
|
1100 (inhibit-read-only t)) |
2cdeb4c70d45
(vc-dir-kill-line): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107537
diff
changeset
|
1101 (ewoc-delete vc-ewoc crt))) |
2cdeb4c70d45
(vc-dir-kill-line): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107537
diff
changeset
|
1102 |
99159
b0dce7f34dda
* vc.el: Rename VC methods that were missed when vc-status was
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99133
diff
changeset
|
1103 (defun vc-dir-printer (fileentry) |
b0dce7f34dda
* vc.el: Rename VC methods that were missed when vc-status was
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99133
diff
changeset
|
1104 (vc-call-backend vc-dir-backend 'dir-printer fileentry)) |
96203 | 1105 |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1106 (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
|
1107 (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
|
1108 files |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1109 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
|
1110 state |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1111 model) |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1112 (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
|
1113 (progn |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1114 (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
|
1115 (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
|
1116 (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
|
1117 (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
|
1118 (setq files (list crt)) |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1119 (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
|
1120 (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
|
1121 |
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1122 (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
|
1123 (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
|
1124 ;; 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
|
1125 ;; 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
|
1126 (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
|
1127 (unless (vc-compatible-state (cdr crt) state) |
102660
ab984696947f
(vc-dir-deduce-fileset): Make the error message more explicit.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102260
diff
changeset
|
1128 (error "When applying VC operations to multiple files, the files are required\nto be in similar VC states.\n%s in state %s clashes with %s in state %s" |
96256
a56e02fe83fc
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96216
diff
changeset
|
1129 (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
|
1130 (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
|
1131 (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
|
1132 (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
|
1133 (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
|
1134 |
96203 | 1135 ;;;###autoload |
96411
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1136 (defun vc-dir (dir &optional backend) |
102929
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1137 "Show the VC status for \"interesting\" files in and below DIR. |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1138 This allows you to mark files and perform VC operations on them. |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1139 The list omits files which are up to date, with no changes in your copy |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1140 or the repository, if there is nothing in particular to say about them. |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1141 |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1142 Preparing the list of file status takes time; when the buffer |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1143 first appears, it has only the first few lines of summary information. |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1144 The file lines appear later. |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1145 |
96411
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1146 Optional second argument BACKEND specifies the VC backend to use. |
102929
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1147 Interactively, a prefix argument means to ask for the backend. |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1148 |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1149 These are the commands available for use in the file status buffer: |
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1150 |
106412
3fea95b17dfa
(vc-dir): Use the correct markup for showing keymaps
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105424
diff
changeset
|
1151 \\{vc-dir-mode-map}" |
102929
6be674ea734e
* vc-dir.el (vc-dir): Dox fix.
Richard M. Stallman <rms@gnu.org>
parents:
102660
diff
changeset
|
1152 |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1153 (interactive |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1154 (list |
97118
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1155 ;; 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
|
1156 ;; 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
|
1157 ;; 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
|
1158 ;; 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
|
1159 ;; 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
|
1160 (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
|
1161 default-directory default-directory t |
48b4d1b43ea2
(vc-dir): Call file-truename on the dir argument.
Sam Steingold <sds@gnu.org>
parents:
97117
diff
changeset
|
1162 nil #'file-directory-p)) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1163 (if current-prefix-arg |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1164 (intern |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1165 (completing-read |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1166 "Use VC backend: " |
96411
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1167 (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
|
1168 vc-handled-backends) |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1169 nil t nil nil))))) |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1170 (unless backend |
31e595cb6c02
(vc-dir): Make backend argument optional and use
Andreas Schwab <schwab@suse.de>
parents:
96390
diff
changeset
|
1171 (setq backend (vc-responsible-backend dir))) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1172 (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
|
1173 (if (derived-mode-p 'vc-dir-mode) |
96203 | 1174 (vc-dir-refresh) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1175 ;; 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
|
1176 (let ((use-vc-backend backend)) |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1177 (vc-dir-mode)))) |
96203 | 1178 |
99159
b0dce7f34dda
* vc.el: Rename VC methods that were missed when vc-status was
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99133
diff
changeset
|
1179 (defun vc-default-dir-extra-headers (backend dir) |
96203 | 1180 ;; Be loud by default to remind people to add code to display |
1181 ;; backend specific headers. | |
1182 ;; XXX: change this to return nil before the release. | |
1183 (concat | |
1184 (propertize "Extra : " 'face 'font-lock-type-face) | |
1185 (propertize "Please add backend specific headers here. It's easy!" | |
1186 'face 'font-lock-warning-face))) | |
1187 | |
101940
dea4466580a6
* vc-dir.el (vc-dir-filename-mouse-map): Rename from vc-dir-mouse-map.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101924
diff
changeset
|
1188 (defvar vc-dir-filename-mouse-map |
101924
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
1189 (let ((map (make-sparse-keymap))) |
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
1190 (define-key map [mouse-2] 'vc-dir-find-file-other-window) |
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
1191 map) |
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
1192 "Local keymap for visiting a file.") |
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
1193 |
99159
b0dce7f34dda
* vc.el: Rename VC methods that were missed when vc-status was
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99133
diff
changeset
|
1194 (defun vc-default-dir-printer (backend fileentry) |
96203 | 1195 "Pretty print FILEENTRY." |
1196 ;; If you change the layout here, change vc-dir-move-to-goal-column. | |
101940
dea4466580a6
* vc-dir.el (vc-dir-filename-mouse-map): Rename from vc-dir-mouse-map.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101924
diff
changeset
|
1197 ;; VC backends can implement backend specific versions of this |
dea4466580a6
* vc-dir.el (vc-dir-filename-mouse-map): Rename from vc-dir-mouse-map.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101924
diff
changeset
|
1198 ;; function. Changes here might need to be reflected in the |
dea4466580a6
* vc-dir.el (vc-dir-filename-mouse-map): Rename from vc-dir-mouse-map.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101924
diff
changeset
|
1199 ;; vc-BACKEND-dir-printer functions. |
96203 | 1200 (let* ((isdir (vc-dir-fileinfo->directory fileentry)) |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1201 (state (if isdir "" (vc-dir-fileinfo->state fileentry))) |
96203 | 1202 (filename (vc-dir-fileinfo->name fileentry))) |
1203 (insert | |
1204 (propertize | |
1205 (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? )) | |
1206 'face 'font-lock-type-face) | |
1207 " " | |
1208 (propertize | |
1209 (format "%-20s" state) | |
1210 'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face) | |
1211 ((memq state '(missing conflict)) 'font-lock-warning-face) | |
1212 (t 'font-lock-variable-name-face)) | |
1213 'mouse-face 'highlight) | |
1214 " " | |
1215 (propertize | |
1216 (format "%s" filename) | |
96216
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1217 'face |
0c3be806e711
(vc-client-object): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96204
diff
changeset
|
1218 (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
|
1219 'help-echo |
96388
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1220 (if isdir |
7ed97437d100
* vc-dir.el (vc-dir): Complete only directory names.
Juanma Barranquero <lekktu@gmail.com>
parents:
96310
diff
changeset
|
1221 "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
|
1222 "File\nmouse-3: Pop-up menu") |
101924
c1950714465b
(vc-dir-find-file-other-window): Allow mouse events.
Nick Roberts <nickrob@snap.net.nz>
parents:
101718
diff
changeset
|
1223 'mouse-face 'highlight |
101940
dea4466580a6
* vc-dir.el (vc-dir-filename-mouse-map): Rename from vc-dir-mouse-map.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101924
diff
changeset
|
1224 'keymap vc-dir-filename-mouse-map)))) |
96203 | 1225 |
1226 (defun vc-default-extra-status-menu (backend) | |
1227 nil) | |
1228 | |
1229 (defun vc-default-status-fileinfo-extra (backend file) | |
1230 "Default absence of extra information returned for a file." | |
1231 nil) | |
1232 | |
1233 (provide 'vc-dir) | |
1234 | |
96204 | 1235 ;; arch-tag: 0274a2e3-e8e9-4b1a-a73c-e8b9129d5d15 |
96203 | 1236 ;;; vc-dir.el ends here |