Mercurial > emacs
annotate lisp/vc-dispatcher.el @ 94837:55eb2a3c59b4
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1153
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 10 May 2008 05:34:55 +0000 |
parents | 5b364ab2654b |
children | 1aa1de92b8a1 |
rev | line source |
---|---|
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
1 ;;; vc-dispatcher.el -- generic command-dispatcher facility. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
2 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
3 ;; Copyright (C) 2008 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
5 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
6 ;; Author: FSF (see below for full credits) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
7 ;; Maintainer: Eric S. Raymond <esr@thyrsus.com> |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
8 ;; Keywords: tools |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
9 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
11 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94652
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94652
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94652
diff
changeset
|
15 ;; (at your option) any later version. |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
16 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
21 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94652
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
24 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
25 ;;; Credits: |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
26 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
27 ;; Designed and implemented by Eric S. Raymond, originally as part of VC mode. |
94690
1cd9c5b2b68a
Comment typo fix.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94678
diff
changeset
|
28 ;; Stefan Monnier and Dan Nicolaescu contributed substantial work on the |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
29 ;; vc-dir front end. |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
30 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
31 ;;; Commentary: |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
32 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
33 ;; Goals: |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
34 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
35 ;; There is a class of front-ending problems that Emacs might be used |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
36 ;; to address that involves selecting sets of files, or possibly |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
37 ;; directories, and passing the selection set to slave commands. The |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
38 ;; prototypical example, from which this code is derived, is talking |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
39 ;; to version-control systems. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
40 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
41 ;; vc-dispatcher.el is written to decouple the UI issues in such front |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
42 ;; ends from their application-specific logic. It also provides a |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
43 ;; service layer for running the slave commands either synchronously |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
44 ;; or asynchronously and managing the message/error logs from the |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
45 ;; command runs. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
46 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
47 ;; Similar UI problems can be expected to come up in applications |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
48 ;; areas other than VCSes; IDEs and document search are two obvious ones. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
49 ;; This mode is intended to ensure that the Emacs interfaces for all such |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
50 ;; beasts are consistent and carefully designed. But even if nothing |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
51 ;; but VC ever uses it, getting the layer separation right will be |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
52 ;; a valuable thing. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
53 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
54 ;; Dispatcher's universe: |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
55 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
56 ;; The universe consists of the file tree rooted at the current |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
57 ;; directory. The dispatcher's upper layer deduces some subset |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
58 ;; of the file tree from the state of the currently visited buffer |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
59 ;; and returns that subset, presumably to a client mode. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
60 ;; |
94811
47dff47e1b61
Comment and to-do list fixes.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94810
diff
changeset
|
61 ;; The user may be looking at either of two different views; a buffer |
47dff47e1b61
Comment and to-do list fixes.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94810
diff
changeset
|
62 ;; visiting a file, or a directory buffer generated by vc-dispatcher. |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
63 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
64 ;; The lower layer of this mode runs commands in subprocesses, either |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
65 ;; synchronously or asynchronously. Commands may be launched in one |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
66 ;; of two ways: they may be run immediately, or the calling mode can |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
67 ;; create a closure associated with a text-entry buffer, to be |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
68 ;; executed when the user types C-c to ship the buffer contents. In |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
69 ;; either case the command messages and error (if any) will remain |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
70 ;; available in a status buffer. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
71 |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
72 ;; Special behavior of dispatcher directory buffers: |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
73 ;; |
94637
cb8291c75f39
Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94625
diff
changeset
|
74 ;; In dispatcher directory buffers, facilities to perform basic |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
75 ;; navigation and selection operations are provided by keymap and menu |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
76 ;; entries that dispatcher sets up itself, so they'll be uniform |
94637
cb8291c75f39
Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94625
diff
changeset
|
77 ;; across all dispatcher-using client modes. Client modes are |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
78 ;; expected to append to these to provide mode-specific bindings. |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
79 ;; |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
80 ;; The standard map associates a 'state' slot (that the client mode |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
81 ;; may set) with each directory entry. The dispatcher knows nothing |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
82 ;; about the semantics of individual states, but mark and unmark commands |
94637
cb8291c75f39
Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94625
diff
changeset
|
83 ;; treat all entries with the same state as the currently selected one as |
cb8291c75f39
Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94625
diff
changeset
|
84 ;; a unit. |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
85 |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
86 ;; The interface |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
87 ;; |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
88 ;; The main interface to the lower level is vc-do-command. This launches a |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
89 ;; comand, synchronously or asynchronously, making the output available |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
90 ;; in a command log buffer. Two other functions, (vc-start-annotation) and |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
91 ;; (vc-finish-logentry), allow you to associate a command closure with an |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
92 ;; abbotation buffer so that when the user confirms the comment the closure |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
93 ;; is run (with the comment as part of its context). |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
94 ;; |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
95 ;; The interface to the upper level has the two main entry points (vc-dir) |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
96 ;; and (vc-dispatcher-selection-set) and a couple of convenience functions. |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
97 ;; (vc-dir) sets up a dispatcher browsing buffer; (vc-dispatcher-selection-set) |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
98 ;; returns a selection set of files, either the marked files in a browsing |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
99 ;; buffer or the singleton set consisting of the file visited by the current |
94692
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
100 ;; buffer (when that is appropriate). It also does what is needed to ensure |
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
101 ;; that on-disk files and the contents of their visiting Emacs buffers |
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
102 ;; coincide. |
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
103 ;; |
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
104 ;; When the client mode adds a local mode-line-hook to a buffer, it |
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
105 ;; will be called with the buffer file name as argument whenever the |
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
106 ;; dispatcher resynchs the buffer. |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
107 |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
108 ;; To do: |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
109 ;; |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
110 ;; - vc-dir-kill-dir-status-process should not be specific to dir-status, |
94817
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
111 ;; it should work for other async commands done through vc-do-command |
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
112 ;; as well, |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
113 ;; |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
114 ;; - the *VC-log* buffer needs font-locking. |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
115 ;; |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
116 ;; - vc-dir needs mouse bindings. |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
117 ;; |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
118 ;; - vc-dir toolbar needs more icons. |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
119 ;; |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
120 ;; - add commands to move to the prev/next directory in vc-dir. |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
121 ;; |
94817
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
122 ;; - vc-dir-menu-map-filter hook call needs to be moved to vc.el. |
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
123 ;; |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
124 |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
125 (provide 'vc-dispatcher) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
126 |
94582
8393f040d26d
Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94579
diff
changeset
|
127 (eval-when-compile |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
128 (require 'cl)) |
94582
8393f040d26d
Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94579
diff
changeset
|
129 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
130 ;; General customization |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
131 |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
132 (defcustom vc-logentry-check-hook nil |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
133 "Normal hook run by `vc-finish-logentry'. |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
134 Use this to impose your own rules on the entry in addition to any the |
94582
8393f040d26d
Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94579
diff
changeset
|
135 dispatcher client mode imposes itself." |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
136 :type 'hook |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
137 :group 'vc) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
138 |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
139 (defcustom vc-delete-logbuf-window t |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
140 "If non-nil, delete the *VC-log* buffer and window after each logical action. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
141 If nil, bury that buffer instead. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
142 This is most useful if you have multiple windows on a frame and would like to |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
143 preserve the setting." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
144 :type 'boolean |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
145 :group 'vc) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
146 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
147 (defcustom vc-command-messages nil |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
148 "If non-nil, display run messages from back-end commands." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
149 :type 'boolean |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
150 :group 'vc) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
151 |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
152 (defcustom vc-suppress-confirm nil |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
153 "If non-nil, treat user as expert; suppress yes-no prompts on some things." |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
154 :type 'boolean |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
155 :group 'vc) |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
156 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
157 ;; Variables the user doesn't need to know about. |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
158 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
159 (defvar vc-log-operation nil) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
160 (defvar vc-log-after-operation-hook nil) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
161 (defvar vc-log-fileset) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
162 (defvar vc-log-extra) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
163 |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
164 ;; In a log entry buffer, this is a local variable |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
165 ;; that points to the buffer for which it was made |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
166 ;; (either a file, or a VC directory buffer). |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
167 (defvar vc-parent-buffer nil) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
168 (put 'vc-parent-buffer 'permanent-local t) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
169 (defvar vc-parent-buffer-name nil) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
170 (put 'vc-parent-buffer-name 'permanent-local t) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
171 |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
172 ;; Common command execution logic |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
173 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
174 (defun vc-process-filter (p s) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
175 "An alternative output filter for async process P. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
176 One difference with the default filter is that this inserts S after markers. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
177 Another is that undo information is not kept." |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
178 (let ((buffer (process-buffer p))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
179 (when (buffer-live-p buffer) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
180 (with-current-buffer buffer |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
181 (save-excursion |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
182 (let ((buffer-undo-list t) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
183 (inhibit-read-only t)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
184 (goto-char (process-mark p)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
185 (insert s) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
186 (set-marker (process-mark p) (point)))))))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
187 |
94572
3bdffe280ad3
Remove logentry primitive from backend API.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94571
diff
changeset
|
188 (defun vc-setup-buffer (buf) |
3bdffe280ad3
Remove logentry primitive from backend API.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94571
diff
changeset
|
189 "Prepare BUF for executing a slave command and make it current." |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
190 (let ((camefrom (current-buffer)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
191 (olddir default-directory)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
192 (set-buffer (get-buffer-create buf)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
193 (kill-all-local-variables) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
194 (set (make-local-variable 'vc-parent-buffer) camefrom) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
195 (set (make-local-variable 'vc-parent-buffer-name) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
196 (concat " from " (buffer-name camefrom))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
197 (setq default-directory olddir) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
198 (let ((buffer-undo-list t) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
199 (inhibit-read-only t)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
200 (erase-buffer)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
201 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
202 (defvar vc-sentinel-movepoint) ;Dynamically scoped. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
203 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
204 (defun vc-process-sentinel (p s) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
205 (let ((previous (process-get p 'vc-previous-sentinel)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
206 (buf (process-buffer p))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
207 ;; Impatient users sometime kill "slow" buffers; check liveness |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
208 ;; to avoid "error in process sentinel: Selecting deleted buffer". |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
209 (when (buffer-live-p buf) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
210 (when previous (funcall previous p s)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
211 (with-current-buffer buf |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
212 (setq mode-line-process |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
213 (let ((status (process-status p))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
214 ;; Leave mode-line uncluttered, normally. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
215 (unless (eq 'exit status) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
216 (format " (%s)" status)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
217 (let (vc-sentinel-movepoint) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
218 ;; Normally, we want async code such as sentinels to not move point. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
219 (save-excursion |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
220 (goto-char (process-mark p)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
221 (let ((cmds (process-get p 'vc-sentinel-commands))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
222 (process-put p 'vc-sentinel-commands nil) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
223 (dolist (cmd cmds) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
224 ;; Each sentinel may move point and the next one should be run |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
225 ;; at that new point. We could get the same result by having |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
226 ;; each sentinel read&set process-mark, but since `cmd' needs |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
227 ;; to work both for async and sync processes, this would be |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
228 ;; difficult to achieve. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
229 (vc-exec-after cmd)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
230 ;; But sometimes the sentinels really want to move point. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
231 (when vc-sentinel-movepoint |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
232 (let ((win (get-buffer-window (current-buffer) 0))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
233 (if (not win) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
234 (goto-char vc-sentinel-movepoint) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
235 (with-selected-window win |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
236 (goto-char vc-sentinel-movepoint)))))))))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
237 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
238 (defun vc-set-mode-line-busy-indicator () |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
239 (setq mode-line-process |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
240 (concat " " (propertize "[waiting...]" |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
241 'face 'mode-line-emphasis |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
242 'help-echo |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
243 "A VC command is in progress in this buffer")))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
244 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
245 (defun vc-exec-after (code) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
246 "Eval CODE when the current buffer's process is done. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
247 If the current buffer has no process, just evaluate CODE. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
248 Else, add CODE to the process' sentinel." |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
249 (let ((proc (get-buffer-process (current-buffer)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
250 (cond |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
251 ;; If there's no background process, just execute the code. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
252 ;; We used to explicitly call delete-process on exited processes, |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
253 ;; but this led to timing problems causing process output to be |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
254 ;; lost. Terminated processes get deleted automatically |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
255 ;; anyway. -- cyd |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
256 ((or (null proc) (eq (process-status proc) 'exit)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
257 ;; Make sure we've read the process's output before going further. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
258 (when proc (accept-process-output proc)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
259 (eval code)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
260 ;; If a process is running, add CODE to the sentinel |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
261 ((eq (process-status proc) 'run) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
262 (vc-set-mode-line-busy-indicator) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
263 (let ((previous (process-sentinel proc))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
264 (unless (eq previous 'vc-process-sentinel) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
265 (process-put proc 'vc-previous-sentinel previous)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
266 (set-process-sentinel proc 'vc-process-sentinel)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
267 (process-put proc 'vc-sentinel-commands |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
268 ;; We keep the code fragments in the order given |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
269 ;; so that vc-diff-finish's message shows up in |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
270 ;; the presence of non-nil vc-command-messages. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
271 (append (process-get proc 'vc-sentinel-commands) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
272 (list code)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
273 (t (error "Unexpected process state")))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
274 nil) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
275 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
276 (defvar vc-post-command-functions nil |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
277 "Hook run at the end of `vc-do-command'. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
278 Each function is called inside the buffer in which the command was run |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
279 and is passed 3 arguments: the COMMAND, the FILES and the FLAGS.") |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
280 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
281 (defvar w32-quote-process-args) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
282 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
283 (defun vc-delistify (filelist) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
284 "Smash a FILELIST into a file list string suitable for info messages." |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
285 ;; FIXME what about file names with spaces? |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
286 (if (not filelist) "." (mapconcat 'identity filelist " "))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
287 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
288 ;;;###autoload |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
289 (defun vc-do-command (buffer okstatus command file-or-list &rest flags) |
94811
47dff47e1b61
Comment and to-do list fixes.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94810
diff
changeset
|
290 "Execute a slave command, notifying user and checking for errors. |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
291 Output from COMMAND goes to BUFFER, or *vc* if BUFFER is nil or the |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
292 current buffer if BUFFER is t. If the destination buffer is not |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
293 already current, set it up properly and erase it. The command is |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
294 considered successful if its exit status does not exceed OKSTATUS (if |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
295 OKSTATUS is nil, that means to ignore error status, if it is `async', that |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
296 means not to wait for termination of the subprocess; if it is t it means to |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
297 ignore all execution errors). FILE-OR-LIST is the name of a working file; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
298 it may be a list of files or be nil (to execute commands that don't expect |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
299 a file name or set of files). If an optional list of FLAGS is present, |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
300 that is inserted into the command line before the filename." |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
301 ;; FIXME: file-relative-name can return a bogus result because |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
302 ;; it doesn't look at the actual file-system to see if symlinks |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
303 ;; come into play. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
304 (let* ((files |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
305 (mapcar (lambda (f) (file-relative-name (expand-file-name f))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
306 (if (listp file-or-list) file-or-list (list file-or-list)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
307 (full-command |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
308 ;; What we're doing here is preparing a version of the command |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
309 ;; for display in a debug-progess message. If it's fewer than |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
310 ;; 20 characters display the entire command (without trailing |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
311 ;; newline). Otherwise display the first 20 followed by an ellipsis. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
312 (concat (if (string= (substring command -1) "\n") |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
313 (substring command 0 -1) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
314 command) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
315 " " |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
316 (vc-delistify (mapcar (lambda (s) (if (> (length s) 20) (concat (substring s 0 2) "...") s)) flags)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
317 " " (vc-delistify files)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
318 (save-current-buffer |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
319 (unless (or (eq buffer t) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
320 (and (stringp buffer) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
321 (string= (buffer-name) buffer)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
322 (eq buffer (current-buffer))) |
94573
ce09c5078ae7
Partially undo the dispatcher split, it needs to happen more gradually
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94572
diff
changeset
|
323 (vc-setup-buffer (or buffer "*vc*"))) |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
324 ;; If there's some previous async process still running, just kill it. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
325 (let ((oldproc (get-buffer-process (current-buffer)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
326 ;; If we wanted to wait for oldproc to finish before doing |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
327 ;; something, we'd have used vc-eval-after. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
328 ;; Use `delete-process' rather than `kill-process' because we don't |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
329 ;; want any of its output to appear from now on. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
330 (if oldproc (delete-process oldproc))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
331 (let ((squeezed (remq nil flags)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
332 (inhibit-read-only t) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
333 (status 0)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
334 (when files |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
335 (setq squeezed (nconc squeezed files))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
336 (let ((exec-path (append vc-path exec-path)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
337 ;; Add vc-path to PATH for the execution of this command. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
338 (process-environment |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
339 (cons (concat "PATH=" (getenv "PATH") |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
340 path-separator |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
341 (mapconcat 'identity vc-path path-separator)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
342 process-environment)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
343 (w32-quote-process-args t)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
344 (when (and (eq okstatus 'async) (file-remote-p default-directory)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
345 ;; start-process does not support remote execution |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
346 (setq okstatus nil)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
347 (if (eq okstatus 'async) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
348 ;; Run asynchronously. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
349 (let ((proc |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
350 (let ((process-connection-type nil)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
351 (apply 'start-file-process command (current-buffer) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
352 command squeezed)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
353 (if vc-command-messages |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
354 (message "Running %s in background..." full-command)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
355 ;;(set-process-sentinel proc (lambda (p msg) (delete-process p))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
356 (set-process-filter proc 'vc-process-filter) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
357 (vc-exec-after |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
358 `(if vc-command-messages |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
359 (message "Running %s in background... done" ',full-command)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
360 ;; Run synchrously |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
361 (when vc-command-messages |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
362 (message "Running %s in foreground..." full-command)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
363 (let ((buffer-undo-list t)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
364 (setq status (apply 'process-file command nil t nil squeezed))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
365 (when (and (not (eq t okstatus)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
366 (or (not (integerp status)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
367 (and okstatus (< okstatus status)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
368 (unless (eq ?\s (aref (buffer-name (current-buffer)) 0)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
369 (pop-to-buffer (current-buffer)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
370 (goto-char (point-min)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
371 (shrink-window-if-larger-than-buffer)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
372 (error "Running %s...FAILED (%s)" full-command |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
373 (if (integerp status) (format "status %d" status) status)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
374 ;; We're done. But don't emit a status message if running |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
375 ;; asychronously, it would just mislead. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
376 (if (and vc-command-messages (not (eq okstatus 'async))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
377 (message "Running %s...OK = %d" full-command status))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
378 (vc-exec-after |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
379 `(run-hook-with-args 'vc-post-command-functions |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
380 ',command ',file-or-list ',flags)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
381 status)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
382 |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
383 ;; These functions are used to ensure that the view the user sees is up to date |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
384 ;; even if the dispatcher client mode has messed with file contents (as in, |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
385 ;; for example, VCS keyword expansion). |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
386 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
387 (declare-function view-mode-exit "view" (&optional return-to-alist exit-action all-win)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
388 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
389 (defun vc-position-context (posn) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
390 "Save a bit of the text around POSN in the current buffer. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
391 Used to help us find the corresponding position again later |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
392 if markers are destroyed or corrupted." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
393 ;; A lot of this was shamelessly lifted from Sebastian Kremer's |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
394 ;; rcs.el mode. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
395 (list posn |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
396 (buffer-size) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
397 (buffer-substring posn |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
398 (min (point-max) (+ posn 100))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
399 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
400 (defun vc-find-position-by-context (context) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
401 "Return the position of CONTEXT in the current buffer. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
402 If CONTEXT cannot be found, return nil." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
403 (let ((context-string (nth 2 context))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
404 (if (equal "" context-string) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
405 (point-max) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
406 (save-excursion |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
407 (let ((diff (- (nth 1 context) (buffer-size)))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
408 (when (< diff 0) (setq diff (- diff))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
409 (goto-char (nth 0 context)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
410 (if (or (search-forward context-string nil t) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
411 ;; Can't use search-backward since the match may continue |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
412 ;; after point. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
413 (progn (goto-char (- (point) diff (length context-string))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
414 ;; goto-char doesn't signal an error at |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
415 ;; beginning of buffer like backward-char would |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
416 (search-forward context-string nil t))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
417 ;; to beginning of OSTRING |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
418 (- (point) (length context-string)))))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
419 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
420 (defun vc-context-matches-p (posn context) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
421 "Return t if POSN matches CONTEXT, nil otherwise." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
422 (let* ((context-string (nth 2 context)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
423 (len (length context-string)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
424 (end (+ posn len))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
425 (if (> end (1+ (buffer-size))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
426 nil |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
427 (string= context-string (buffer-substring posn end))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
428 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
429 (defun vc-buffer-context () |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
430 "Return a list (POINT-CONTEXT MARK-CONTEXT REPARSE). |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
431 Used by `vc-restore-buffer-context' to later restore the context." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
432 (let ((point-context (vc-position-context (point))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
433 ;; Use mark-marker to avoid confusion in transient-mark-mode. |
94728
b4258832258e
Remove dead code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94722
diff
changeset
|
434 (mark-context (when (eq (marker-buffer (mark-marker)) (current-buffer)) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
435 (vc-position-context (mark-marker)))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
436 ;; Make the right thing happen in transient-mark-mode. |
94728
b4258832258e
Remove dead code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94722
diff
changeset
|
437 (mark-active nil)) |
b4258832258e
Remove dead code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94722
diff
changeset
|
438 (list point-context mark-context nil))) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
439 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
440 (defun vc-restore-buffer-context (context) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
441 "Restore point/mark, and reparse any affected compilation buffers. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
442 CONTEXT is that which `vc-buffer-context' returns." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
443 (let ((point-context (nth 0 context)) |
94728
b4258832258e
Remove dead code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94722
diff
changeset
|
444 (mark-context (nth 1 context))) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
445 ;; if necessary, restore point and mark |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
446 (if (not (vc-context-matches-p (point) point-context)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
447 (let ((new-point (vc-find-position-by-context point-context))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
448 (when new-point (goto-char new-point)))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
449 (and mark-active |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
450 mark-context |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
451 (not (vc-context-matches-p (mark) mark-context)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
452 (let ((new-mark (vc-find-position-by-context mark-context))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
453 (when new-mark (set-mark new-mark)))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
454 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
455 (defun vc-revert-buffer-internal (&optional arg no-confirm) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
456 "Revert buffer, keeping point and mark where user expects them. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
457 Try to be clever in the face of changes due to expanded version-control |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
458 key words. This is important for typeahead to work as expected. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
459 ARG and NO-CONFIRM are passed on to `revert-buffer'." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
460 (interactive "P") |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
461 (widen) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
462 (let ((context (vc-buffer-context))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
463 ;; Use save-excursion here, because it may be able to restore point |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
464 ;; and mark properly even in cases where vc-restore-buffer-context |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
465 ;; would fail. However, save-excursion might also get it wrong -- |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
466 ;; in this case, vc-restore-buffer-context gives it a second try. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
467 (save-excursion |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
468 ;; t means don't call normal-mode; |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
469 ;; that's to preserve various minor modes. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
470 (revert-buffer arg no-confirm t)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
471 (vc-restore-buffer-context context))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
472 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
473 (defun vc-resynch-window (file &optional keep noquery) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
474 "If FILE is in the current buffer, either revert or unvisit it. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
475 The choice between revert (to see expanded keywords) and unvisit |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
476 depends on KEEP. NOQUERY if non-nil inhibits confirmation for |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
477 reverting. NOQUERY should be t *only* if it is known the only |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
478 difference between the buffer and the file is due to |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
479 modifications by the dispatcher client code, rather than user |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
480 editing!" |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
481 (and (string= buffer-file-name file) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
482 (if keep |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
483 (progn |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
484 (vc-revert-buffer-internal t noquery) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
485 ;; TODO: Adjusting view mode might no longer be necessary |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
486 ;; after RMS change to files.el of 1999-08-08. Investigate |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
487 ;; this when we install the new VC. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
488 (and view-read-only |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
489 (if (file-writable-p file) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
490 (and view-mode |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
491 (let ((view-old-buffer-read-only nil)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
492 (view-mode-exit))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
493 (and (not view-mode) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
494 (not (eq (get major-mode 'mode-class) 'special)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
495 (view-mode-enter)))) |
94692
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
496 (run-hook-with-args 'modeline-hook buffer-file-name)) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
497 (kill-buffer (current-buffer))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
498 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
499 (defun vc-resynch-buffer (file &optional keep noquery) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
500 "If FILE is currently visited, resynch its buffer." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
501 (if (string= buffer-file-name file) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
502 (vc-resynch-window file keep noquery) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
503 (let ((buffer (get-file-buffer file))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
504 (when buffer |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
505 (with-current-buffer buffer |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
506 (vc-resynch-window file keep noquery))))) |
94700
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
507 (vc-directory-resynch-file file)) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
508 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
509 ;; Command closures |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
510 |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
511 (defun vc-start-logentry (files extra comment initial-contents msg action &optional after-hook) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
512 "Accept a comment for an operation on FILES with extra data EXTRA. |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
513 If COMMENT is nil, pop up a VC-log buffer, emit MSG, and set the |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
514 action on close to ACTION. If COMMENT is a string and |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
515 INITIAL-CONTENTS is non-nil, then COMMENT is used as the initial |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
516 contents of the log entry buffer. If COMMENT is a string and |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
517 INITIAL-CONTENTS is nil, do action immediately as if the user had |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
518 entered COMMENT. If COMMENT is t, also do action immediately with an |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
519 empty comment. Remember the file's buffer in `vc-parent-buffer' |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
520 \(current one if no file). AFTER-HOOK specifies the local value |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
521 for `vc-log-after-operation-hook'." |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
522 (let ((parent |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
523 (if (vc-dispatcher-browsing) |
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
524 ;; If we are called from a directory browser, the parent buffer is |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
525 ;; the current buffer. |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
526 (current-buffer) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
527 (if (and files (equal (length files) 1)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
528 (get-file-buffer (car files)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
529 (current-buffer))))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
530 (if (and comment (not initial-contents)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
531 (set-buffer (get-buffer-create "*VC-log*")) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
532 (pop-to-buffer (get-buffer-create "*VC-log*"))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
533 (set (make-local-variable 'vc-parent-buffer) parent) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
534 (set (make-local-variable 'vc-parent-buffer-name) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
535 (concat " from " (buffer-name vc-parent-buffer))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
536 (vc-log-edit files) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
537 (make-local-variable 'vc-log-after-operation-hook) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
538 (when after-hook |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
539 (setq vc-log-after-operation-hook after-hook)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
540 (setq vc-log-operation action) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
541 (setq vc-log-extra extra) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
542 (when comment |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
543 (erase-buffer) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
544 (when (stringp comment) (insert comment))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
545 (if (or (not comment) initial-contents) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
546 (message "%s Type C-c C-c when done" msg) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
547 (vc-finish-logentry (eq comment t))))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
548 |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
549 (defun vc-finish-logentry (&optional nocomment) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
550 "Complete the operation implied by the current log entry. |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
551 Use the contents of the current buffer as a check-in or registration |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
552 comment. If the optional arg NOCOMMENT is non-nil, then don't check |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
553 the buffer contents as a comment." |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
554 (interactive) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
555 ;; Check and record the comment, if any. |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
556 (unless nocomment |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
557 (run-hooks 'vc-logentry-check-hook)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
558 ;; Sync parent buffer in case the user modified it while editing the comment. |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
559 ;; But not if it is a vc-directory buffer. |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
560 (with-current-buffer vc-parent-buffer |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
561 (or (vc-dispatcher-browsing) (vc-buffer-sync))) |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
562 (unless vc-log-operation |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
563 (error "No log operation is pending")) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
564 ;; save the parameters held in buffer-local variables |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
565 (let ((log-operation vc-log-operation) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
566 (log-fileset vc-log-fileset) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
567 (log-extra vc-log-extra) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
568 (log-entry (buffer-string)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
569 (after-hook vc-log-after-operation-hook) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
570 (tmp-vc-parent-buffer vc-parent-buffer)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
571 (pop-to-buffer vc-parent-buffer) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
572 ;; OK, do it to it |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
573 (save-excursion |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
574 (funcall log-operation |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
575 log-fileset |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
576 log-extra |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
577 log-entry)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
578 ;; Remove checkin window (after the checkin so that if that fails |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
579 ;; we don't zap the *VC-log* buffer and the typing therein). |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
580 ;; -- IMO this should be replaced with quit-window |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
581 (let ((logbuf (get-buffer "*VC-log*"))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
582 (cond ((and logbuf vc-delete-logbuf-window) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
583 (delete-windows-on logbuf (selected-frame)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
584 ;; Kill buffer and delete any other dedicated windows/frames. |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
585 (kill-buffer logbuf)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
586 (logbuf (pop-to-buffer "*VC-log*") |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
587 (bury-buffer) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
588 (pop-to-buffer tmp-vc-parent-buffer)))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
589 ;; Now make sure we see the expanded headers |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
590 (when log-fileset |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
591 (mapc |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
592 (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
593 log-fileset)) |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
594 (when (vc-dispatcher-browsing) |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
595 (vc-dir-move-to-goal-column)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
596 (run-hooks after-hook 'vc-finish-logentry-hook))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
597 |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
598 ;; The ewoc-based vc-directory implementation |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
599 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
600 (defcustom vc-dir-mode-hook nil |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
601 "Normal hook run by `vc-dir-mode'. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
602 See `run-hooks'." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
603 :type 'hook |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
604 :group 'vc) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
605 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
606 ;; Used to store information for the files displayed in the *VC status* buffer. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
607 ;; Each item displayed corresponds to one of these defstructs. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
608 (defstruct (vc-dir-fileinfo |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
609 (:copier nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
610 (:type list) ;So we can use `member' on lists of FIs. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
611 (:constructor |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
612 ;; We could define it as an alias for `list'. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
613 vc-dir-create-fileinfo (name state &optional extra marked directory)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
614 (:conc-name vc-dir-fileinfo->)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
615 name ;Keep it as first, for `member'. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
616 state |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
617 ;; For storing client-mode specific information. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
618 extra |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
619 marked |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
620 ;; To keep track of not updated files during a global refresh |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
621 needs-update |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
622 ;; To distinguish files and directories. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
623 directory) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
624 |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
625 ;; Used to describe a dispatcher client mode. |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
626 (defstruct (vc-client-object |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
627 (:copier nil) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
628 (:constructor |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
629 vc-create-client-object (name |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
630 headers |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
631 file-to-info |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
632 file-to-state |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
633 file-to-extra |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
634 updater)) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
635 (:conc-name vc-client-object->)) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
636 name |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
637 headers |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
638 file-to-info |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
639 file-to-state |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
640 file-to-extra |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
641 updater) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
642 |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
643 (defvar vc-ewoc nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
644 (defvar vc-dir-process-buffer nil |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
645 "The buffer used for the asynchronous call that computes the VC status.") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
646 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
647 (defun vc-dir-move-to-goal-column () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
648 ;; Used to keep the cursor on the file name column. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
649 (beginning-of-line) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
650 ;; Must be in sync with vc-default-status-printer. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
651 (forward-char 25)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
652 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
653 (defun vc-dir-prepare-status-buffer (dir &optional create-new) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
654 "Find a *vc-dir* buffer showing DIR, or create a new one." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
655 (setq dir (expand-file-name dir)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
656 (let* ((bname "*vc-dir*") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
657 ;; Look for another *vc-dir* buffer visiting the same directory. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
658 (buf (save-excursion |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
659 (unless create-new |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
660 (dolist (buffer (buffer-list)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
661 (set-buffer buffer) |
94800
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
662 (when (and (vc-dispatcher-browsing) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
663 (string= (expand-file-name default-directory) dir)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
664 (return buffer))))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
665 (or buf |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
666 ;; Create a new *vc-dir* buffer. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
667 (with-current-buffer (create-file-buffer bname) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
668 (cd dir) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
669 (vc-setup-buffer (current-buffer)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
670 ;; Reset the vc-parent-buffer-name so that it does not appear |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
671 ;; in the mode-line. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
672 (setq vc-parent-buffer-name nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
673 (current-buffer))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
674 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
675 (defvar vc-dir-menu-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
676 (let ((map (make-sparse-keymap "VC-dir"))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
677 (define-key map [quit] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
678 '(menu-item "Quit" quit-window |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
679 :help "Quit")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
680 (define-key map [kill] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
681 '(menu-item "Kill Update Command" vc-dir-kill-dir-status-process |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
682 :enable (vc-dir-busy) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
683 :help "Kill the command that updates VC status buffer")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
684 (define-key map [refresh] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
685 '(menu-item "Refresh" vc-dir-refresh |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
686 :enable (not (vc-dir-busy)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
687 :help "Refresh the contents of the VC status buffer")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
688 ;; Movement. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
689 (define-key map [sepmv] '("--")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
690 (define-key map [next-line] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
691 '(menu-item "Next line" vc-dir-next-line |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
692 :help "Go to the next line" :keys "n")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
693 (define-key map [previous-line] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
694 '(menu-item "Previous line" vc-dir-previous-line |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
695 :help "Go to the previous line")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
696 ;; Marking. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
697 (define-key map [sepmrk] '("--")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
698 (define-key map [unmark-all] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
699 '(menu-item "Unmark All" vc-dir-unmark-all-files |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
700 :help "Unmark all files that are in the same state as the current file\ |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
701 \nWith prefix argument unmark all files")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
702 (define-key map [unmark-previous] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
703 '(menu-item "Unmark previous " vc-dir-unmark-file-up |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
704 :help "Move to the previous line and unmark the file")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
705 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
706 (define-key map [mark-all] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
707 '(menu-item "Mark All" vc-dir-mark-all-files |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
708 :help "Mark all files that are in the same state as the current file\ |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
709 \nWith prefix argument mark all files")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
710 (define-key map [unmark] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
711 '(menu-item "Unmark" vc-dir-unmark |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
712 :help "Unmark the current file or all files in the region")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
713 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
714 (define-key map [mark] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
715 '(menu-item "Mark" vc-dir-mark |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
716 :help "Mark the current file or all files in the region")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
717 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
718 (define-key map [sepopn] '("--")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
719 (define-key map [open-other] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
720 '(menu-item "Open in other window" vc-dir-find-file-other-window |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
721 :help "Find the file on the current line, in another window")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
722 (define-key map [open] |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
723 '(menu-item "Open file" vc-dir-find-file |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
724 :help "Find the file on the current line")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
725 map) |
94722
3f069e5a5693
Second attempt to move the VC-specific menu initialization.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94712
diff
changeset
|
726 "Menu for dispatcher status") |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
727 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
728 (defalias 'vc-dir-menu-map vc-dir-menu-map) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
729 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
730 (defvar vc-dir-mode-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
731 (let ((map (make-keymap))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
732 (suppress-keymap map) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
733 ;; Marking. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
734 (define-key map "m" 'vc-dir-mark) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
735 (define-key map "M" 'vc-dir-mark-all-files) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
736 (define-key map "u" 'vc-dir-unmark) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
737 (define-key map "U" 'vc-dir-unmark-all-files) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
738 (define-key map "\C-?" 'vc-dir-unmark-file-up) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
739 (define-key map "\M-\C-?" 'vc-dir-unmark-all-files) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
740 ;; Movement. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
741 (define-key map "n" 'vc-dir-next-line) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
742 (define-key map " " 'vc-dir-next-line) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
743 (define-key map "\t" 'vc-dir-next-line) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
744 (define-key map "p" 'vc-dir-previous-line) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
745 (define-key map [backtab] 'vc-dir-previous-line) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
746 ;; The remainder. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
747 (define-key map "f" 'vc-dir-find-file) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
748 (define-key map "\C-m" 'vc-dir-find-file) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
749 (define-key map "o" 'vc-dir-find-file-other-window) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
750 (define-key map "q" 'quit-window) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
751 (define-key map "g" 'vc-dir-refresh) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
752 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
753 (define-key map [(down-mouse-3)] 'vc-dir-menu) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
754 (define-key map [(mouse-2)] 'vc-dir-toggle-mark) |
94698
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
755 |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
756 ;; FIXME: Calls back into vc.el |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
757 ;; Hook up the menu. |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
758 (define-key map [menu-bar vc-dir-mode] |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
759 '(menu-item |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
760 ;; This is used so that client modes can add mode-specific |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
761 ;; menu items to vc-dir-menu-map. |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
762 "VC Status" vc-dir-menu-map :filter vc-dir-menu-map-filter)) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
763 map) |
94698
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
764 "Keymap for VC status") |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
765 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
766 (defmacro vc-at-event (event &rest body) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
767 "Evaluate `body' wich point located at event-start of `event'. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
768 If `body' uses `event', it should be a variable, |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
769 otherwise it will be evaluated twice." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
770 (let ((posn (gensym "vc-at-event-posn"))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
771 `(let ((,posn (event-start ,event))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
772 (save-excursion |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
773 (set-buffer (window-buffer (posn-window ,posn))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
774 (goto-char (posn-point ,posn)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
775 ,@body)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
776 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
777 (defun vc-dir-menu (e) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
778 "Popup the VC status menu." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
779 (interactive "e") |
94698
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
780 (vc-at-event e (popup-menu vc-dir-menu-map e))) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
781 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
782 (defvar vc-dir-tool-bar-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
783 (let ((map (make-sparse-keymap))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
784 (tool-bar-local-item-from-menu 'vc-dir-find-file "open" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
785 map vc-dir-mode-map) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
786 (tool-bar-local-item "bookmark_add" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
787 'vc-dir-toggle-mark 'vc-dir-toggle-mark map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
788 :help "Toggle mark on current item") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
789 (tool-bar-local-item-from-menu 'vc-dir-previous-line "left-arrow" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
790 map vc-dir-mode-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
791 :rtl "right-arrow") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
792 (tool-bar-local-item-from-menu 'vc-dir-next-line "right-arrow" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
793 map vc-dir-mode-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
794 :rtl "left-arrow") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
795 (tool-bar-local-item-from-menu 'vc-print-log "info" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
796 map vc-dir-mode-map) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
797 (tool-bar-local-item-from-menu 'vc-dir-refresh "refresh" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
798 map vc-dir-mode-map) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
799 (tool-bar-local-item-from-menu 'nonincremental-search-forward |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
800 "search" map) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
801 (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
802 map vc-dir-mode-map) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
803 (tool-bar-local-item-from-menu 'quit-window "exit" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
804 map vc-dir-mode-map) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
805 map)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
806 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
807 (defun vc-dir-update (entries buffer &optional noinsert) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
808 "Update BUFFER's ewoc from the list of ENTRIES. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
809 If NOINSERT, ignore elements on ENTRIES which are not in the ewoc." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
810 ;; Add ENTRIES to the vc-dir buffer BUFFER. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
811 (with-current-buffer buffer |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
812 ;; Insert the entries sorted by name into the ewoc. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
813 ;; We assume the ewoc is sorted too, which should be the |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
814 ;; case if we always add entries with vc-dir-update. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
815 (setq entries |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
816 ;; Sort: first files and then subdirectories. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
817 ;; XXX: this is VERY inefficient, it computes the directory |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
818 ;; names too many times |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
819 (sort entries |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
820 (lambda (entry1 entry2) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
821 (let ((dir1 (file-name-directory (expand-file-name (car entry1)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
822 (dir2 (file-name-directory (expand-file-name (car entry2))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
823 (cond |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
824 ((string< dir1 dir2) t) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
825 ((not (string= dir1 dir2)) nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
826 ((string< (car entry1) (car entry2)))))))) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
827 ;; Insert directory entries in the right places. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
828 (let ((entry (car entries)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
829 (node (ewoc-nth vc-ewoc 0))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
830 ;; Insert . if it is not present. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
831 (unless node |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
832 (let ((rd (file-relative-name default-directory))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
833 (ewoc-enter-last |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
834 vc-ewoc (vc-dir-create-fileinfo |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
835 rd nil nil nil (expand-file-name default-directory)))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
836 (setq node (ewoc-nth vc-ewoc 0))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
837 |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
838 (while (and entry node) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
839 (let* ((entryfile (car entry)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
840 (entrydir (file-name-directory (expand-file-name entryfile))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
841 (nodedir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
842 (or (vc-dir-fileinfo->directory (ewoc-data node)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
843 (file-name-directory |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
844 (expand-file-name |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
845 (vc-dir-fileinfo->name (ewoc-data node))))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
846 (cond |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
847 ;; First try to find the directory. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
848 ((string-lessp nodedir entrydir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
849 (setq node (ewoc-next vc-ewoc node))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
850 ((string-equal nodedir entrydir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
851 ;; Found the directory, find the place for the file name. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
852 (let ((nodefile (vc-dir-fileinfo->name (ewoc-data node)))) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
853 (cond |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
854 ((string-lessp nodefile entryfile) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
855 (setq node (ewoc-next vc-ewoc node))) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
856 ((string-equal nodefile entryfile) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
857 (setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
858 (setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
859 (setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
860 (ewoc-invalidate vc-ewoc node) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
861 (setq entries (cdr entries) entry (car entries)) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
862 (setq node (ewoc-next vc-ewoc node))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
863 (t |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
864 (ewoc-enter-before vc-ewoc node |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
865 (apply 'vc-dir-create-fileinfo entry)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
866 (setq entries (cdr entries) entry (car entries)))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
867 (t |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
868 ;; We need to insert a directory node |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
869 (let ((rd (file-relative-name entrydir))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
870 (ewoc-enter-last |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
871 vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
872 ;; Now insert the node itself. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
873 (ewoc-enter-before vc-ewoc node |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
874 (apply 'vc-dir-create-fileinfo entry)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
875 (setq entries (cdr entries) entry (car entries)))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
876 ;; We're past the last node, all remaining entries go to the end. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
877 (unless (or node noinsert) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
878 (let* ((lastnode (ewoc-nth vc-ewoc -1)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
879 (lastdir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
880 (or (vc-dir-fileinfo->directory (ewoc-data lastnode)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
881 (file-name-directory |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
882 (expand-file-name |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
883 (vc-dir-fileinfo->name (ewoc-data lastnode))))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
884 (dolist (entry entries) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
885 (let ((entrydir (file-name-directory (expand-file-name (car entry))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
886 ;; Insert a directory node if needed. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
887 (unless (string-equal lastdir entrydir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
888 (setq lastdir entrydir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
889 (let ((rd (file-relative-name entrydir))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
890 (ewoc-enter-last |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
891 vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir)))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
892 ;; Now insert the node itself. |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
893 (ewoc-enter-last vc-ewoc |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
894 (apply 'vc-dir-create-fileinfo entry))))))))) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
895 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
896 (defun vc-dir-busy () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
897 (and (buffer-live-p vc-dir-process-buffer) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
898 (get-buffer-process vc-dir-process-buffer))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
899 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
900 (defun vc-dir-kill-dir-status-process () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
901 "Kill the temporary buffer and associated process." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
902 (interactive) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
903 (when (buffer-live-p vc-dir-process-buffer) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
904 (let ((proc (get-buffer-process vc-dir-process-buffer))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
905 (when proc (delete-process proc)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
906 (setq vc-dir-process-buffer nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
907 (setq mode-line-process nil)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
908 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
909 (defun vc-dir-kill-query () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
910 ;; Make sure that when the VC status buffer is killed the update |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
911 ;; process running in background is also killed. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
912 (if (vc-dir-busy) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
913 (when (y-or-n-p "Status update process running, really kill status buffer?") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
914 (vc-dir-kill-dir-status-process) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
915 t) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
916 t)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
917 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
918 (defun vc-dir-next-line (arg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
919 "Go to the next line. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
920 If a prefix argument is given, move by that many lines." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
921 (interactive "p") |
94817
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
922 (with-no-warnings |
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
923 (ewoc-goto-next vc-ewoc arg) |
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
924 (vc-dir-move-to-goal-column))) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
925 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
926 (defun vc-dir-previous-line (arg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
927 "Go to the previous line. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
928 If a prefix argument is given, move by that many lines." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
929 (interactive "p") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
930 (ewoc-goto-prev vc-ewoc arg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
931 (vc-dir-move-to-goal-column)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
932 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
933 (defun vc-dir-mark-unmark (mark-unmark-function) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
934 (if (use-region-p) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
935 (let ((firstl (line-number-at-pos (region-beginning))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
936 (lastl (line-number-at-pos (region-end)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
937 (save-excursion |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
938 (goto-char (region-beginning)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
939 (while (<= (line-number-at-pos) lastl) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
940 (funcall mark-unmark-function)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
941 (funcall mark-unmark-function))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
942 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
943 (defun vc-dir-parent-marked-p (arg) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
944 ;; Return nil if none of the parent directories of arg is marked. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
945 (let* ((argdata (ewoc-data arg)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
946 (argdir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
947 (let ((crtdir (vc-dir-fileinfo->directory argdata))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
948 (if crtdir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
949 crtdir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
950 (file-name-directory (expand-file-name |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
951 (vc-dir-fileinfo->name argdata)))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
952 (arglen (length argdir)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
953 (crt arg) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
954 data dir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
955 ;; Go through the predecessors, checking if any directory that is |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
956 ;; a parent is marked. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
957 (while (setq crt (ewoc-prev vc-ewoc crt)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
958 (setq data (ewoc-data crt)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
959 (setq dir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
960 (let ((crtdir (vc-dir-fileinfo->directory data))) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
961 (if crtdir |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
962 crtdir |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
963 (file-name-directory (expand-file-name |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
964 (vc-dir-fileinfo->name data)))))) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
965 |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
966 (when (and (vc-dir-fileinfo->directory data) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
967 (string-equal (substring argdir 0 (length dir)) dir)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
968 (when (vc-dir-fileinfo->marked data) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
969 (error "Cannot mark `%s', parent directory `%s' marked" |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
970 (vc-dir-fileinfo->name argdata) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
971 (vc-dir-fileinfo->name data))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
972 nil)) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
973 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
974 (defun vc-dir-children-marked-p (arg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
975 ;; Return nil if none of the children of arg is marked. |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
976 (let* ((argdata (ewoc-data arg)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
977 (argdir (vc-dir-fileinfo->directory argdata)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
978 (arglen (length argdir)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
979 (is-child t) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
980 (crt arg) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
981 data dir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
982 (while (and is-child (setq crt (ewoc-next vc-ewoc crt))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
983 (setq data (ewoc-data crt)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
984 (setq dir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
985 (let ((crtdir (vc-dir-fileinfo->directory data))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
986 (if crtdir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
987 crtdir |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
988 (file-name-directory (expand-file-name |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
989 (vc-dir-fileinfo->name data)))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
990 (if (string-equal argdir (substring dir 0 arglen)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
991 (when (vc-dir-fileinfo->marked data) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
992 (error "Cannot mark `%s', child `%s' marked" |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
993 (vc-dir-fileinfo->name argdata) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
994 (vc-dir-fileinfo->name data))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
995 ;; We are done, we got to an entry that is not a child of `arg'. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
996 (setq is-child nil))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
997 nil)) |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
998 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
999 (defun vc-dir-mark-file (&optional arg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1000 ;; Mark ARG or the current file and move to the next line. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1001 (let* ((crt (or arg (ewoc-locate vc-ewoc))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1002 (file (ewoc-data crt)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1003 (isdir (vc-dir-fileinfo->directory file))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1004 (when (or (and isdir (not (vc-dir-children-marked-p crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1005 (and (not isdir) (not (vc-dir-parent-marked-p crt)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1006 (setf (vc-dir-fileinfo->marked file) t) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1007 (ewoc-invalidate vc-ewoc crt) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1008 (unless (or arg (mouse-event-p last-command-event)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1009 (vc-dir-next-line 1))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1010 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1011 (defun vc-dir-mark () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1012 "Mark the current file or all files in the region. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1013 If the region is active, mark all the files in the region. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1014 Otherwise mark the file on the current line and move to the next |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1015 line." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1016 (interactive) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1017 (vc-dir-mark-unmark 'vc-dir-mark-file)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1018 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1019 (defun vc-dir-mark-all-files (arg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1020 "Mark all files with the same state as the current one. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1021 With a prefix argument mark all files. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1022 If the current entry is a directory, mark all child files. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1023 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1024 The VC commands operate on files that are on the same state. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1025 This command is intended to make it easy to select all files that |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1026 share the same state." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1027 (interactive "P") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1028 (if arg |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1029 ;; Mark all files. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1030 (progn |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1031 ;; First check that no directory is marked, we can't mark |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1032 ;; files in that case. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1033 (ewoc-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1034 (lambda (filearg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1035 (when (and (vc-dir-fileinfo->directory filearg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1036 (vc-dir-fileinfo->directory filearg)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1037 (error "Cannot mark all files, directory `%s' marked" |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1038 (vc-dir-fileinfo->name filearg)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1039 vc-ewoc) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1040 (ewoc-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1041 (lambda (filearg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1042 (unless (vc-dir-fileinfo->marked filearg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1043 (setf (vc-dir-fileinfo->marked filearg) t) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1044 t)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1045 vc-ewoc)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1046 (let ((data (ewoc-data (ewoc-locate vc-ewoc)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1047 (if (vc-dir-fileinfo->directory data) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1048 ;; It's a directory, mark child files. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1049 (let ((crt (ewoc-locate vc-ewoc))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1050 (unless (vc-dir-children-marked-p crt) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1051 (while (setq crt (ewoc-next vc-ewoc crt)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1052 (let ((crt-data (ewoc-data crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1053 (unless (vc-dir-fileinfo->directory crt-data) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1054 (setf (vc-dir-fileinfo->marked crt-data) t) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1055 (ewoc-invalidate vc-ewoc crt)))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1056 ;; It's a file |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1057 (let ((state (vc-dir-fileinfo->state data)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1058 (crt (ewoc-nth vc-ewoc 0))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1059 (while crt |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1060 (let ((crt-data (ewoc-data crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1061 (when (and (not (vc-dir-fileinfo->marked crt-data)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1062 (eq (vc-dir-fileinfo->state crt-data) state) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1063 (not (vc-dir-fileinfo->directory crt-data))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1064 (vc-dir-mark-file crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1065 (setq crt (ewoc-next vc-ewoc crt)))))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1066 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1067 (defun vc-dir-unmark-file () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1068 ;; Unmark the current file and move to the next line. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1069 (let* ((crt (ewoc-locate vc-ewoc)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1070 (file (ewoc-data crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1071 (setf (vc-dir-fileinfo->marked file) nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1072 (ewoc-invalidate vc-ewoc crt) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1073 (unless (mouse-event-p last-command-event) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1074 (vc-dir-next-line 1)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1075 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1076 (defun vc-dir-unmark () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1077 "Unmark the current file or all files in the region. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1078 If the region is active, unmark all the files in the region. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1079 Otherwise mark the file on the current line and move to the next |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1080 line." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1081 (interactive) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1082 (vc-dir-mark-unmark 'vc-dir-unmark-file)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1083 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1084 (defun vc-dir-unmark-file-up () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1085 "Move to the previous line and unmark the file." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1086 (interactive) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1087 ;; If we're on the first line, we won't move up, but we will still |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1088 ;; remove the mark. This seems a bit odd but it is what buffer-menu |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1089 ;; does. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1090 (let* ((prev (ewoc-goto-prev vc-ewoc 1)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1091 (file (ewoc-data prev))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1092 (setf (vc-dir-fileinfo->marked file) nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1093 (ewoc-invalidate vc-ewoc prev) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1094 (vc-dir-move-to-goal-column))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1095 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1096 (defun vc-dir-unmark-all-files (arg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1097 "Unmark all files with the same state as the current one. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1098 With a prefix argument unmark all files. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1099 If the current entry is a directory, unmark all the child files. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1100 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1101 The VC commands operate on files that are on the same state. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1102 This command is intended to make it easy to deselect all files |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1103 that share the same state." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1104 (interactive "P") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1105 (if arg |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1106 (ewoc-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1107 (lambda (filearg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1108 (when (vc-dir-fileinfo->marked filearg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1109 (setf (vc-dir-fileinfo->marked filearg) nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1110 t)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1111 vc-ewoc) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1112 (let* ((crt (ewoc-locate vc-ewoc)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1113 (data (ewoc-data crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1114 (if (vc-dir-fileinfo->directory data) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1115 ;; It's a directory, unmark child files. |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1116 (while (setq crt (ewoc-next vc-ewoc crt)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1117 (let ((crt-data (ewoc-data crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1118 (unless (vc-dir-fileinfo->directory crt-data) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1119 (setf (vc-dir-fileinfo->marked crt-data) nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1120 (ewoc-invalidate vc-ewoc crt)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1121 ;; It's a file |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1122 (let ((crt-state (vc-dir-fileinfo->state (ewoc-data crt)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1123 (ewoc-map |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1124 (lambda (filearg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1125 (when (and (vc-dir-fileinfo->marked filearg) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1126 (eq (vc-dir-fileinfo->state filearg) crt-state)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1127 (setf (vc-dir-fileinfo->marked filearg) nil) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1128 t)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1129 vc-ewoc)))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1130 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1131 (defun vc-dir-toggle-mark-file () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1132 (let* ((crt (ewoc-locate vc-ewoc)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1133 (file (ewoc-data crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1134 (if (vc-dir-fileinfo->marked file) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1135 (vc-dir-unmark-file) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1136 (vc-dir-mark-file)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1137 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1138 (defun vc-dir-toggle-mark (e) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1139 (interactive "e") |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1140 (vc-at-event e (vc-dir-mark-unmark 'vc-dir-toggle-mark-file))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1141 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1142 (defun vc-dir-delete-file () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1143 "Delete the marked files, or the current file if no marks." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1144 (interactive) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1145 (mapc 'vc-delete-file (or (vc-dir-marked-files) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1146 (list (vc-dir-current-file))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1147 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1148 (defun vc-dir-find-file () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1149 "Find the file on the current line." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1150 (interactive) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1151 (find-file (vc-dir-current-file))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1152 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1153 (defun vc-dir-find-file-other-window () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1154 "Find the file on the current line, in another window." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1155 (interactive) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1156 (find-file-other-window (vc-dir-current-file))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1157 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1158 (defun vc-dir-current-file () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1159 (let ((node (ewoc-locate vc-ewoc))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1160 (unless node |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1161 (error "No file available.")) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1162 (expand-file-name (vc-dir-fileinfo->name (ewoc-data node))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1163 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1164 (defun vc-dir-marked-files () |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1165 "Return the list of marked files." |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1166 (mapcar |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1167 (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1168 (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1169 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1170 (defun vc-dir-marked-only-files () |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1171 "Return the list of marked files, For marked directories return child files." |
94584
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1172 (let ((crt (ewoc-nth vc-ewoc 0)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1173 result) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1174 (while crt |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1175 (let ((crt-data (ewoc-data crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1176 (if (vc-dir-fileinfo->marked crt-data) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1177 (if (vc-dir-fileinfo->directory crt-data) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1178 (let* ((dir (vc-dir-fileinfo->directory crt-data)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1179 (dirlen (length dir)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1180 data) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1181 (while |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1182 (and (setq crt (ewoc-next vc-ewoc crt)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1183 (string-equal |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1184 (substring |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1185 (progn |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1186 (setq data (ewoc-data crt)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1187 (let ((crtdir (vc-dir-fileinfo->directory data))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1188 (if crtdir |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1189 crtdir |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1190 (file-name-directory |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1191 (expand-file-name |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1192 (vc-dir-fileinfo->name data)))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1193 0 dirlen) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1194 dir)) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1195 (unless (vc-dir-fileinfo->directory data) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1196 (push (vc-dir-fileinfo->name data) result)))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1197 (push (expand-file-name (vc-dir-fileinfo->name crt-data)) result) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1198 (setq crt (ewoc-next vc-ewoc crt))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1199 (setq crt (ewoc-next vc-ewoc crt))))) |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1200 result)) |
94637
cb8291c75f39
Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94625
diff
changeset
|
1201 |
94700
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1202 (defun vc-directory-resynch-file (&optional fname) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1203 "Update the entries for FILE in any directory buffers that list it." |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1204 (let ((file (or fname (expand-file-name buffer-file-name)))) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1205 ;; The vc-dir case |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1206 (let ((found-vc-dir-buf nil)) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1207 (save-excursion |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1208 (dolist (status-buf (buffer-list)) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1209 (set-buffer status-buf) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1210 ;; look for a vc-dir buffer that might show this file. |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1211 (when (eq major-mode 'vc-dir-mode) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1212 (setq found-vc-dir-buf t) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1213 (let ((ddir (expand-file-name default-directory))) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1214 ;; This test is cvs-string-prefix-p |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1215 (when (eq t (compare-strings file nil (length ddir) ddir nil nil)) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1216 (let* |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1217 ((file-short (substring file (length ddir))) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1218 (state |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1219 (funcall (vc-client-object->file-to-state vc-client-mode) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1220 file)) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1221 (extra |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1222 (funcall (vc-client-object->file-to-extra vc-client-mode) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1223 file)) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1224 (entry |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1225 (list file-short state extra))) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1226 (vc-dir-update (list entry) status-buf)))))) |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1227 ;; We didn't find any vc-dir buffers, remove the hook, it is |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1228 ;; not needed. |
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1229 (unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-directory-resynch-file)))))) |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1230 |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1231 (defun vc-dir-mode (client-object) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1232 "Major mode for showing the VC status for a directory. |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1233 Marking/Unmarking key bindings and actions: |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1234 m - marks a file/directory or if the region is active, mark all the files |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1235 in region. |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1236 Restrictions: - a file cannot be marked if any parent directory is marked |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1237 - a directory cannot be marked if any child file or |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1238 directory is marked |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1239 u - marks a file/directory or if the region is active, unmark all the files |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1240 in region. |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1241 M - if the cursor is on a file: mark all the files with the same VC state as |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1242 the current file |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1243 - if the cursor is on a directory: mark all child files |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1244 - with a prefix argument: mark all files |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1245 U - if the cursor is on a file: unmark all the files with the same VC state |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1246 as the current file |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1247 - if the cursor is on a directory: unmark all child files |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1248 - with a prefix argument: unmark all files |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1249 |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1250 |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1251 \\{vc-dir-mode-map}" |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1252 (setq mode-name (vc-client-object->name client-object)) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1253 (setq major-mode 'vc-dir-mode) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1254 (setq buffer-read-only t) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1255 (use-local-map vc-dir-mode-map) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1256 (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map) |
94625
be875b5d451e
(vc-dir-mark-buffer-changed): Fix typo
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94613
diff
changeset
|
1257 (set (make-local-variable 'vc-client-mode) client-object) |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1258 (let ((buffer-read-only nil)) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1259 (erase-buffer) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1260 (set (make-local-variable 'vc-dir-process-buffer) nil) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1261 (set (make-local-variable 'vc-ewoc) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1262 (ewoc-create (vc-client-object->file-to-info client-object) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1263 (vc-client-object->headers client-object))) |
94700
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1264 (add-hook 'after-save-hook 'vc-directory-resynch-file) |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1265 ;; Make sure that if the VC status buffer is killed, the update |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1266 ;; process running in the background is also killed. |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1267 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1268 (funcall (vc-client-object->updater client-object))) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1269 (run-hooks 'vc-dir-mode-hook)) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1270 |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1271 (put 'vc-dir-mode 'mode-class 'special) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1272 |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
1273 (defun vc-dispatcher-browsing () |
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
1274 "Are we in a directory browser buffer?" |
94800
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1275 (derived-mode-p 'vc-dir-mode)) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1276 |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1277 (defun vc-dispatcher-in-fileset-p (fileset) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1278 (let ((member nil)) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1279 (while (and (not member) fileset) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1280 (let ((elem (pop fileset))) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1281 (if (if (file-directory-p elem) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1282 (eq t (compare-strings buffer-file-name nil (length elem) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1283 elem nil nil)) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1284 (eq (current-buffer) (get-file-buffer elem))) |
94801
4a0c0906cc91
(vc-dispatcher-selection-set): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94800
diff
changeset
|
1285 (setq member t)))) |
4a0c0906cc91
(vc-dispatcher-selection-set): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94800
diff
changeset
|
1286 member)) |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
1287 |
94820
5b364ab2654b
Dupport an use an observer flag in (vc-dispatcher-selection-set).
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94819
diff
changeset
|
1288 (defun vc-dispatcher-selection-set (&optional observer) |
94802
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1289 "Deduce a set of files to which to apply an operation. Return the fileset. |
94778
b9687393def1
Large simplification in (vc-deduce-fileset) logic.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94729
diff
changeset
|
1290 If we're in a directory display, the fileset is the list of marked files (if |
94802
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1291 there is one) else the file on the curreent line. If not in a directory |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1292 display, but the current buffer visits a file, the fileset is a singleton |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1293 containing that file. Otherwise, throw an error." |
94650
276c5ce56449
Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94647
diff
changeset
|
1294 (let ((files |
94802
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1295 (cond |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1296 ;; Browsing with vc-dir |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1297 ((vc-dispatcher-browsing) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1298 (or (vc-dir-marked-files) (list (vc-dir-current-file)))) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1299 ;; Visiting an eligible file |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1300 ((buffer-file-name) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1301 (list buffer-file-name)) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1302 ;; No eligible file -- if there's a parent buffer, deduce from there |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1303 ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1304 (with-current-buffer vc-parent-buffer |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1305 (vc-dispatcher-browsing)))) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1306 (with-current-buffer vc-parent-buffer |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1307 (vc-dispatcher-selection-set))) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1308 ;; No good set here, throw error |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1309 (t (error "No fileset is available here"))))) |
94800
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1310 ;; We assume, in order to avoid unpleasant surprises to the user, |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1311 ;; that a fileset is not in good shape to be handed to the user if the |
94778
b9687393def1
Large simplification in (vc-deduce-fileset) logic.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94729
diff
changeset
|
1312 ;; buffers visiting the fileset don't match the on-disk contents. |
94820
5b364ab2654b
Dupport an use an observer flag in (vc-dispatcher-selection-set).
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94819
diff
changeset
|
1313 (if (not observer) |
5b364ab2654b
Dupport an use an observer flag in (vc-dispatcher-selection-set).
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94819
diff
changeset
|
1314 (save-some-buffers |
5b364ab2654b
Dupport an use an observer flag in (vc-dispatcher-selection-set).
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94819
diff
changeset
|
1315 nil (lambda () (vc-dispatcher-in-fileset-p files)))) |
94650
276c5ce56449
Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94647
diff
changeset
|
1316 files)) |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
1317 |
94613 | 1318 ;; arch-tag: 7d08b17f-5470-4799-914b-bfb9fcf6a246 |
94573
ce09c5078ae7
Partially undo the dispatcher split, it needs to happen more gradually
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94572
diff
changeset
|
1319 ;;; vc-dispatcher.el ends here |