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