Mercurial > emacs
annotate lisp/vc-dispatcher.el @ 96000:f2d08191aec7
(font_check_object): Delete it.
(font_clear_cache): Check if a font-object is alive.
(font_open_entity): Likewise. Set FONT_OBJLST_INDEX of a
font-object to nil.
(font_close_object): Don't check FONT_CLOSE_OBJECT.
(font_at): Don't call font_check_object.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 16 Jun 2008 07:32:04 +0000 |
parents | 174ed97a282b |
children | 47c289fef3ec |
rev | line source |
---|---|
94859 | 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 |
95074 | 39 ;; to version-control systems. |
94571
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 |
95074 | 42 ;; ends from their application-specific logic. It also provides a |
94571
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 |
95074 | 57 ;; directory. The dispatcher's upper layer deduces some subset |
58 ;; of the file tree from the state of the currently visited buffer | |
94571
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 |
95074 | 68 ;; executed when the user types C-c to ship the buffer contents. In |
94571
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 |
95074 | 83 ;; treat all entries with the same state as the currently selected one as |
94637
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 |
95074 | 89 ;; command, synchronously or asynchronously, making the output available |
94652
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 |
95074 | 92 ;; annotation buffer so that when the user confirms the comment the closure |
94652
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 |
95074 | 100 ;; buffer (when that is appropriate). It also does what is needed to ensure |
101 ;; that on-disk files and the contents of their visiting Emacs buffers | |
94692
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, |
95074 | 111 ;; it should work for other async commands done through vc-do-command |
94817
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 | 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 |
95074 | 308 ;; for display in a debug-progress message. If it's fewer than |
94571
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)))) |
95074 | 359 ;; Run synchronously |
94571
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 |
95074 | 374 ;; asynchronously, it would just mislead. |
94571
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 |
95074 | 383 ;; even if the dispatcher client mode has messed with file contents (as in, |
94579
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)))) |
95318
685f73a291fb
(vc-resynch-window): Fix mode-line updating.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95078
diff
changeset
|
495 (run-hook-with-args 'mode-line-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))))) |
95338
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
506 ;; Try to avoid unnecessary work, a *vc-dir* buffer is only present |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
507 ;; if this is true. |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
508 (when (memq 'vc-dir-resynch-file after-save-hook) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
509 (vc-dir-resynch-file file))) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
510 |
94857
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
511 (defun vc-buffer-sync (&optional not-urgent) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
512 "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
|
513 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
|
514 (when (buffer-modified-p) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
515 (if (or vc-suppress-confirm |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
516 (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
|
517 (save-buffer) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
518 (unless not-urgent |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
519 (error "Aborted"))))) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
520 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
521 ;; Command closures |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
522 |
94857
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
523 ;; 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
|
524 |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
525 (defun vc-log-edit (fileset) |
95017
7be06414cb71
Remove assumptions about buffer names.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95016
diff
changeset
|
526 "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
|
527 (setq default-directory |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
528 (with-current-buffer vc-parent-buffer default-directory)) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
529 (log-edit 'vc-finish-logentry |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
530 nil |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
531 `((log-edit-listfun . (lambda () ',fileset)) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
532 (log-edit-diff-function . (lambda () (vc-diff nil))))) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
533 (set (make-local-variable 'vc-log-fileset) fileset) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
534 (make-local-variable 'vc-log-extra) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
535 (set-buffer-modified-p nil) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
536 (setq buffer-file-name nil)) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
537 |
95018
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
538 (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
|
539 "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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 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
|
547 \(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
|
548 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
|
549 (let ((parent |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
550 (if (vc-dispatcher-browsing) |
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
551 ;; 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
|
552 ;; the current buffer. |
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 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
|
555 (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
|
556 (current-buffer))))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
557 (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
|
558 (set-buffer (get-buffer-create logbuf)) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
559 (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
|
560 (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
|
561 (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
|
562 (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
|
563 (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
|
564 (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
|
565 (when after-hook |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
566 (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
|
567 (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
|
568 (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
|
569 (when comment |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
570 (erase-buffer) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
571 (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
|
572 (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
|
573 (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
|
574 (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
|
575 |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
576 (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
|
577 "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
|
578 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
|
579 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
|
580 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
|
581 (interactive) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
582 ;; 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
|
583 (unless nocomment |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
584 (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
|
585 ;; Sync parent buffer in case the user modified it while editing the comment. |
95338
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
586 ;; But not if it is a vc-dir buffer. |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
587 (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
|
588 (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
|
589 (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
|
590 (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
|
591 ;; 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
|
592 (let ((logbuf (current-buffer)) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
593 (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
|
594 (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
|
595 (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
|
596 (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
|
597 (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
|
598 (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
|
599 (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
|
600 ;; 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
|
601 (save-excursion |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
602 (funcall log-operation |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
603 log-fileset |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
604 log-extra |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
605 log-entry)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
606 ;; Remove checkin window (after the checkin so that if that fails |
95019 | 607 ;; 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
|
608 ;; -- 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
|
609 (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
|
610 (delete-windows-on logbuf (selected-frame)) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
611 ;; 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
|
612 (kill-buffer logbuf)) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
613 (logbuf (pop-to-buffer logbuf) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
614 (bury-buffer) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
615 (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
|
616 ;; 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
|
617 (when log-fileset |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
618 (mapc |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
619 (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
|
620 log-fileset)) |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
621 (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
|
622 (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
|
623 (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
|
624 |
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
|
625 ;; 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
|
626 |
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 (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
|
628 "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
|
629 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
|
630 :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
|
631 :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
|
632 |
95015
183ac8cfca91
Fix an incorrect buffer name and remove an unneeded defalias.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94984
diff
changeset
|
633 ;; 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
|
634 ;; 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
|
635 (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
|
636 (: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
|
637 (: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
|
638 (: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
|
639 ;; 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
|
640 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
|
641 (: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
|
642 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
|
643 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
|
644 ;; 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
|
645 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
|
646 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
|
647 ;; 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
|
648 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
|
649 ;; 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
|
650 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
|
651 |
95074 | 652 ;; Used to describe a dispatcher client mode. |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
653 (defstruct (vc-client-object |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
654 (:copier nil) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
655 (:constructor |
95074 | 656 vc-create-client-object (name |
657 headers | |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
658 file-to-info |
95074 | 659 file-to-state |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
660 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
|
661 updater |
ebce6f4852ad
Move vc-dir menu hook back to vc-dispatcher.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95015
diff
changeset
|
662 extra-menu)) |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
663 (:conc-name vc-client-object->)) |
95074 | 664 name |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
665 headers |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
666 file-to-info |
95074 | 667 file-to-state |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
668 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
|
669 updater |
ebce6f4852ad
Move vc-dir menu hook back to vc-dispatcher.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95015
diff
changeset
|
670 extra-menu) |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
671 |
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 (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
|
673 (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
|
674 "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
|
675 |
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 (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
|
677 ;; 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
|
678 (beginning-of-line) |
95672
df59f8d16051
(vc-dir-move-to-goal-column): Don't move in an
Andreas Schwab <schwab@suse.de>
parents:
95511
diff
changeset
|
679 (unless (eolp) |
df59f8d16051
(vc-dir-move-to-goal-column): Don't move in an
Andreas Schwab <schwab@suse.de>
parents:
95511
diff
changeset
|
680 ;; Must be in sync with vc-default-status-printer. |
df59f8d16051
(vc-dir-move-to-goal-column): Don't move in an
Andreas Schwab <schwab@suse.de>
parents:
95511
diff
changeset
|
681 (forward-char 25))) |
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
|
682 |
95017
7be06414cb71
Remove assumptions about buffer names.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95016
diff
changeset
|
683 (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
|
684 "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
|
685 (setq dir (expand-file-name dir)) |
95017
7be06414cb71
Remove assumptions about buffer names.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95016
diff
changeset
|
686 (let* |
7be06414cb71
Remove assumptions about buffer names.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95016
diff
changeset
|
687 ;; 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
|
688 ((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
|
689 (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
|
690 (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
|
691 (set-buffer buffer) |
94800
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
692 (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
|
693 (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
|
694 (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
|
695 (or buf |
95017
7be06414cb71
Remove assumptions about buffer names.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95016
diff
changeset
|
696 ;; 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
|
697 (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
|
698 (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
|
699 (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
|
700 ;; 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
|
701 ;; 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
|
702 (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
|
703 (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
|
704 |
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 (defvar vc-dir-menu-map |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
706 (let ((map (make-sparse-keymap "VC-dir"))) |
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
|
707 (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
|
708 '(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
|
709 :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
|
710 (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
|
711 '(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
|
712 :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
|
713 :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
|
714 (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
|
715 '(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
|
716 :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
|
717 :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
|
718 ;; 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
|
719 (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
|
720 (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
|
721 '(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
|
722 :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
|
723 (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
|
724 '(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
|
725 :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
|
726 ;; 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
|
727 (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
|
728 (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
|
729 '(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
|
730 :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
|
731 \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
|
732 (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
|
733 '(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
|
734 :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
|
735 |
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 [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
|
737 '(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
|
738 :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
|
739 \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
|
740 (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
|
741 '(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
|
742 :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
|
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 [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
|
745 '(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
|
746 :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
|
747 |
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 [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
|
749 (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
|
750 '(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
|
751 :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
|
752 (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
|
753 '(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
|
754 :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
|
755 map) |
94722
3f069e5a5693
Second attempt to move the VC-specific menu initialization.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94712
diff
changeset
|
756 "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
|
757 |
95074 | 758 ;; This is used so that client modes can add mode-specific menu |
95016
ebce6f4852ad
Move vc-dir menu hook back to vc-dispatcher.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95015
diff
changeset
|
759 ;; 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
|
760 (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
|
761 (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
|
762 (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
|
763 (let ((ext-binding |
95511
8d41ea93731c
(vc-dir-menu-map-filter): Don't fail if vc-client-mode is not set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95338
diff
changeset
|
764 ;; This may be executed at load-time for tool-bar-local-item-from-menu |
8d41ea93731c
(vc-dir-menu-map-filter): Don't fail if vc-client-mode is not set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95338
diff
changeset
|
765 ;; but at that time vc-client-mode is not known (or even bound) yet. |
8d41ea93731c
(vc-dir-menu-map-filter): Don't fail if vc-client-mode is not set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95338
diff
changeset
|
766 (when (and (boundp 'vc-client-mode) vc-client-mode) |
8d41ea93731c
(vc-dir-menu-map-filter): Don't fail if vc-client-mode is not set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95338
diff
changeset
|
767 (funcall (vc-client-object->extra-menu vc-client-mode))))) |
95016
ebce6f4852ad
Move vc-dir menu hook back to vc-dispatcher.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95015
diff
changeset
|
768 (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
|
769 orig-binding |
ebce6f4852ad
Move vc-dir menu hook back to vc-dispatcher.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95015
diff
changeset
|
770 (append orig-binding |
ebce6f4852ad
Move vc-dir menu hook back to vc-dispatcher.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95015
diff
changeset
|
771 '("----") |
ebce6f4852ad
Move vc-dir menu hook back to vc-dispatcher.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95015
diff
changeset
|
772 ext-binding)))) |
ebce6f4852ad
Move vc-dir menu hook back to vc-dispatcher.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95015
diff
changeset
|
773 |
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
|
774 (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
|
775 (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
|
776 (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
|
777 ;; 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
|
778 (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
|
779 (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
|
780 (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
|
781 (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
|
782 (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
|
783 (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
|
784 ;; 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
|
785 (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
|
786 (define-key map " " 'vc-dir-next-line) |
95078
603a7e650673
(vc-dir-previous-directory): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95074
diff
changeset
|
787 (define-key map "\t" 'vc-dir-next-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 (define-key map "p" 'vc-dir-previous-line) |
95078
603a7e650673
(vc-dir-previous-directory): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95074
diff
changeset
|
789 (define-key map [backtab] 'vc-dir-previous-directory) |
94845
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
790 ;;; 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
|
791 (define-key map "\M-}" 'vc-dir-next-directory) |
95078
603a7e650673
(vc-dir-previous-directory): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95074
diff
changeset
|
792 (define-key map "\M-{" 'vc-dir-previous-directory) |
603a7e650673
(vc-dir-previous-directory): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95074
diff
changeset
|
793 (define-key map [C-down] 'vc-dir-next-directory) |
603a7e650673
(vc-dir-previous-directory): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95074
diff
changeset
|
794 (define-key map [C-up] 'vc-dir-previous-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
|
795 ;; 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
|
796 (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
|
797 (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
|
798 (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
|
799 (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
|
800 (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
|
801 (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) |
95078
603a7e650673
(vc-dir-previous-directory): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95074
diff
changeset
|
802 (define-key map [down-mouse-3] 'vc-dir-menu) |
603a7e650673
(vc-dir-previous-directory): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95074
diff
changeset
|
803 (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
|
804 |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
805 ;; Hook up the menu. |
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
806 (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
|
807 `(menu-item |
94698
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
808 ;; 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
|
809 ;; menu items to vc-dir-menu-map. |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
810 "VC-dir" ,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
|
811 map) |
95015
183ac8cfca91
Fix an incorrect buffer name and remove an unneeded defalias.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94984
diff
changeset
|
812 "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
|
813 |
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 (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
|
815 "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
|
816 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
|
817 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
|
818 (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
|
819 `(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
|
820 (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
|
821 (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
|
822 (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
|
823 ,@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
|
824 |
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 (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
|
826 "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
|
827 (interactive "e") |
94698
8983ac9b89b4
Back out menu move, it broke something obscure.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94695
diff
changeset
|
828 (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
|
829 |
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 (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
|
831 (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
|
832 (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
|
833 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
|
834 (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
|
835 '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
|
836 :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
|
837 (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
|
838 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
|
839 :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
|
840 (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
|
841 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
|
842 :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
|
843 (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
|
844 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
|
845 (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
|
846 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
|
847 (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
|
848 "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
|
849 (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
|
850 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
|
851 (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
|
852 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
|
853 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
|
854 |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
855 (defun vc-dir-node-directory (node) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
856 ;; Compute the directory for NODE. |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
857 ;; If it's a directory node, get it from the the node. |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
858 (let ((data (ewoc-data node))) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
859 (or (vc-dir-fileinfo->directory data) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
860 ;; Otherwise compute it from the file name. |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
861 (file-name-directory |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
862 (expand-file-name |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
863 (vc-dir-fileinfo->name data)))))) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
864 |
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
|
865 (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
|
866 "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
|
867 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
|
868 ;; 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
|
869 (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
|
870 ;; 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
|
871 ;; 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
|
872 ;; 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
|
873 (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
|
874 ;; 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
|
875 ;; 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
|
876 ;; 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
|
877 (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
|
878 (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
|
879 (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
|
880 (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
|
881 (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
|
882 ((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
|
883 ((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
|
884 ((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
|
885 ;; 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
|
886 (let ((entry (car entries)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
887 (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
|
888 ;; 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
|
889 (unless node |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
890 (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
|
891 (ewoc-enter-last |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
892 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
|
893 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
|
894 (setq node (ewoc-nth vc-ewoc 0))) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
895 |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
896 (while (and entry node) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
897 (let* ((entryfile (car entry)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
898 (entrydir (file-name-directory (expand-file-name entryfile))) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
899 (nodedir (vc-dir-node-directory node))) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
900 (cond |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
901 ;; 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
|
902 ((string-lessp nodedir entrydir) |
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 ((string-equal nodedir entrydir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
905 ;; 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
|
906 (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
|
907 (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
|
908 ((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
|
909 (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
|
910 ((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
|
911 (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
|
912 (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
|
913 (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
|
914 (ewoc-invalidate vc-ewoc node) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
915 (setq entries (cdr entries)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
916 (setq entry (car entries)) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
917 (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
|
918 (t |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
919 (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
|
920 (apply 'vc-dir-create-fileinfo entry)) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
921 (setq entries (cdr entries)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
922 (setq entry (car entries)))))) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
923 (t |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
924 ;; We might need to insert a directory node if the |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
925 ;; previous node was in a different directory. |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
926 (let* ((rd (file-relative-name entrydir)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
927 (prev-node (ewoc-prev vc-ewoc node)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
928 (prev-dir (vc-dir-node-directory prev-node))) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
929 (unless (string-equal entrydir prev-dir) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
930 (ewoc-enter-before |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
931 vc-ewoc node (vc-dir-create-fileinfo rd nil nil nil entrydir)))) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
932 ;; Now insert the node itself. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
933 (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
|
934 (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
|
935 (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
|
936 ;; 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
|
937 (unless (or node noinsert) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
938 (let ((lastdir (vc-dir-node-directory (ewoc-nth vc-ewoc -1)))) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
939 (dolist (entry entries) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
940 (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
|
941 ;; 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
|
942 (unless (string-equal lastdir entrydir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
943 (setq lastdir entrydir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
944 (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
|
945 (ewoc-enter-last |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
946 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
|
947 ;; 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
|
948 (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
|
949 (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
|
950 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
951 (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
|
952 (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
|
953 (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
|
954 |
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 (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
|
956 "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
|
957 (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
|
958 (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
|
959 (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
|
960 (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
|
961 (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
|
962 (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
|
963 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
964 (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
|
965 ;; 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
|
966 ;; 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
|
967 (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
|
968 (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
|
969 (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
|
970 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
|
971 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
|
972 |
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 (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
|
974 "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
|
975 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
|
976 (interactive "p") |
94817
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
977 (with-no-warnings |
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
978 (ewoc-goto-next vc-ewoc arg) |
0977154ddbe5
Suppress an annoying warning.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94811
diff
changeset
|
979 (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
|
980 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
981 (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
|
982 "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
|
983 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
|
984 (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
|
985 (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
|
986 (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
|
987 |
94845
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
988 (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
|
989 "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
|
990 (interactive) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
991 (let ((orig (point))) |
95074 | 992 (if |
94845
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
993 (catch 'foundit |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
994 (while t |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
995 (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
|
996 (cond ((not next) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
997 (throw 'foundit t)) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
998 (t |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
999 (progn |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1000 (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
|
1001 (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
|
1002 (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
|
1003 (throw 'foundit nil)))))))) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1004 (goto-char orig)))) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1005 |
95078
603a7e650673
(vc-dir-previous-directory): Rename from
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95074
diff
changeset
|
1006 (defun vc-dir-previous-directory () |
94845
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1007 "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
|
1008 (interactive) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1009 (let ((orig (point))) |
95074 | 1010 (if |
94845
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1011 (catch 'foundit |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1012 (while t |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1013 (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
|
1014 (cond ((not prev) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1015 (throw 'foundit t)) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1016 (t |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1017 (progn |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1018 (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
|
1019 (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
|
1020 (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
|
1021 (throw 'foundit nil)))))))) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1022 (goto-char orig)))) |
1aa1de92b8a1
New functions implementing motion to next and previous directory.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94820
diff
changeset
|
1023 |
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
|
1024 (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
|
1025 (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
|
1026 (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
|
1027 (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
|
1028 (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
|
1029 (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
|
1030 (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
|
1031 (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
|
1032 (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
|
1033 |
95329
3bf215f97a31
(vc-string-prefix-p): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95320
diff
changeset
|
1034 (defun vc-string-prefix-p (prefix string) |
95338
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1035 (let ((lpref (length prefix))) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1036 (and (>= (length string) lpref) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1037 (eq t (compare-strings prefix nil nil string nil lpref))))) |
95329
3bf215f97a31
(vc-string-prefix-p): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95320
diff
changeset
|
1038 |
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
|
1039 (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
|
1040 ;; Return nil if none of the parent directories of arg is marked. |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1041 (let* ((argdir (vc-dir-node-directory arg)) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1042 (arglen (length argdir)) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1043 (crt arg) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1044 data dir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1045 ;; 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
|
1046 ;; a parent is marked. |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1047 (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
|
1048 (setq data (ewoc-data crt)) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1049 (setq dir (vc-dir-node-directory crt)) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1050 (when (and (vc-dir-fileinfo->directory data) |
95329
3bf215f97a31
(vc-string-prefix-p): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95320
diff
changeset
|
1051 (vc-string-prefix-p dir argdir)) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1052 (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
|
1053 (error "Cannot mark `%s', parent directory `%s' marked" |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1054 (vc-dir-fileinfo->name (ewoc-data arg)) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1055 (vc-dir-fileinfo->name data))))) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1056 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
|
1057 |
f6d320d12050
Moved most of vc-dir from vc.el to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94582
diff
changeset
|
1058 (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
|
1059 ;; Return nil if none of the children of arg is marked. |
95674
0c2f83acfffe
(vc-dir-children-marked-p): Fix child check.
Andreas Schwab <schwab@suse.de>
parents:
95672
diff
changeset
|
1060 (let* ((argdir-re (concat "\\`" (regexp-quote (vc-dir-node-directory arg)))) |
94810
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1061 (is-child t) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1062 (crt arg) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1063 data dir) |
3e09ff6082e0
Remove the vc-dir-insert-directories global.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94802
diff
changeset
|
1064 (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
|
1065 (setq data (ewoc-data crt)) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1066 (setq dir (vc-dir-node-directory crt)) |
95674
0c2f83acfffe
(vc-dir-children-marked-p): Fix child check.
Andreas Schwab <schwab@suse.de>
parents:
95672
diff
changeset
|
1067 (if (string-match argdir-re dir) |
94810
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" |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1070 (vc-dir-fileinfo->name (ewoc-data arg)) |
94810
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) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1113 (vc-dir-fileinfo->marked filearg)) |
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
|
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 () |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
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) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1254 ;; FIXME: use vc-dir-child-files here instead of duplicating it. |
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
|
1255 (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
|
1256 (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
|
1257 (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
|
1258 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
|
1259 (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
|
1260 (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
|
1261 (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
|
1262 (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
|
1263 (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
|
1264 (setq data (ewoc-data crt)) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1265 (vc-dir-node-directory crt)) |
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
|
1266 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
|
1267 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
|
1268 (unless (vc-dir-fileinfo->directory data) |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1269 (push (expand-file-name (vc-dir-fileinfo->name data)) result)))) |
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
|
1270 (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
|
1271 (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
|
1272 (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
|
1273 result)) |
95074 | 1274 |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1275 (defun vc-dir-child-files () |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1276 "Return the list of child files for the current entry if it's a directory. |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1277 If it is a file, return the file itself." |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1278 (let* ((crt (ewoc-locate vc-ewoc)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1279 (crt-data (ewoc-data crt)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1280 result) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1281 (if (vc-dir-fileinfo->directory crt-data) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1282 (let* ((dir (vc-dir-fileinfo->directory crt-data)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1283 (dirlen (length dir)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1284 data) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1285 (while |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1286 (and (setq crt (ewoc-next vc-ewoc crt)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1287 (string-equal |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1288 (substring |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1289 (progn |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1290 (setq data (ewoc-data crt)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1291 (vc-dir-node-directory crt)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1292 0 dirlen) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1293 dir)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1294 (unless (vc-dir-fileinfo->directory data) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1295 (push (expand-file-name (vc-dir-fileinfo->name data)) result)))) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1296 (push (expand-file-name (vc-dir-fileinfo->name crt-data)) result)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1297 result)) |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1298 |
95338
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1299 (defun vc-dir-resynch-file (&optional fname) |
94700
d45699617202
Merege two functions in preparation for removing dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94699
diff
changeset
|
1300 "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
|
1301 (let ((file (or fname (expand-file-name buffer-file-name)))) |
95338
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1302 (if (file-directory-p file) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1303 ;; FIXME: Maybe this should never happen? |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1304 ;; FIXME: But it is useful to update the state of a directory |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1305 ;; (more precisely the files in the directory) after some VC |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1306 ;; operations. |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1307 nil |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1308 (let ((found-vc-dir-buf nil)) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1309 (save-excursion |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1310 (dolist (status-buf (buffer-list)) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1311 (set-buffer status-buf) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1312 ;; look for a vc-dir buffer that might show this file. |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1313 (when (derived-mode-p 'vc-dir-mode) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1314 (setq found-vc-dir-buf t) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1315 (let ((ddir (expand-file-name default-directory))) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1316 (when (vc-string-prefix-p ddir file) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1317 (let* |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1318 ((file-short (substring file (length ddir))) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1319 (state |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1320 (funcall (vc-client-object->file-to-state vc-client-mode) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1321 file)) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1322 (extra |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1323 (funcall (vc-client-object->file-to-extra vc-client-mode) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1324 file)) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1325 (entry |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1326 (list file-short state extra))) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1327 (vc-dir-update (list entry) status-buf)))))) |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1328 ;; We didn't find any vc-dir buffers, remove the hook, it is |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1329 ;; not needed. |
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1330 (unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-dir-resynch-file))))))) |
94611
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1331 |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1332 (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
|
1333 "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
|
1334 Marking/Unmarking key bindings and actions: |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1335 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
|
1336 in region. |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1337 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
|
1338 - 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
|
1339 directory is marked |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1340 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
|
1341 in region. |
95017
7be06414cb71
Remove assumptions about buffer names.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95016
diff
changeset
|
1342 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
|
1343 the current file |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1344 - 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
|
1345 - 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
|
1346 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
|
1347 as the current file |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1348 - 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
|
1349 - 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
|
1350 |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1351 |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1352 \\{vc-dir-mode-map}" |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1353 (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
|
1354 (setq major-mode 'vc-dir-mode) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1355 (setq buffer-read-only t) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1356 (use-local-map vc-dir-mode-map) |
95834
174ed97a282b
(vc-dir-mode): Check tool-bar-mode is bound.
Glenn Morris <rgm@gnu.org>
parents:
95674
diff
changeset
|
1357 (if (boundp 'tool-bar-map) |
174ed97a282b
(vc-dir-mode): Check tool-bar-mode is bound.
Glenn Morris <rgm@gnu.org>
parents:
95674
diff
changeset
|
1358 (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
|
1359 (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
|
1360 (let ((buffer-read-only nil)) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1361 (erase-buffer) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1362 (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
|
1363 (set (make-local-variable 'vc-ewoc) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1364 (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
|
1365 (vc-client-object->headers client-object))) |
95338
b4a9f05bf87b
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95329
diff
changeset
|
1366 (add-hook 'after-save-hook 'vc-dir-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
|
1367 ;; 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
|
1368 ;; 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
|
1369 (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
|
1370 (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
|
1371 (run-hooks 'vc-dir-mode-hook)) |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1372 |
78377ffa1363
Bug fix for vc-dispatcher split.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94585
diff
changeset
|
1373 (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
|
1374 |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
1375 (defun vc-dispatcher-browsing () |
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
1376 "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
|
1377 (derived-mode-p 'vc-dir-mode)) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1378 |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1379 (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
|
1380 (let ((member nil)) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1381 (while (and (not member) fileset) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1382 (let ((elem (pop fileset))) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1383 (if (if (file-directory-p elem) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1384 (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
|
1385 elem nil nil)) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
1386 (eq (current-buffer) (get-file-buffer elem))) |
94801
4a0c0906cc91
(vc-dispatcher-selection-set): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94800
diff
changeset
|
1387 (setq member t)))) |
4a0c0906cc91
(vc-dispatcher-selection-set): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94800
diff
changeset
|
1388 member)) |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
1389 |
94820
5b364ab2654b
Dupport an use an observer flag in (vc-dispatcher-selection-set).
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94819
diff
changeset
|
1390 (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
|
1391 "Deduce a set of files to which to apply an operation. Return a cons |
95074 | 1392 cell (SELECTION . FILESET), where SELECTION is what the user chose |
94984
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1393 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
|
1394 within them. |
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1395 |
94778
b9687393def1
Large simplification in (vc-deduce-fileset) logic.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94729
diff
changeset
|
1396 If we're in a directory display, the fileset is the list of marked files (if |
95074 | 1397 there is one) else the file on the current line. If not in a directory |
94802
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1398 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
|
1399 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
|
1400 (let ((selection |
94802
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1401 (cond |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1402 ;; Browsing with vc-dir |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1403 ((vc-dispatcher-browsing) |
95074 | 1404 ;; If no files are marked, temporarily mark current file |
94984
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1405 ;; 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
|
1406 (if (not (vc-dir-marked-files)) |
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1407 (prog2 |
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1408 (vc-dir-mark-file) |
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1409 (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
|
1410 (vc-dir-unmark-all-files t)) |
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1411 (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
|
1412 ;; Visiting an eligible file |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1413 ((buffer-file-name) |
94984
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1414 (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
|
1415 ;; 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
|
1416 ((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
|
1417 (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
|
1418 (vc-dispatcher-browsing)))) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1419 (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
|
1420 (vc-dispatcher-selection-set))) |
b6ba0c08fee1
(vc-dispatcher-selection-set): More typos, plus indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94801
diff
changeset
|
1421 ;; 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
|
1422 (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
|
1423 ;; 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
|
1424 ;; 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
|
1425 ;; buffers visiting the fileset don't match the on-disk contents. |
95320
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1426 (unless observer |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1427 (save-some-buffers |
51b445e6b312
(vc-dir-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95318
diff
changeset
|
1428 nil (lambda () (vc-dispatcher-in-fileset-p (cdr selection))))) |
94984
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
1429 selection)) |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
1430 |
94854
4c35f4ccba9e
(vc-hooks, ewoc): Require.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
1431 (provide 'vc-dispatcher) |
4c35f4ccba9e
(vc-hooks, ewoc): Require.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
1432 |
94613 | 1433 ;; 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
|
1434 ;;; vc-dispatcher.el ends here |