annotate lisp/vc-dispatcher.el @ 95055:422c9dc4e561

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