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