annotate lisp/vc-dispatcher.el @ 94692:891cb8f8888f

More decoupling of vc-dispatcher.el from vc.el.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Tue, 06 May 2008 16:00:54 +0000
parents 1cd9c5b2b68a
children f46fc59d6e9e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ;;
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61 ;; The user may be attempting to select one of three contexts: an
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 ;; explicitly selected fileset, the current working directory, or a
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 ;; global (null) context. The user may be looking at either of two
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64 ;; different views; a buffer visiting a file, or a directory buffer
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65 ;; generated by vc-dispatcher. The main UI problem connected with
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66 ;; this mode is that the user may need to be able to select any of
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
67 ;; these three contexts from either view.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
68 ;;
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 ;; 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
70 ;; synchronously or asynchronously. Commands may be launched in one
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 ;; 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
72 ;; 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
73 ;; 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
74 ;; 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
75 ;; available in a status buffer.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
76
94585
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
77 ;; Special behavior of dispatcher directory buffers:
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
78 ;;
94637
cb8291c75f39 Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94625
diff changeset
79 ;; 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
80 ;; 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
81 ;; 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
82 ;; 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
83 ;; 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
84 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
85 ;; 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
86 ;; 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
87 ;; 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
88 ;; 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
89 ;; a unit.
94652
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
90
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
91 ;; The interface
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
92 ;;
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
93 ;; 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
94 ;; comand, synchronously or asynchronously, making the output available
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
95 ;; 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
96 ;; (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
97 ;; 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
98 ;; 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
99 ;;
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
100 ;; 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
101 ;; 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
102 ;; (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
103 ;; 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
104 ;; 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
105 ;; 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
106 ;; 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
107 ;; coincide.
891cb8f8888f More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94690
diff changeset
108 ;;
891cb8f8888f More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94690
diff changeset
109 ;; 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
110 ;; 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
111 ;; dispatcher resynchs the buffer.
94652
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
112
94585
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
113 ;; To do:
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
114 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
115 ;; - vc-dir-kill-dir-status-process should not be specific to dir-status,
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
116 ;; it should work for other async commands as well (pull/push/...).
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 ;; - the *VC-log* buffer needs font-locking.
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 ;; - Set `vc-dir-insert-directories' to t and check what operations
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
121 ;; and backends do not support directory arguments and fix them.
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
122 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
123 ;; - vc-dir needs mouse bindings.
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
124 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
125 ;; - vc-dir needs more key bindings for VC actions.
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
126 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
127 ;; - vc-dir toolbar needs more icons.
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
128 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
129 ;; - vc-dir-next-line should not print an "end of buffer" message when
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
130 ;; invoked with the cursor on the last file.
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
131 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
132 ;; - 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
133 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
134 ;; - document vc-dir in the manual.
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
135 ;;
16008b90ad8c Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94584
diff changeset
136
94571
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
137 (provide 'vc-dispatcher)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
138
94582
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
139 (eval-when-compile
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
140 (require 'cl)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
141 (require 'dired) ; for dired-map-over-marks macro
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
142 (require 'dired-aux)) ; for dired-kill-{line,tree}
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
143
94576
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
144 ;; General customization
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
145
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
146 (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
147 "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
148 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
149 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
150 :type 'hook
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
151 :group 'vc)
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
152
94579
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
153 (defcustom vc-delete-logbuf-window t
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
154 "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
155 If nil, bury that buffer instead.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
156 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
157 preserve the setting."
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
158 :type 'boolean
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
159 :group 'vc)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
160
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
161 (defcustom vc-command-messages nil
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
162 "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
163 :type 'boolean
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
164 :group 'vc)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
165
94652
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
166 (defcustom vc-suppress-confirm nil
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
167 "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
168 :type 'boolean
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
169 :group 'vc)
3a091c58b092 Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94650
diff changeset
170
94576
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
171 ;; 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
172
94576
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
173 (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
174 (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
175 (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
176 (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
177
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
178 ;; 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
179 ;; that points to the buffer for which it was made
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
180 ;; (either a file, or a VC dired buffer).
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
181 (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
182 (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
183 (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
184 (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
185
94571
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
186 ;; Common command execution logic
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
187
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
188 (defun vc-process-filter (p s)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
189 "An alternative output filter for async process P.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
190 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
191 Another is that undo information is not kept."
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
192 (let ((buffer (process-buffer p)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
193 (when (buffer-live-p buffer)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
194 (with-current-buffer buffer
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
195 (save-excursion
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
196 (let ((buffer-undo-list t)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
197 (inhibit-read-only t))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
198 (goto-char (process-mark p))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
199 (insert s)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
200 (set-marker (process-mark p) (point))))))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
201
94572
3bdffe280ad3 Remove logentry primitive from backend API.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94571
diff changeset
202 (defun vc-setup-buffer (buf)
3bdffe280ad3 Remove logentry primitive from backend API.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94571
diff changeset
203 "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
204 (let ((camefrom (current-buffer))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
205 (olddir default-directory))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
206 (set-buffer (get-buffer-create buf))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
207 (kill-all-local-variables)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
208 (set (make-local-variable 'vc-parent-buffer) camefrom)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
209 (set (make-local-variable 'vc-parent-buffer-name)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
210 (concat " from " (buffer-name camefrom)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
211 (setq default-directory olddir)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
212 (let ((buffer-undo-list t)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
213 (inhibit-read-only t))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
214 (erase-buffer))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
215
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
216 (defvar vc-sentinel-movepoint) ;Dynamically scoped.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
217
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
218 (defun vc-process-sentinel (p s)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
219 (let ((previous (process-get p 'vc-previous-sentinel))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
220 (buf (process-buffer p)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
221 ;; Impatient users sometime kill "slow" buffers; check liveness
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
222 ;; to avoid "error in process sentinel: Selecting deleted buffer".
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
223 (when (buffer-live-p buf)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
224 (when previous (funcall previous p s))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
225 (with-current-buffer buf
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
226 (setq mode-line-process
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
227 (let ((status (process-status p)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
228 ;; Leave mode-line uncluttered, normally.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
229 (unless (eq 'exit status)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
230 (format " (%s)" status))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
231 (let (vc-sentinel-movepoint)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
232 ;; 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
233 (save-excursion
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
234 (goto-char (process-mark p))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
235 (let ((cmds (process-get p 'vc-sentinel-commands)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
236 (process-put p 'vc-sentinel-commands nil)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
237 (dolist (cmd cmds)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
238 ;; 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
239 ;; 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
240 ;; 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
241 ;; 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
242 ;; difficult to achieve.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
243 (vc-exec-after cmd))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
244 ;; But sometimes the sentinels really want to move point.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
245 (when vc-sentinel-movepoint
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
246 (let ((win (get-buffer-window (current-buffer) 0)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
247 (if (not win)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
248 (goto-char vc-sentinel-movepoint)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
249 (with-selected-window win
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
250 (goto-char vc-sentinel-movepoint))))))))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
251
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
252 (defun vc-set-mode-line-busy-indicator ()
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
253 (setq mode-line-process
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
254 (concat " " (propertize "[waiting...]"
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
255 'face 'mode-line-emphasis
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
256 'help-echo
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
257 "A VC command is in progress in this buffer"))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
258
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
259 (defun vc-exec-after (code)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
260 "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
261 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
262 Else, add CODE to the process' sentinel."
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
263 (let ((proc (get-buffer-process (current-buffer))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
264 (cond
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
265 ;; 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
266 ;; 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
267 ;; 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
268 ;; lost. Terminated processes get deleted automatically
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
269 ;; anyway. -- cyd
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
270 ((or (null proc) (eq (process-status proc) 'exit))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
271 ;; 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
272 (when proc (accept-process-output proc))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
273 (eval code))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
274 ;; 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
275 ((eq (process-status proc) 'run)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
276 (vc-set-mode-line-busy-indicator)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
277 (let ((previous (process-sentinel proc)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
278 (unless (eq previous 'vc-process-sentinel)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
279 (process-put proc 'vc-previous-sentinel previous))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
280 (set-process-sentinel proc 'vc-process-sentinel))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
281 (process-put proc 'vc-sentinel-commands
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
282 ;; We keep the code fragments in the order given
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
283 ;; 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
284 ;; the presence of non-nil vc-command-messages.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
285 (append (process-get proc 'vc-sentinel-commands)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
286 (list code))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
287 (t (error "Unexpected process state"))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
288 nil)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
289
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
290 (defvar vc-post-command-functions nil
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
291 "Hook run at the end of `vc-do-command'.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
292 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
293 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
294
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
295 (defvar w32-quote-process-args)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
296
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
297 (defun vc-delistify (filelist)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
298 "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
299 ;; FIXME what about file names with spaces?
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
300 (if (not filelist) "." (mapconcat 'identity filelist " ")))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
301
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
302 ;;;###autoload
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
303 (defun vc-do-command (buffer okstatus command file-or-list &rest flags)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
304 "Execute a VC command, notifying user and checking for errors.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
305 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
306 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
307 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
308 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
309 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
310 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
311 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
312 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
313 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
314 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
315 ;; 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
316 ;; 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
317 ;; come into play.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
318 (let* ((files
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
319 (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
320 (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
321 (full-command
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
322 ;; 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
323 ;; 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
324 ;; 20 characters display the entire command (without trailing
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
325 ;; 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
326 (concat (if (string= (substring command -1) "\n")
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
327 (substring command 0 -1)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
328 command)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
329 " "
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
330 (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
331 " " (vc-delistify files))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
332 (save-current-buffer
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
333 (unless (or (eq buffer t)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
334 (and (stringp buffer)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
335 (string= (buffer-name) buffer))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
336 (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
337 (vc-setup-buffer (or buffer "*vc*")))
94571
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
338 ;; 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
339 (let ((oldproc (get-buffer-process (current-buffer))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
340 ;; 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
341 ;; something, we'd have used vc-eval-after.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
342 ;; 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
343 ;; 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
344 (if oldproc (delete-process oldproc)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
345 (let ((squeezed (remq nil flags))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
346 (inhibit-read-only t)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
347 (status 0))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
348 (when files
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
349 (setq squeezed (nconc squeezed files)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
350 (let ((exec-path (append vc-path exec-path))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
351 ;; 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
352 (process-environment
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
353 (cons (concat "PATH=" (getenv "PATH")
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
354 path-separator
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
355 (mapconcat 'identity vc-path path-separator))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
356 process-environment))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
357 (w32-quote-process-args t))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
358 (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
359 ;; start-process does not support remote execution
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
360 (setq okstatus nil))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
361 (if (eq okstatus 'async)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
362 ;; Run asynchronously.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
363 (let ((proc
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
364 (let ((process-connection-type nil))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
365 (apply 'start-file-process command (current-buffer)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
366 command squeezed))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
367 (if vc-command-messages
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
368 (message "Running %s in background..." full-command))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
369 ;;(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
370 (set-process-filter proc 'vc-process-filter)
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
371 (vc-exec-after
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
372 `(if vc-command-messages
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
373 (message "Running %s in background... done" ',full-command))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
374 ;; Run synchrously
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
375 (when vc-command-messages
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
376 (message "Running %s in foreground..." full-command))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
377 (let ((buffer-undo-list t))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
378 (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
379 (when (and (not (eq t okstatus))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
380 (or (not (integerp status))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
381 (and okstatus (< okstatus status))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
382 (unless (eq ?\s (aref (buffer-name (current-buffer)) 0))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
383 (pop-to-buffer (current-buffer))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
384 (goto-char (point-min))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
385 (shrink-window-if-larger-than-buffer))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
386 (error "Running %s...FAILED (%s)" full-command
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
387 (if (integerp status) (format "status %d" status) status))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
388 ;; 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
389 ;; asychronously, it would just mislead.
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
390 (if (and vc-command-messages (not (eq okstatus 'async)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
391 (message "Running %s...OK = %d" full-command status)))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
392 (vc-exec-after
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
393 `(run-hook-with-args 'vc-post-command-functions
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
394 ',command ',file-or-list ',flags))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
395 status))))
61cca370b8f5 vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
396
94579
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
397 ;; 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
398 ;; 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
399 ;; for example, VCS keyword expansion).
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
400
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
401 (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
402
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
403 (defun vc-position-context (posn)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
404 "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
405 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
406 if markers are destroyed or corrupted."
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
407 ;; 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
408 ;; rcs.el mode.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
409 (list posn
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
410 (buffer-size)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
411 (buffer-substring posn
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
412 (min (point-max) (+ posn 100)))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
413
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
414 (defun vc-find-position-by-context (context)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
415 "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
416 If CONTEXT cannot be found, return nil."
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
417 (let ((context-string (nth 2 context)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
418 (if (equal "" context-string)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
419 (point-max)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
420 (save-excursion
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
421 (let ((diff (- (nth 1 context) (buffer-size))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
422 (when (< diff 0) (setq diff (- diff)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
423 (goto-char (nth 0 context))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
424 (if (or (search-forward context-string nil t)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
425 ;; 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
426 ;; after point.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
427 (progn (goto-char (- (point) diff (length context-string)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
428 ;; goto-char doesn't signal an error at
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
429 ;; beginning of buffer like backward-char would
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
430 (search-forward context-string nil t)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
431 ;; to beginning of OSTRING
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
432 (- (point) (length context-string))))))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
433
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
434 (defun vc-context-matches-p (posn context)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
435 "Return t if POSN matches CONTEXT, nil otherwise."
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
436 (let* ((context-string (nth 2 context))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
437 (len (length context-string))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
438 (end (+ posn len)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
439 (if (> end (1+ (buffer-size)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
440 nil
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
441 (string= context-string (buffer-substring posn end)))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
442
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
443 (defun vc-buffer-context ()
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
444 "Return a list (POINT-CONTEXT MARK-CONTEXT REPARSE).
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
445 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
446 (let ((point-context (vc-position-context (point)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
447 ;; Use mark-marker to avoid confusion in transient-mark-mode.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
448 (mark-context (when (eq (marker-buffer (mark-marker)) (current-buffer))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
449 (vc-position-context (mark-marker))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
450 ;; Make the right thing happen in transient-mark-mode.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
451 (mark-active nil)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
452 ;; The new compilation code does not use compilation-error-list any
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
453 ;; more, so the code below is now ineffective and might as well
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
454 ;; be disabled. -- Stef
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
455 ;; ;; We may want to reparse the compilation buffer after revert
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
456 ;; (reparse (and (boundp 'compilation-error-list) ;compile loaded
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
457 ;; ;; Construct a list; each elt is nil or a buffer
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
458 ;; ;; if that buffer is a compilation output buffer
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
459 ;; ;; that contains markers into the current buffer.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
460 ;; (save-current-buffer
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
461 ;; (mapcar (lambda (buffer)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
462 ;; (set-buffer buffer)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
463 ;; (let ((errors (or
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
464 ;; compilation-old-error-list
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
465 ;; compilation-error-list))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
466 ;; (buffer-error-marked-p nil))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
467 ;; (while (and (consp errors)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
468 ;; (not buffer-error-marked-p))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
469 ;; (and (markerp (cdr (car errors)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
470 ;; (eq buffer
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
471 ;; (marker-buffer
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
472 ;; (cdr (car errors))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
473 ;; (setq buffer-error-marked-p t))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
474 ;; (setq errors (cdr errors)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
475 ;; (if buffer-error-marked-p buffer)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
476 ;; (buffer-list)))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
477 (reparse nil))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
478 (list point-context mark-context reparse)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
479
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
480 (defun vc-restore-buffer-context (context)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
481 "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
482 CONTEXT is that which `vc-buffer-context' returns."
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
483 (let ((point-context (nth 0 context))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
484 (mark-context (nth 1 context))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
485 ;; (reparse (nth 2 context))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
486 )
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
487 ;; The new compilation code does not use compilation-error-list any
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
488 ;; more, so the code below is now ineffective and might as well
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
489 ;; be disabled. -- Stef
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
490 ;; ;; Reparse affected compilation buffers.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
491 ;; (while reparse
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
492 ;; (if (car reparse)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
493 ;; (with-current-buffer (car reparse)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
494 ;; (let ((compilation-last-buffer (current-buffer)) ;select buffer
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
495 ;; ;; Record the position in the compilation buffer of
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
496 ;; ;; the last error next-error went to.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
497 ;; (error-pos (marker-position
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
498 ;; (car (car-safe compilation-error-list)))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
499 ;; ;; Reparse the error messages as far as they were parsed before.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
500 ;; (compile-reinitialize-errors '(4) compilation-parsing-end)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
501 ;; ;; Move the pointer up to find the error we were at before
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
502 ;; ;; reparsing. Now next-error should properly go to the next one.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
503 ;; (while (and compilation-error-list
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
504 ;; (/= error-pos (car (car compilation-error-list))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
505 ;; (setq compilation-error-list (cdr compilation-error-list))))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
506 ;; (setq reparse (cdr reparse)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
507
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
508 ;; if necessary, restore point and mark
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
509 (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
510 (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
511 (when new-point (goto-char new-point))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
512 (and mark-active
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
513 mark-context
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
514 (not (vc-context-matches-p (mark) mark-context))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
515 (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
516 (when new-mark (set-mark new-mark))))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
517
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
518 (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
519 "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
520 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
521 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
522 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
523 (interactive "P")
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
524 (widen)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
525 (let ((context (vc-buffer-context)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
526 ;; 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
527 ;; 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
528 ;; 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
529 ;; 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
530 (save-excursion
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
531 ;; t means don't call normal-mode;
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
532 ;; that's to preserve various minor modes.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
533 (revert-buffer arg no-confirm t))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
534 (vc-restore-buffer-context context)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
535
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
536 (defun vc-resynch-window (file &optional keep noquery)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
537 "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
538 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
539 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
540 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
541 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
542 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
543 editing!"
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
544 (and (string= buffer-file-name file)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
545 (if keep
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
546 (progn
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
547 (vc-revert-buffer-internal t noquery)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
548 ;; 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
549 ;; 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
550 ;; this when we install the new VC.
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
551 (and view-read-only
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
552 (if (file-writable-p file)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
553 (and view-mode
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
554 (let ((view-old-buffer-read-only nil))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
555 (view-mode-exit)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
556 (and (not view-mode)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
557 (not (eq (get major-mode 'mode-class) 'special))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
558 (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
559 (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
560 (kill-buffer (current-buffer)))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
561
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
562 (defun vc-resynch-buffer (file &optional keep noquery)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
563 "If FILE is currently visited, resynch its buffer."
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
564 (if (string= buffer-file-name file)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
565 (vc-resynch-window file keep noquery)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
566 (let ((buffer (get-file-buffer file)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
567 (when buffer
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
568 (with-current-buffer buffer
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
569 (vc-resynch-window file keep noquery)))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
570 (vc-directory-resynch-file file)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
571 (when (memq 'vc-dir-mark-buffer-changed after-save-hook)
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
572 (let ((buffer (get-file-buffer file)))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
573 (vc-dir-mark-buffer-changed file))))
dca2377770e7 Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94576
diff changeset
574
94576
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
575 ;; Command closures
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
576
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
577 (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
578 "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
579 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
580 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
581 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
582 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
583 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
584 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
585 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
586 \(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
587 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
588 (let ((parent
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
589 (if (or (eq major-mode 'vc-dired-mode) (eq major-mode 'vc-dir-mode))
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
590 ;; If we are called from VC dired, the parent buffer is
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
591 ;; the current buffer.
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
592 (current-buffer)
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
593 (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
594 (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
595 (current-buffer)))))
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
596 (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
597 (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
598 (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
599 (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
600 (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
601 (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
602 (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
603 (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
604 (when after-hook
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
605 (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
606 (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
607 (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
608 (when comment
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
609 (erase-buffer)
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
610 (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
611 (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
612 (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
613 (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
614
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
615 (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
616 "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
617 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
618 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
619 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
620 (interactive)
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
621 ;; 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
622 (unless nocomment
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
623 (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
624 ;; Sync parent buffer in case the user modified it while editing the comment.
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
625 ;; But not if it is a vc-dired buffer.
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
626 (with-current-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
627 (or vc-dired-mode (eq major-mode 'vc-dir-mode) (vc-buffer-sync)))
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
628 (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
629 (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
630 ;; 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
631 (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
632 (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
633 (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
634 (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
635 (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
636 (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
637 (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
638 ;; 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
639 (save-excursion
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
640 (funcall log-operation
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
641 log-fileset
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
642 log-extra
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
643 log-entry))
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
644 ;; 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
645 ;; 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
646 ;; -- 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
647 (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
648 (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
649 (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
650 ;; 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
651 (kill-buffer logbuf))
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
652 (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
653 (bury-buffer)
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
654 (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
655 ;; 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
656 (when log-fileset
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
657 (mapc
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
658 (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
659 log-fileset))
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
660 (when vc-dired-mode
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
661 (dired-move-to-filename))
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
662 (when (eq major-mode 'vc-dir-mode)
7de38dedf0a6 Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94573
diff changeset
663 (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
664 (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
665
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
666 ;; VC-Dired 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
667 ;; FIXME: to be removed when vc-dir support is finished
94582
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
668
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
669 (defcustom vc-dired-listing-switches "-al"
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
670 "Switches passed to `ls' for vc-dired. MUST contain the `l' option."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
671 :type 'string
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
672 :group 'vc
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
673 :version "21.1")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
674
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
675 (defcustom vc-dired-recurse t
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
676 "If non-nil, show directory trees recursively in VC Dired."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
677 :type 'boolean
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
678 :group 'vc
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
679 :version "20.3")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
680
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
681 (defcustom vc-dired-terse-display t
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
682 "If non-nil, show only locked or locally modified files in VC Dired."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
683 :type 'boolean
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
684 :group 'vc
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
685 :version "20.3")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
686
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
687 (defvar vc-dired-mode nil)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
688 (defvar vc-dired-window-configuration)
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
689 (defvar vc-dired-switches)
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 (defvar vc-dired-terse-mode)
94582
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
691
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
692 (make-variable-buffer-local 'vc-dired-mode)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
693
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
694 (defvar vc-dired-mode-map
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
695 (let ((map (make-sparse-keymap))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
696 (vmap (make-sparse-keymap)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
697 (define-key map "\C-xv" vmap)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
698 (define-key map "v" vmap)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
699 (set-keymap-parent vmap vc-prefix-map)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
700 (define-key vmap "t" 'vc-dired-toggle-terse-mode)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
701 map))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
702
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
703 (define-derived-mode vc-dired-mode dired-mode "Dired under VC"
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
704 "The major mode used in VC directory buffers.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
705
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
706 It works like Dired, but lists only files under version control, with
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
707 the current VC state of each file being indicated in the place of the
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
708 file's link count, owner, group and size. Subdirectories are also
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
709 listed, and you may insert them into the buffer as desired, like in
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
710 Dired.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
711
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
712 All Dired commands operate normally, with the exception of `v', which
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
713 is redefined as the version control prefix, so that you can type
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
714 `vl', `v=' etc. to invoke `vc-print-log', `vc-diff', and the like on
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
715 the file named in the current Dired buffer line. `vv' invokes
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
716 `vc-next-action' on this file, or on all files currently marked.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
717 There is a special command, `*l', to mark all files currently locked."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
718 ;; define-derived-mode does it for us in Emacs-21, but not in Emacs-20.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
719 ;; We do it here because dired might not be loaded yet
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
720 ;; when vc-dired-mode-map is initialized.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
721 (set-keymap-parent vc-dired-mode-map dired-mode-map)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
722 (add-hook 'dired-after-readin-hook 'vc-dired-hook nil t)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
723 ;; The following is slightly modified from files.el,
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
724 ;; because file lines look a bit different in vc-dired-mode
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
725 ;; (the column before the date does not end in a digit).
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
726 ;; albinus: It should be done in the original declaration. Problem
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
727 ;; is the optional empty state-info; otherwise ")" would be good
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
728 ;; enough as delimeter.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
729 (set (make-local-variable 'directory-listing-before-filename-regexp)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
730 (let* ((l "\\([A-Za-z]\\|[^\0-\177]\\)")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
731 ;; In some locales, month abbreviations are as short as 2 letters,
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
732 ;; and they can be followed by ".".
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
733 (month (concat l l "+\\.?"))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
734 (s " ")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
735 (yyyy "[0-9][0-9][0-9][0-9]")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
736 (dd "[ 0-3][0-9]")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
737 (HH:MM "[ 0-2][0-9]:[0-5][0-9]")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
738 (seconds "[0-6][0-9]\\([.,][0-9]+\\)?")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
739 (zone "[-+][0-2][0-9][0-5][0-9]")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
740 (iso-mm-dd "[01][0-9]-[0-3][0-9]")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
741 (iso-time (concat HH:MM "\\(:" seconds "\\( ?" zone "\\)?\\)?"))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
742 (iso (concat "\\(\\(" yyyy "-\\)?" iso-mm-dd "[ T]" iso-time
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
743 "\\|" yyyy "-" iso-mm-dd "\\)"))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
744 (western (concat "\\(" month s "+" dd "\\|" dd "\\.?" s month "\\)"
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
745 s "+"
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
746 "\\(" HH:MM "\\|" yyyy "\\)"))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
747 (western-comma (concat month s "+" dd "," s "+" yyyy))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
748 ;; Japanese MS-Windows ls-lisp has one-digit months, and
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
749 ;; omits the Kanji characters after month and day-of-month.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
750 (mm "[ 0-1]?[0-9]")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
751 (japanese
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
752 (concat mm l "?" s dd l "?" s "+"
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
753 "\\(" HH:MM "\\|" yyyy l "?" "\\)")))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
754 ;; the .* below ensures that we find the last match on a line
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
755 (concat ".*" s
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
756 "\\(" western "\\|" western-comma "\\|" japanese "\\|" iso "\\)"
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
757 s "+")))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
758 (and (boundp 'vc-dired-switches)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
759 vc-dired-switches
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
760 (set (make-local-variable 'dired-actual-switches)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
761 vc-dired-switches))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
762 (set (make-local-variable 'vc-dired-terse-mode) vc-dired-terse-display)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
763 ;;(let ((backend-name (symbol-name (vc-responsible-backend
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
764 ;; default-directory))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
765 ;; (setq mode-name (concat mode-name backend-name))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
766 ;; ;; Add menu after `vc-dired-mode-map' has `dired-mode-map' as the parent.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
767 ;; (let ((vc-dire-menu-map (copy-keymap vc-menu-map)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
768 ;; (define-key-after (lookup-key vc-dired-mode-map [menu-bar]) [vc]
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
769 ;; (cons backend-name vc-dire-menu-map) 'subdir)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
770 (setq vc-dired-mode t))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
771
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
772 (defun vc-dired-toggle-terse-mode ()
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
773 "Toggle terse display in VC Dired."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
774 (interactive)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
775 (if (not vc-dired-mode)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
776 nil
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
777 (setq vc-dired-terse-mode (not vc-dired-terse-mode))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
778 (if vc-dired-terse-mode
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
779 (vc-dired-hook)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
780 (revert-buffer))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
781
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
782 (defun vc-dired-mark-locked ()
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
783 "Mark all files currently locked."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
784 (interactive)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
785 (dired-mark-if (let ((f (dired-get-filename nil t)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
786 (and f
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
787 (not (file-directory-p f))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
788 (not (vc-up-to-date-p f))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
789 "locked file"))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
790
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
791 (define-key vc-dired-mode-map "*l" 'vc-dired-mark-locked)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
792
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
793 (defun vc-dired-reformat-line (vc-info)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
794 "Reformat a directory-listing line.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
795 Replace various columns with version control information, VC-INFO.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
796 This code, like dired, assumes UNIX -l format."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
797 (beginning-of-line)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
798 (when (re-search-forward
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
799 ;; Match link count, owner, group, size. Group may be missing,
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
800 ;; and only the size is present in OS/2 -l format.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
801 "^..[drwxlts-]+ \\( *[0-9]+\\( [^ ]+ +\\([^ ]+ +\\)?[0-9]+\\)?\\) "
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
802 (line-end-position) t)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
803 (replace-match (substring (concat vc-info " ") 0 10)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
804 t t nil 1)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
805
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
806 (defun vc-dired-ignorable-p (filename)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
807 "Should FILENAME be ignored in VC-Dired listings?"
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
808 (catch t
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
809 ;; Ignore anything that wouldn't be found by completion (.o, .la, etc.)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
810 (dolist (ignorable completion-ignored-extensions)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
811 (let ((ext (substring filename
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
812 (- (length filename)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
813 (length ignorable)))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
814 (if (string= ignorable ext) (throw t t))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
815 ;; Ignore Makefiles derived from something else
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
816 (when (string= (file-name-nondirectory filename) "Makefile")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
817 (let* ((dir (file-name-directory filename))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
818 (peers (directory-files (or dir default-directory))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
819 (if (or (member "Makefile.in" peers) (member "Makefile.am" peers))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
820 (throw t t))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
821 nil))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
822
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
823 (defun vc-dired-purge ()
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
824 "Remove empty subdirs."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
825 (goto-char (point-min))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
826 (while (dired-get-subdir)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
827 (forward-line 2)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
828 (if (dired-get-filename nil t)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
829 (if (not (dired-next-subdir 1 t))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
830 (goto-char (point-max)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
831 (forward-line -2)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
832 (if (not (string= (dired-current-directory) default-directory))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
833 (dired-do-kill-lines t "")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
834 ;; We cannot remove the top level directory.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
835 ;; Just make it look a little nicer.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
836 (forward-line 1)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
837 (or (eobp) (kill-line))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
838 (if (not (dired-next-subdir 1 t))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
839 (goto-char (point-max))))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
840 (goto-char (point-min)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
841
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
842 (defun vc-dired-buffers-for-dir (dir)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
843 "Return a list of all vc-dired buffers that currently display DIR."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
844 (let (result)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
845 ;; Check whether dired is loaded.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
846 (when (fboundp 'dired-buffers-for-dir)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
847 (dolist (buffer (dired-buffers-for-dir dir))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
848 (with-current-buffer buffer
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
849 (when vc-dired-mode
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
850 (push buffer result)))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
851 (nreverse result)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
852
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
853 (defun vc-directory-resynch-file (file)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
854 "Update the entries for FILE in any VC Dired buffers that list it."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
855 ;;FIXME This needs to be implemented so it works for vc-dir
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
856 (let ((buffers (vc-dired-buffers-for-dir (file-name-directory file))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
857 (when buffers
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
858 (mapcar (lambda (buffer)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
859 (with-current-buffer buffer
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
860 (when (dired-goto-file file)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
861 ;; bind vc-dired-terse-mode to nil so that
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
862 ;; files won't vanish when they are checked in
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
863 (let ((vc-dired-terse-mode nil))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
864 (dired-do-redisplay 1)))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
865 buffers))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
866
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
867 ;;;###autoload
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
868 (defun vc-directory (dir read-switches)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
869 "Create a buffer in VC Dired Mode for directory DIR.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
870
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
871 See Info node `VC Dired Mode'.
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
872
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
873 With prefix arg READ-SWITCHES, specify a value to override
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
874 `dired-listing-switches' when generating the listing."
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
875 (interactive "DDired under VC (directory): \nP")
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
876 (let ((vc-dired-switches (concat vc-dired-listing-switches
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
877 (if vc-dired-recurse "R" ""))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
878 (if read-switches
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
879 (setq vc-dired-switches
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
880 (read-string "Dired listing switches: "
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
881 vc-dired-switches)))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
882 (require 'dired)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
883 (require 'dired-aux)
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
884 (switch-to-buffer
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
885 (dired-internal-noselect (expand-file-name (file-name-as-directory dir))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
886 vc-dired-switches
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
887 'vc-dired-mode))))
8393f040d26d Move VC-Dired code from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94579
diff changeset
888
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
889 ;; 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
890
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
891 (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
892 "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
893 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
894 :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
895 :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
896
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 ;; 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
898 ;; 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
899 (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
900 (: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
901 (: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
902 (: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
903 ;; 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
904 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
905 (: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
906 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
907 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
908 ;; 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
909 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
910 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
911 ;; 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
912 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
913 ;; 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
914 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
915
94611
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
916 ;; 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
917 (defstruct (vc-client-object
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
918 (:copier nil)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
919 (:constructor
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
920 vc-create-client-object (name
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
921 headers
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
922 file-to-info
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
923 file-to-state
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
924 file-to-extra
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
925 updater))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
926 (:conc-name vc-client-object->))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
927 name
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
928 headers
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
929 file-to-info
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
930 file-to-state
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
931 file-to-extra
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
932 updater)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
933
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
934 (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
935 (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
936 "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
937
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 (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
939 ;; 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
940 (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
941 ;; 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
942 (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
943
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
944 (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
945 "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
946 (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
947 (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
948 ;; 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
949 (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
950 (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
951 (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
952 (set-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
953 (when (and (eq major-mode '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
954 (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
955 (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
956 (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
957 ;; 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
958 (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
959 (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
960 (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
961 ;; 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
962 ;; 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
963 (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
964 (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
965
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
966 (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
967 (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
968 (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
969 '(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
970 :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
971 (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
972 '(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
973 :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
974 :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
975 (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
976 '(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
977 :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
978 :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
979 ;; 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
980 (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
981 (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
982 '(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
983 :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
984 (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
985 '(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
986 :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
987 ;; 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
988 (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
989 (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
990 '(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
991 :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
992 \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
993 (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
994 '(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
995 :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
996
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
997 (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
998 '(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
999 :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
1000 \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
1001 (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
1002 '(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
1003 :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
1004
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 (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
1006 '(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
1007 :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
1008
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 (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
1010 (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
1011 '(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
1012 :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
1013 (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
1014 '(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
1015 :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
1016 ;; FIXME: Stuff starting here should be appended by 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
1017 ;; VC info details
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 (define-key map [sepvcdet] '("--"))
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 (define-key map [remup]
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 '(menu-item "Hide up-to-date" vc-dir-hide-up-to-date
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 :help "Hide up-to-date items from display"))
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 ;; FIXME: This needs a key binding. And maybe a better 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
1023 ;; ("Insert" like PCL-CVS uses does not sound that great either)...
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 (define-key map [ins]
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 '(menu-item "Show File" vc-dir-show-fileentry
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 :help "Show a file in the VC status listing even though it might be up to date"))
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 (define-key map [annotate]
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 '(menu-item "Annotate" vc-annotate
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 :help "Display the edit history of the current file using colors"))
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 (define-key map [diff]
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 '(menu-item "Compare with Base Version" vc-diff
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 :help "Compare file set with the base version"))
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 (define-key map [log]
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 '(menu-item "Show history" vc-print-log
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 :help "List the change log of the current file set in a 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
1036 ;; VC commands.
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 (define-key map [sepvccmd] '("--"))
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 (define-key map [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
1039 '(menu-item "Update to latest version" vc-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
1040 :help "Update the current fileset's files to their tip revisions"))
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 (define-key map [revert]
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 '(menu-item "Revert to base version" vc-revert
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 :help "Revert working copies of the selected fileset to their repository contents."))
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 (define-key map [next-action]
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 ;; FIXME: This really really really needs a better 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
1046 ;; And a key binding too.
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 '(menu-item "Check In/Out" vc-next-action
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 :help "Do the next logical version control operation on the current fileset"))
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 (define-key map [register]
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 '(menu-item "Register" vc-dir-register
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 :help "Register file set into the version control system"))
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 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
1053 "Menu for 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
1054
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 (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
1056
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 (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
1058 (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
1059 (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
1060 ;; 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
1061 (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
1062 (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
1063 (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
1064 (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
1065 (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
1066 (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
1067 ;; 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
1068 (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
1069 (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
1070 (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
1071 (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
1072 (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
1073 ;; 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
1074 (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
1075 (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
1076 (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
1077 (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
1078 (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
1079 (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
1080 (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
1081 (define-key map [(mouse-2)] 'vc-dir-toggle-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
1082
94611
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1083 ;; FIXME: Calls back into vc.el
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
1084 ;; Hook up the 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
1085 (define-key map [menu-bar 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
1086 '(menu-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
1087 ;; This is used so that client modes can add mode-specific
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 ;; menu items to 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
1089 "VC Status" vc-dir-menu-map :filter vc-dir-menu-map-filter))
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 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
1091 "Keymap for 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
1092
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 (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
1094 "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
1095 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
1096 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
1097 (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
1098 `(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
1099 (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
1100 (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
1101 (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
1102 ,@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
1103
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 (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
1105 "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
1106 (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
1107 (vc-at-event e (popup-menu vc-dir-menu-map 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
1108
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 (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
1110 (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
1111 (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
1112 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
1113 (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
1114 '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
1115 :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
1116 (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
1117 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
1118 :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
1119 (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
1120 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
1121 :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
1122 (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
1123 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
1124 (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
1125 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
1126 (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
1127 "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
1128 (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
1129 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
1130 (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
1131 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
1132 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
1133
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 ;; t if directories should be shown in 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
1135 ;; WORK IN PROGRESS! DO NOT SET this! ONLY set it if you want to help
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 ;; write code for this feature. This variable will likely disappear
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 ;; when the work is done.
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 (defvar vc-dir-insert-directories 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
1139
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 (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
1141 "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
1142 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
1143 ;; 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
1144 (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
1145 ;; 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
1146 ;; 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
1147 ;; 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
1148 (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
1149 ;; 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
1150 ;; 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
1151 ;; 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
1152 (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
1153 (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
1154 (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
1155 (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
1156 (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
1157 ((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
1158 ((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
1159 ((string< (car entry1) (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
1160 (if (not vc-dir-insert-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
1161 (let ((entry (car 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
1162 (node (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
1163 (while (and entry 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
1164 (let ((entryfile (car 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
1165 (nodefile (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
1166 (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
1167 ((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
1168 (setq node (ewoc-next 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
1169 ((string-lessp entryfile nodefile)
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 (unless 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
1171 (ewoc-enter-before 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
1172 (apply 'vc-dir-create-fileinfo 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
1173 (setq entries (cdr entries) entry (car 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
1174 (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
1175 (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
1176 (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
1177 (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
1178 (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
1179 (setq entries (cdr entries) entry (car 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
1180 (setq node (ewoc-next 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
1181 (unless (or node 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
1182 ;; We're past the last node, all remaining entries go to the 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
1183 (while 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
1184 (ewoc-enter-last 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
1185 (apply 'vc-dir-create-fileinfo (pop 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
1186 ;; Insert directory entries in the right places.
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 ((entry (car 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
1188 (node (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
1189 ;; Insert . if it is not present.
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 (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
1191 (let ((rd (file-relative-name default-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
1192 (ewoc-enter-last
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 vc-ewoc (vc-dir-create-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
1194 rd nil nil nil (expand-file-name default-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
1195 (setq node (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
1196
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 (while (and entry 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
1198 (let* ((entryfile (car 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
1199 (entrydir (file-name-directory (expand-file-name 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
1200 (nodedir
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1201 (or (vc-dir-fileinfo->directory (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
1202 (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
1203 (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
1204 (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
1205 (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
1206 ;; First try to find 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
1207 ((string-lessp nodedir entrydir)
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1208 (setq node (ewoc-next 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
1209 ((string-equal nodedir entrydir)
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1210 ;; Found the directory, find the place for the 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
1211 (let ((nodefile (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
1212 (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
1213 ((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
1214 (setq node (ewoc-next 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
1215 ((string-equal 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
1216 (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
1217 (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
1218 (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
1219 (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
1220 (setq entries (cdr entries) entry (car 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
1221 (setq node (ewoc-next 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
1222 (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
1223 (ewoc-enter-before 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
1224 (apply 'vc-dir-create-fileinfo 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
1225 (setq entries (cdr entries) entry (car 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
1226 (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
1227 ;; We need to insert a directory 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
1228 (let ((rd (file-relative-name entrydir)))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1229 (ewoc-enter-last
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1230 vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir)))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1231 ;; Now insert the node itself.
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1232 (ewoc-enter-before 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
1233 (apply 'vc-dir-create-fileinfo 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
1234 (setq entries (cdr entries) entry (car 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
1235 ;; We're past the last node, all remaining entries go to the 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
1236 (unless (or node 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
1237 (let* ((lastnode (ewoc-nth 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
1238 (lastdir
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1239 (or (vc-dir-fileinfo->directory (ewoc-data lastnode))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1240 (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
1241 (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
1242 (vc-dir-fileinfo->name (ewoc-data lastnode)))))))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1243 (dolist (entry 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
1244 (let ((entrydir (file-name-directory (expand-file-name (car 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
1245 ;; Insert a directory node if needed.
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1246 (unless (string-equal lastdir entrydir)
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1247 (setq lastdir entrydir)
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1248 (let ((rd (file-relative-name entrydir)))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1249 (ewoc-enter-last
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1250 vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir))))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1251 ;; Now insert the node itself.
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1252 (ewoc-enter-last 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
1253 (apply 'vc-dir-create-fileinfo 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
1254
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1255 (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
1256 (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
1257 (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
1258
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1259 (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
1260 "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
1261 (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
1262 (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
1263 (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
1264 (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
1265 (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
1266 (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
1267
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1268 (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
1269 ;; 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
1270 ;; 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
1271 (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
1272 (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
1273 (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
1274 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
1275 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
1276
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1277 (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
1278 "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
1279 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
1280 (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
1281 (ewoc-goto-next 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
1282 (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
1283
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1284 (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
1285 "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
1286 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
1287 (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
1288 (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
1289 (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
1290
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1291 (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
1292 (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
1293 (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
1294 (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
1295 (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
1296 (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
1297 (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
1298 (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
1299 (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
1300
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1301 (defun vc-dir-parent-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
1302 (when vc-dir-insert-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
1303 ;; Return nil if none of the parent directories of arg is 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
1304 (let* ((argdata (ewoc-data 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
1305 (argdir
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1306 (let ((crtdir (vc-dir-fileinfo->directory argdata)))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1307 (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
1308 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
1309 (file-name-directory (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
1310 (vc-dir-fileinfo->name argdata))))))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1311 (arglen (length argdir))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1312 (crt 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
1313 data 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
1314 ;; Go through the predecessors, checking if any directory that is
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1315 ;; a parent is 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
1316 (while (setq crt (ewoc-prev 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
1317 (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
1318 (setq 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
1319 (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
1320 (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
1321 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
1322 (file-name-directory (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
1323 (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
1324
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1325 (when (and (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
1326 (string-equal (substring argdir 0 (length dir)) 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
1327 (when (vc-dir-fileinfo->marked 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
1328 (error "Cannot mark `%s', parent 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
1329 (vc-dir-fileinfo->name argdata)
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1330 (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
1331 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
1332
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1333 (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
1334 ;; Return nil if none of the children of arg is 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
1335 (when vc-dir-insert-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
1336 (let* ((argdata (ewoc-data 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
1337 (argdir (vc-dir-fileinfo->directory argdata))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1338 (arglen (length argdir))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1339 (is-child 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
1340 (crt 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
1341 data 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
1342 (while (and is-child (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
1343 (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
1344 (setq 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
1345 (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
1346 (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
1347 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
1348 (file-name-directory (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
1349 (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
1350 (if (string-equal argdir (substring dir 0 arglen))
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1351 (when (vc-dir-fileinfo->marked 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
1352 (error "Cannot mark `%s', child `%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
1353 (vc-dir-fileinfo->name argdata)
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1354 (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
1355 ;; We are done, we got to an entry that is not a child of `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
1356 (setq is-child 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
1357 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
1358
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1359 (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
1360 ;; 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
1361 (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
1362 (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
1363 (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
1364 (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
1365 (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
1366 (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
1367 (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
1368 (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
1369 (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
1370
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1371 (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
1372 "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
1373 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
1374 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
1375 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
1376 (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
1377 (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
1378
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1379 (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
1380 "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
1381 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
1382 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
1383
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1384 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
1385 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
1386 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
1387 (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
1388 (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
1389 ;; 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
1390 (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
1391 ;; 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
1392 ;; 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
1393 (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
1394 (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
1395 (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
1396 (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
1397 (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
1398 (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
1399 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
1400 (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
1401 (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
1402 (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
1403 (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
1404 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
1405 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
1406 (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
1407 (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
1408 ;; 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
1409 (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
1410 (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
1411 (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
1412 (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
1413 (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
1414 (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
1415 (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
1416 ;; 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
1417 (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
1418 (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
1419 (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
1420 (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
1421 (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
1422 (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
1423 (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
1424 (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
1425 (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
1426
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1427 (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
1428 ;; 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
1429 (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
1430 (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
1431 (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
1432 (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
1433 (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
1434 (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
1435
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1436 (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
1437 "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
1438 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
1439 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
1440 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
1441 (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
1442 (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
1443
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1444 (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
1445 "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
1446 (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
1447 ;; 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
1448 ;; 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
1449 ;; 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
1450 (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
1451 (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
1452 (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
1453 (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
1454 (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
1455
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1456 (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
1457 "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
1458 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
1459 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
1460
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1461 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
1462 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
1463 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
1464 (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
1465 (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
1466 (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
1467 (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
1468 (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
1469 (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
1470 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
1471 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
1472 (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
1473 (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
1474 (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
1475 ;; 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
1476 (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
1477 (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
1478 (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
1479 (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
1480 (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
1481 ;; 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
1482 (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
1483 (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
1484 (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
1485 (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
1486 (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
1487 (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
1488 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
1489 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
1490
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1491 (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
1492 (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
1493 (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
1494 (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
1495 (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
1496 (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
1497
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1498 (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
1499 (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
1500 (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
1501
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1502 (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
1503 "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
1504 (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
1505 (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
1506 (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
1507
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1508 (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
1509 "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
1510 (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
1511 (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
1512
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1513 (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
1514 "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
1515 (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
1516 (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
1517
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1518 (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
1519 (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
1520 (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
1521 (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
1522 (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
1523
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1524 (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
1525 "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
1526 (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
1527 (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
1528 (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
1529
f6d320d12050 Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94582
diff changeset
1530 (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
1531 "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
1532 (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
1533 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
1534 (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
1535 (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
1536 (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
1537 (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
1538 (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
1539 (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
1540 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
1541 (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
1542 (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
1543 (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
1544 (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
1545 (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
1546 (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
1547 (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
1548 (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
1549 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
1550 (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
1551 (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
1552 (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
1553 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
1554 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
1555 (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
1556 (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
1557 (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
1558 (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
1559 (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
1560 result))
94637
cb8291c75f39 Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94625
diff changeset
1561
94611
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1562 (defun vc-dir-mark-buffer-changed (&optional fname)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1563 (let* ((file (or fname (expand-file-name buffer-file-name)))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1564 (found-vc-dir-buf nil))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1565 (save-excursion
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1566 (dolist (status-buf (buffer-list))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1567 (set-buffer status-buf)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1568 ;; look for a vc-dir buffer that might show this file.
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1569 (when (eq major-mode 'vc-dir-mode)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1570 (setq found-vc-dir-buf t)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1571 (let ((ddir (expand-file-name default-directory)))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1572 ;; This test is cvs-string-prefix-p
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1573 (when (eq t (compare-strings file nil (length ddir) ddir nil nil))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1574 (let*
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1575 ((file-short (substring file (length ddir)))
94625
be875b5d451e (vc-dir-mark-buffer-changed): Fix typo
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94613
diff changeset
1576 (state
be875b5d451e (vc-dir-mark-buffer-changed): Fix typo
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94613
diff changeset
1577 (funcall (vc-client-object->file-to-state vc-client-mode)
94637
cb8291c75f39 Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94625
diff changeset
1578 file))
94611
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1579 (extra
94625
be875b5d451e (vc-dir-mark-buffer-changed): Fix typo
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94613
diff changeset
1580 (funcall (vc-client-object->file-to-extra vc-client-mode)
94637
cb8291c75f39 Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94625
diff changeset
1581 file))
94611
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1582 (entry
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1583 (list file-short state extra)))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1584 (vc-dir-update (list entry) status-buf))))))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1585 ;; We didn't find any vc-dir buffers, remove the hook, it is
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1586 ;; not needed.
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1587 (unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-dir-mark-buffer-changed)))))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1588
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1589 (defun vc-dir-mode (client-object)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1590 "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
1591 Marking/Unmarking key bindings and actions:
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1592 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
1593 in region.
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1594 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
1595 - 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
1596 directory is marked
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1597 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
1598 in region.
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1599 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
1600 the current file
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1601 - 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
1602 - 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
1603 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
1604 as the current file
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1605 - 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
1606 - 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
1607
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1608
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1609 \\{vc-dir-mode-map}"
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1610 (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
1611 (setq major-mode 'vc-dir-mode)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1612 (setq buffer-read-only t)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1613 (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
1614 (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
1615 (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
1616 (let ((buffer-read-only nil))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1617 (erase-buffer)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1618 (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
1619 (set (make-local-variable 'vc-ewoc)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1620 (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
1621 (vc-client-object->headers client-object)))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1622 (add-hook 'after-save-hook 'vc-dir-mark-buffer-changed)
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1623 ;; 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
1624 ;; 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
1625 (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
1626 (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
1627 (run-hooks 'vc-dir-mode-hook))
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1628
78377ffa1363 Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94585
diff changeset
1629 (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
1630
94650
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1631 (defun vc-buffer-sync (&optional not-urgent)
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1632 "Make sure the current buffer and its working file are in sync.
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1633 NOT-URGENT means it is ok to continue if the user says not to save."
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1634 (when (buffer-modified-p)
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1635 (if (or vc-suppress-confirm
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1636 (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1637 (save-buffer)
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1638 (unless not-urgent
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1639 (error "Aborted")))))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1640
94647
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1641 (defun vc-dispatcher-browsing ()
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1642 "Are we in a directory browser buffer?"
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1643 (or vc-dired-mode (eq major-mode 'vc-dir-mode)))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1644
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1645 (defun vc-dispatcher-selection-set (eligible
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1646 &optional
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1647 allow-directory-wildcard
94692
891cb8f8888f More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94690
diff changeset
1648 allow-ineligible
94647
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1649 include-files-not-directories)
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1650 "Deduce a set of files to which to apply an operation. Return the fileset.
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1651 If we're in VC-dired mode, the fileset is the list of marked files.
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1652 Otherwise, if we're looking at a buffer for which ELIGIBLE returns non-NIL,
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1653 the fileset is a singleton containing this file.
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1654 If neither of these things is true, but ALLOW-DIRECTORY-WILDCARD is on
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1655 and we're in a dired buffer, select the current directory.
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1656 If none of these conditions is met, but ALLOW-INELIGIBLE is on and the
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1657 visited file is not registered, return a singleton fileset containing it.
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1658 If INCLUDE-FILES-NOT-DIRECTORIES then if directories are marked,
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1659 return the list of VC files in those directories instead of
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1660 the directories themselves.
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1661 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
1662 (let ((files
94647
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1663 (cond
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1664 ;; Browsing with dired
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1665 (vc-dired-mode
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1666 (let ((marked (dired-map-over-marks (dired-get-filename) nil)))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1667 (if marked
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1668 marked
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1669 (error "No files have been selected."))))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1670 ;; Browsing with vc-dir
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1671 ((eq major-mode 'vc-dir-mode)
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1672 (or
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1673 (if include-files-not-directories
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1674 (vc-dir-marked-only-files)
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1675 (vc-dir-marked-files))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1676 (list (vc-dir-current-file))))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1677 ;; Visiting an eligible file
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1678 ((funcall eligible buffer-file-name)
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1679 (list buffer-file-name))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1680 ;; No eligible file -- if there's a parent buffer, deuce from there
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1681 ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer)
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1682 (with-current-buffer vc-parent-buffer
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1683 (vc-dispatcher-browsing))))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1684 (progn
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1685 (set-buffer vc-parent-buffer)
94692
891cb8f8888f More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94690
diff changeset
1686 (vc-dispatcher-selection-set eligible)))
94647
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1687 ;; No parent buffer, we may want to select entire directory
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1688 ;;
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1689 ;; This is guarded by an enabling arg so users won't potentially
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1690 ;; shoot themselves in the foot by modifying a fileset they can't
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1691 ;; verify by eyeball. Allow it for nondestructive commands like
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1692 ;; making diffs, or possibly for destructive ones that have
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1693 ;; confirmation prompts.
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1694 ((and allow-directory-wildcard
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1695 ;; I think this is a misfeature. For now, I'll leave it in, but
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1696 ;; I'll disable it anywhere else than in dired buffers. --Stef
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1697 (and (derived-mode-p 'dired-mode)
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1698 (equal buffer-file-name nil)
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1699 (equal list-buffers-directory default-directory)))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1700 (progn
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1701 (message "All eligible files below %s selected."
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1702 default-directory)
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1703 (list default-directory)))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1704 ;; Last, if we're allowing ineligible files and visiting one, select it.
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1705 ((and allow-ineligible (not (eligible buffer-file-name)))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1706 (list buffer-file-name))
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1707 ;; No good set here, throw error
94650
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1708 (t (error "No fileset is available here.")))))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1709 ;; We assume, in order to avoid unpleasant surprises to the user,
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1710 ;; that a fileset is not in good shape to be handed to the user if the
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1711 ;; buffers visting the fileset don't match the on-disk contents.
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1712 (dolist (file files)
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1713 (let ((visited (get-file-buffer file)))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1714 (when visited
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1715 (if (or vc-dired-mode (eq major-mode 'vc-dir-mode))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1716 (switch-to-buffer-other-window visited)
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1717 (set-buffer visited))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1718 ;; Check relation of buffer and file, and make sure
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1719 ;; user knows what he's doing. First, finding the file
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1720 ;; will check whether the file on disk is newer.
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1721 ;; Ignore buffer-read-only during this test, and
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1722 ;; preserve find-file-literally.
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1723 (let ((buffer-read-only (not (file-writable-p file))))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1724 (find-file-noselect file nil find-file-literally))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1725 (if (not (verify-visited-file-modtime (current-buffer)))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1726 (if (yes-or-no-p (format "Replace %s on disk with buffer contents? " file))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1727 (write-file buffer-file-name)
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1728 (error "Aborted"))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1729 ;; Now, check if we have unsaved changes.
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1730 (vc-buffer-sync t)
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1731 (when (buffer-modified-p)
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1732 (or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1733 (error "Aborted")))))))
276c5ce56449 Move the fileset staleness check from vc-next-action to
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94647
diff changeset
1734 files))
94647
d0547efd97db More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 94637
diff changeset
1735
94613
5cfb1b43668c Add arch tagline
Miles Bader <miles@gnu.org>
parents: 94611
diff changeset
1736 ;; 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
1737 ;;; vc-dispatcher.el ends here