Mercurial > emacs
annotate lisp/vc/vc-dispatcher.el @ 111012:2b6e7f137773
Fix the MSDOS build broken by last revisions.
msdos/sed1v2.inp: Use $(..) instead of ${..} in all edit commands.
Needed because of changes in revno 101897.
msdos/sed6.inp (mkinfodir): Edit to avoid Unix shell-isms. Needed
because of changes in revno 101876.
src/unexcoff.c (make_hdr): Fix prototype according to changes in
revno 101757.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 15 Oct 2010 20:45:12 +0200 |
parents | 280c8ae2476d |
children | 1b626601d32d 417b1e4d63cd |
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 |
106815 | 3 ;; Copyright (C) 2008, 2009, 2010 |
94571
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> |
108971
d928a6a7c3f2
* lisp/finder.el (finder-known-keywords): Add keyword "vc"
Juri Linkov <juri@jurta.org>
parents:
108970
diff
changeset
|
8 ;; Keywords: vc tools |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
108971
diff
changeset
|
9 ;; Package: vc |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
10 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
11 ;; This file is part of GNU Emacs. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
12 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94652
diff
changeset
|
13 ;; 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
|
14 ;; 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
|
15 ;; 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
|
16 ;; (at your option) any later version. |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
17 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
18 ;; 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
|
19 ;; 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
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
21 ;; GNU General Public License for more details. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
22 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
23 ;; 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
|
24 ;; 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
|
25 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
26 ;;; Credits: |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
27 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
28 ;; 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
|
29 ;; 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
|
30 ;; vc-dir front end. |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
31 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
32 ;;; Commentary: |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
33 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
34 ;; Goals: |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
35 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
36 ;; 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
|
37 ;; 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
|
38 ;; 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
|
39 ;; prototypical example, from which this code is derived, is talking |
95074 | 40 ;; to version-control systems. |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
41 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
42 ;; vc-dispatcher.el is written to decouple the UI issues in such front |
95074 | 43 ;; 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
|
44 ;; service layer for running the slave commands either synchronously |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
45 ;; 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
|
46 ;; command runs. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
47 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
48 ;; 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
|
49 ;; 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
|
50 ;; 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
|
51 ;; 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
|
52 ;; 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
|
53 ;; a valuable thing. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
54 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
55 ;; Dispatcher's universe: |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
56 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
57 ;; The universe consists of the file tree rooted at the current |
95074 | 58 ;; directory. The dispatcher's upper layer deduces some subset |
59 ;; 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
|
60 ;; and returns that subset, presumably to a client mode. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
61 ;; |
94811
47dff47e1b61
Comment and to-do list fixes.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94810
diff
changeset
|
62 ;; 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
|
63 ;; 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
|
64 ;; |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
65 ;; 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
|
66 ;; synchronously or asynchronously. Commands may be launched in one |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
67 ;; 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
|
68 ;; create a closure associated with a text-entry buffer, to be |
95074 | 69 ;; 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
|
70 ;; 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
|
71 ;; available in a status buffer. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
72 |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
73 ;; Special behavior of dispatcher directory buffers: |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
74 ;; |
94637
cb8291c75f39
Avoid passing default nil argument.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94625
diff
changeset
|
75 ;; 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
|
76 ;; 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
|
77 ;; 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
|
78 ;; 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
|
79 ;; 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
|
80 ;; |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
81 ;; 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
|
82 ;; 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
|
83 ;; about the semantics of individual states, but mark and unmark commands |
95074 | 84 ;; 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
|
85 ;; a unit. |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
86 |
94857
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
87 ;; The interface: |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
88 ;; |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
89 ;; The main interface to the lower level is vc-do-command. This launches a |
95074 | 90 ;; command, synchronously or asynchronously, making the output available |
105130
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
91 ;; in a command log buffer. Two other functions, (vc-start-logentry) and |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
92 ;; (vc-finish-logentry), allow you to associate a command closure with an |
95074 | 93 ;; 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
|
94 ;; 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
|
95 ;; |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
96 ;; 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
|
97 ;; 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
|
98 ;; (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
|
99 ;; 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
|
100 ;; buffer or the singleton set consisting of the file visited by the current |
95074 | 101 ;; buffer (when that is appropriate). It also does what is needed to ensure |
102 ;; 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
|
103 ;; coincide. |
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
104 ;; |
108943
04a1a4b18129
* lisp/vc-dispatcher.el: Rename mode-line-hook to vc-mode-line-hook;
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106871
diff
changeset
|
105 ;; When the client mode adds a local vc-mode-line-hook to a buffer, it |
94692
891cb8f8888f
More decoupling of vc-dispatcher.el from vc.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94690
diff
changeset
|
106 ;; 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
|
107 ;; dispatcher resynchs the buffer. |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
108 |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
109 ;; To do: |
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
110 ;; |
95015
183ac8cfca91
Fix an incorrect buffer name and remove an unneeded defalias.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94984
diff
changeset
|
111 ;; - log buffers need font-locking. |
94585
16008b90ad8c
Reorganze VC todo list.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94584
diff
changeset
|
112 ;; |
95055
422c9dc4e561
(top-level): Revert previous change: require cl when compiling.
John Paul Wallington <jpw@pobox.com>
parents:
95052
diff
changeset
|
113 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
114 ;; General customization |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
115 (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
|
116 "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
|
117 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
|
118 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
|
119 :type 'hook |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
120 :group 'vc) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
121 |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
122 (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
|
123 "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
|
124 If nil, bury that buffer instead. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
125 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
|
126 preserve the setting." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
127 :type 'boolean |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
128 :group 'vc) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
129 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
130 (defcustom vc-command-messages nil |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
131 "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
|
132 :type 'boolean |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
133 :group 'vc) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
134 |
94652
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
135 (defcustom vc-suppress-confirm nil |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
136 "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
|
137 :type 'boolean |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
138 :group 'vc) |
3a091c58b092
Move a customization variable.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94650
diff
changeset
|
139 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
140 ;; 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
|
141 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
142 (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
|
143 (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
|
144 (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
|
145 |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
146 ;; 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
|
147 ;; 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
|
148 ;; (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
|
149 (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
|
150 (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
|
151 (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
|
152 (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
|
153 |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
154 ;; Common command execution logic |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
155 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
156 (defun vc-process-filter (p s) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
157 "An alternative output filter for async process P. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
158 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
|
159 Another is that undo information is not kept." |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
160 (let ((buffer (process-buffer p))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
161 (when (buffer-live-p buffer) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
162 (with-current-buffer buffer |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
163 (save-excursion |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
164 (let ((buffer-undo-list t) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
165 (inhibit-read-only t)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
166 (goto-char (process-mark p)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
167 (insert s) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
168 (set-marker (process-mark p) (point)))))))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
169 |
94572
3bdffe280ad3
Remove logentry primitive from backend API.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94571
diff
changeset
|
170 (defun vc-setup-buffer (buf) |
3bdffe280ad3
Remove logentry primitive from backend API.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94571
diff
changeset
|
171 "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
|
172 (let ((camefrom (current-buffer)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
173 (olddir default-directory)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
174 (set-buffer (get-buffer-create buf)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
175 (kill-all-local-variables) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
176 (set (make-local-variable 'vc-parent-buffer) camefrom) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
177 (set (make-local-variable 'vc-parent-buffer-name) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
178 (concat " from " (buffer-name camefrom))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
179 (setq default-directory olddir) |
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 (erase-buffer)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
183 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
184 (defvar vc-sentinel-movepoint) ;Dynamically scoped. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
185 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
186 (defun vc-process-sentinel (p s) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
187 (let ((previous (process-get p 'vc-previous-sentinel)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
188 (buf (process-buffer p))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
189 ;; Impatient users sometime kill "slow" buffers; check liveness |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
190 ;; to avoid "error in process sentinel: Selecting deleted buffer". |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
191 (when (buffer-live-p buf) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
192 (when previous (funcall previous p s)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
193 (with-current-buffer buf |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
194 (setq mode-line-process |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
195 (let ((status (process-status p))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
196 ;; Leave mode-line uncluttered, normally. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
197 (unless (eq 'exit status) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
198 (format " (%s)" status)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
199 (let (vc-sentinel-movepoint) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
200 ;; 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
|
201 (save-excursion |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
202 (goto-char (process-mark p)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
203 (let ((cmds (process-get p 'vc-sentinel-commands))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
204 (process-put p 'vc-sentinel-commands nil) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
205 (dolist (cmd cmds) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
206 ;; 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
|
207 ;; 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
|
208 ;; 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
|
209 ;; 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
|
210 ;; difficult to achieve. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
211 (vc-exec-after cmd)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
212 ;; But sometimes the sentinels really want to move point. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
213 (when vc-sentinel-movepoint |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
214 (let ((win (get-buffer-window (current-buffer) 0))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
215 (if (not win) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
216 (goto-char vc-sentinel-movepoint) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
217 (with-selected-window win |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
218 (goto-char vc-sentinel-movepoint)))))))))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
219 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
220 (defun vc-set-mode-line-busy-indicator () |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
221 (setq mode-line-process |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
222 (concat " " (propertize "[waiting...]" |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
223 'face 'mode-line-emphasis |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
224 'help-echo |
95017
7be06414cb71
Remove assumptions about buffer names.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95016
diff
changeset
|
225 "A command is in progress in this buffer")))) |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
226 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
227 (defun vc-exec-after (code) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
228 "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
|
229 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
|
230 Else, add CODE to the process' sentinel." |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
231 (let ((proc (get-buffer-process (current-buffer)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
232 (cond |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
233 ;; 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
|
234 ;; 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
|
235 ;; 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
|
236 ;; lost. Terminated processes get deleted automatically |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
237 ;; anyway. -- cyd |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
238 ((or (null proc) (eq (process-status proc) 'exit)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
239 ;; 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
|
240 (when proc (accept-process-output proc)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
241 (eval code)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
242 ;; 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
|
243 ((eq (process-status proc) 'run) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
244 (vc-set-mode-line-busy-indicator) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
245 (let ((previous (process-sentinel proc))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
246 (unless (eq previous 'vc-process-sentinel) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
247 (process-put proc 'vc-previous-sentinel previous)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
248 (set-process-sentinel proc 'vc-process-sentinel)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
249 (process-put proc 'vc-sentinel-commands |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
250 ;; We keep the code fragments in the order given |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
251 ;; 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
|
252 ;; the presence of non-nil vc-command-messages. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
253 (append (process-get proc 'vc-sentinel-commands) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
254 (list code)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
255 (t (error "Unexpected process state")))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
256 nil) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
257 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
258 (defvar vc-post-command-functions nil |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
259 "Hook run at the end of `vc-do-command'. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
260 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
|
261 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
|
262 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
263 (defvar w32-quote-process-args) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
264 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
265 (defun vc-delistify (filelist) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
266 "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
|
267 ;; FIXME what about file names with spaces? |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
268 (if (not filelist) "." (mapconcat 'identity filelist " "))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
269 |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
270 ;;;###autoload |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
271 (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
|
272 "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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 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
|
278 `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
|
279 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
|
280 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
|
281 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
|
282 name or set of files). If an optional list of FLAGS is present, |
105130
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
283 that is inserted into the command line before the filename. |
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
284 Return the return value of the slave command in the synchronous |
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
285 case, and the process object in the asynchronous case." |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
286 ;; 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
|
287 ;; 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
|
288 ;; come into play. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
289 (let* ((files |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
290 (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
|
291 (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
|
292 (full-command |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
293 ;; What we're doing here is preparing a version of the command |
95074 | 294 ;; 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
|
295 ;; 20 characters display the entire command (without trailing |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
296 ;; 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
|
297 (concat (if (string= (substring command -1) "\n") |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
298 (substring command 0 -1) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
299 command) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
300 " " |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
301 (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
|
302 " " (vc-delistify files)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
303 (save-current-buffer |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
304 (unless (or (eq buffer t) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
305 (and (stringp buffer) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
306 (string= (buffer-name) buffer)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
307 (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
|
308 (vc-setup-buffer buffer)) |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
309 ;; 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
|
310 (let ((oldproc (get-buffer-process (current-buffer)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
311 ;; 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
|
312 ;; something, we'd have used vc-eval-after. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
313 ;; 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
|
314 ;; want any of its output to appear from now on. |
105130
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
315 (when oldproc (delete-process oldproc))) |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
316 (let ((squeezed (remq nil flags)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
317 (inhibit-read-only t) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
318 (status 0)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
319 (when files |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
320 (setq squeezed (nconc squeezed files))) |
107434
11244653958e
lisp/vc-dispatcher.el (vc-do-command): Remove reference to `vc-path'.
Juanma Barranquero <lekktu@gmail.com>
parents:
107430
diff
changeset
|
321 (let (;; Since some functions need to parse the output |
106871
6427b60ed4f2
* vc-dispatcher.el (vc-do-command): Set LC_MESSAGES, so that we
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
322 ;; from external commands, set LC_MESSAGES to C. |
107434
11244653958e
lisp/vc-dispatcher.el (vc-do-command): Remove reference to `vc-path'.
Juanma Barranquero <lekktu@gmail.com>
parents:
107430
diff
changeset
|
323 (process-environment (cons "LC_MESSAGES=C" process-environment)) |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
324 (w32-quote-process-args t)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
325 (if (eq okstatus 'async) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
326 ;; Run asynchronously. |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
327 (let ((proc |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
328 (let ((process-connection-type nil)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
329 (apply 'start-file-process command (current-buffer) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
330 command squeezed)))) |
105130
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
331 (when vc-command-messages |
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
332 (message "Running %s in background..." full-command)) |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
333 ;;(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
|
334 (set-process-filter proc 'vc-process-filter) |
105130
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
335 (setq status proc) |
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
336 (when vc-command-messages |
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
337 (vc-exec-after |
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
338 `(message "Running %s in background... done" ',full-command)))) |
95074 | 339 ;; Run synchronously |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
340 (when vc-command-messages |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
341 (message "Running %s in foreground..." full-command)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
342 (let ((buffer-undo-list t)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
343 (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
|
344 (when (and (not (eq t okstatus)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
345 (or (not (integerp status)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
346 (and okstatus (< okstatus status)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
347 (unless (eq ?\s (aref (buffer-name (current-buffer)) 0)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
348 (pop-to-buffer (current-buffer)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
349 (goto-char (point-min)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
350 (shrink-window-if-larger-than-buffer)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
351 (error "Running %s...FAILED (%s)" full-command |
105130
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
352 (if (integerp status) (format "status %d" status) status))) |
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
353 (when vc-command-messages |
115d5f887b34
(vc-do-command): Return the process object in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104169
diff
changeset
|
354 (message "Running %s...OK = %d" full-command status)))) |
94571
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
355 (vc-exec-after |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
356 `(run-hook-with-args 'vc-post-command-functions |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
357 ',command ',file-or-list ',flags)) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
358 status)))) |
61cca370b8f5
vc-dispatcher layer separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff
changeset
|
359 |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
360 ;; These functions are used to ensure that the view the user sees is up to date |
95074 | 361 ;; 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
|
362 ;; for example, VCS keyword expansion). |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
363 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
364 (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
|
365 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
366 (defun vc-position-context (posn) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
367 "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
|
368 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
|
369 if markers are destroyed or corrupted." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
370 ;; 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
|
371 ;; rcs.el mode. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
372 (list posn |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
373 (buffer-size) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
374 (buffer-substring posn |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
375 (min (point-max) (+ posn 100))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
376 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
377 (defun vc-find-position-by-context (context) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
378 "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
|
379 If CONTEXT cannot be found, return nil." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
380 (let ((context-string (nth 2 context))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
381 (if (equal "" context-string) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
382 (point-max) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
383 (save-excursion |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
384 (let ((diff (- (nth 1 context) (buffer-size)))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
385 (when (< diff 0) (setq diff (- diff))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
386 (goto-char (nth 0 context)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
387 (if (or (search-forward context-string nil t) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
388 ;; 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
|
389 ;; after point. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
390 (progn (goto-char (- (point) diff (length context-string))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
391 ;; goto-char doesn't signal an error at |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
392 ;; beginning of buffer like backward-char would |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
393 (search-forward context-string nil t))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
394 ;; to beginning of OSTRING |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
395 (- (point) (length context-string)))))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
396 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
397 (defun vc-context-matches-p (posn context) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
398 "Return t if POSN matches CONTEXT, nil otherwise." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
399 (let* ((context-string (nth 2 context)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
400 (len (length context-string)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
401 (end (+ posn len))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
402 (if (> end (1+ (buffer-size))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
403 nil |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
404 (string= context-string (buffer-substring posn end))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
405 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
406 (defun vc-buffer-context () |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
407 "Return a list (POINT-CONTEXT MARK-CONTEXT REPARSE). |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
408 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
|
409 (let ((point-context (vc-position-context (point))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
410 ;; 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
|
411 (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
|
412 (vc-position-context (mark-marker)))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
413 ;; 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
|
414 (mark-active nil)) |
b4258832258e
Remove dead code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94722
diff
changeset
|
415 (list point-context mark-context nil))) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
416 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
417 (defun vc-restore-buffer-context (context) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
418 "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
|
419 CONTEXT is that which `vc-buffer-context' returns." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
420 (let ((point-context (nth 0 context)) |
94728
b4258832258e
Remove dead code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94722
diff
changeset
|
421 (mark-context (nth 1 context))) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
422 ;; if necessary, restore point and mark |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
423 (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
|
424 (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
|
425 (when new-point (goto-char new-point)))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
426 (and mark-active |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
427 mark-context |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
428 (not (vc-context-matches-p (mark) mark-context)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
429 (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
|
430 (when new-mark (set-mark new-mark)))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
431 |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
432 (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
|
433 "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
|
434 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
|
435 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
|
436 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
|
437 (interactive "P") |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
438 (widen) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
439 (let ((context (vc-buffer-context))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
440 ;; 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
|
441 ;; 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
|
442 ;; 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
|
443 ;; 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
|
444 (save-excursion |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
445 ;; t means don't call normal-mode; |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
446 ;; that's to preserve various minor modes. |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
447 (revert-buffer arg no-confirm t)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
448 (vc-restore-buffer-context context))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
449 |
108943
04a1a4b18129
* lisp/vc-dispatcher.el: Rename mode-line-hook to vc-mode-line-hook;
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106871
diff
changeset
|
450 (defvar vc-mode-line-hook nil) |
04a1a4b18129
* lisp/vc-dispatcher.el: Rename mode-line-hook to vc-mode-line-hook;
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106871
diff
changeset
|
451 (make-variable-buffer-local 'vc-mode-line-hook) |
04a1a4b18129
* lisp/vc-dispatcher.el: Rename mode-line-hook to vc-mode-line-hook;
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106871
diff
changeset
|
452 (put 'vc-mode-line-hook 'permanent-local t) |
04a1a4b18129
* lisp/vc-dispatcher.el: Rename mode-line-hook to vc-mode-line-hook;
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106871
diff
changeset
|
453 |
108914
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
454 (defun vc-resynch-window (file &optional keep noquery reset-vc-info) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
455 "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
|
456 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
|
457 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
|
458 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
|
459 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
|
460 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
|
461 editing!" |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
462 (and (string= buffer-file-name file) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
463 (if keep |
105329
fa9bcb68092e
(vc-resynch-window): Don't revert a buffer which has no associated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105130
diff
changeset
|
464 (when (file-exists-p file) |
108914
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
465 (when reset-vc-info |
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
466 (vc-file-clearprops file)) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
467 (vc-revert-buffer-internal t noquery) |
104169
dc97cf5c3f82
(vc-resynch-window): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
468 |
dc97cf5c3f82
(vc-resynch-window): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
469 ;; VC operations might toggle the read-only state. In |
dc97cf5c3f82
(vc-resynch-window): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
470 ;; that case we need to adjust the `view-mode' status |
dc97cf5c3f82
(vc-resynch-window): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
471 ;; when `view-read-only' is non-nil. |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
472 (and view-read-only |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
473 (if (file-writable-p file) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
474 (and view-mode |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
475 (let ((view-old-buffer-read-only nil)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
476 (view-mode-exit))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
477 (and (not view-mode) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
478 (not (eq (get major-mode 'mode-class) 'special)) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
479 (view-mode-enter)))) |
104169
dc97cf5c3f82
(vc-resynch-window): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104051
diff
changeset
|
480 |
108943
04a1a4b18129
* lisp/vc-dispatcher.el: Rename mode-line-hook to vc-mode-line-hook;
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106871
diff
changeset
|
481 ;; FIXME: Why use a hook? Why pass it buffer-file-name? |
04a1a4b18129
* lisp/vc-dispatcher.el: Rename mode-line-hook to vc-mode-line-hook;
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106871
diff
changeset
|
482 (run-hook-with-args 'vc-mode-line-hook buffer-file-name)) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
483 (kill-buffer (current-buffer))))) |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
484 |
96203 | 485 (declare-function vc-dir-resynch-file "vc-dir" (&optional fname)) |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
486 (declare-function vc-string-prefix-p "vc" (prefix string)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
487 |
108914
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
488 (defun vc-resynch-buffers-in-directory (directory &optional keep noquery reset-vc-info) |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
489 "Resync all buffers that visit files in DIRECTORY." |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
490 (dolist (buffer (buffer-list)) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
491 (let ((fname (buffer-file-name buffer))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
492 (when (and fname (vc-string-prefix-p directory fname)) |
104051
a629d51e1d82
* vc-dispatcher.el (vc-resynch-buffers-in-directory): Make sure
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100908
diff
changeset
|
493 (with-current-buffer buffer |
108914
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
494 (vc-resynch-buffer fname keep noquery reset-vc-info)))))) |
96203 | 495 |
108914
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
496 (defun vc-resynch-buffer (file &optional keep noquery reset-vc-info) |
94579
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
497 "If FILE is currently visited, resynch its buffer." |
dca2377770e7
Move context-preservation machinery.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94576
diff
changeset
|
498 (if (string= buffer-file-name file) |
108914
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
499 (vc-resynch-window file keep noquery reset-vc-info) |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
500 (if (file-directory-p file) |
108914
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
501 (vc-resynch-buffers-in-directory file keep noquery reset-vc-info) |
96520
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
502 (let ((buffer (get-file-buffer file))) |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
503 (when buffer |
00812d11af93
* vc-dir.el (vc-dir-find-child-files): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96203
diff
changeset
|
504 (with-current-buffer buffer |
108914
e7f12b4b8ef7
Add optional support for resetting VC properties.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108009
diff
changeset
|
505 (vc-resynch-window file keep noquery reset-vc-info)))))) |
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. |
105329
fa9bcb68092e
(vc-resynch-window): Don't revert a buffer which has no associated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105130
diff
changeset
|
508 (when vc-dir-buffers |
95338
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 |
107430
1918e70c8b37
Add special markup processing for commit logs.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106871
diff
changeset
|
525 (defun vc-log-edit (fileset mode) |
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 |
108009
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
531 `((log-edit-listfun . (lambda () |
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
532 ;; FIXME: Should expand the list |
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
533 ;; for directories. |
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
534 (mapcar 'file-relative-name |
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
535 ',fileset))) |
107430
1918e70c8b37
Add special markup processing for commit logs.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106871
diff
changeset
|
536 (log-edit-diff-function . (lambda () (vc-diff nil)))) |
1918e70c8b37
Add special markup processing for commit logs.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106871
diff
changeset
|
537 nil |
1918e70c8b37
Add special markup processing for commit logs.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106871
diff
changeset
|
538 mode) |
94857
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
539 (set (make-local-variable 'vc-log-fileset) fileset) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
540 (set-buffer-modified-p nil) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
541 (setq buffer-file-name nil)) |
7f0ec5dfb100
Prevent some compilaation warnings.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94855
diff
changeset
|
542 |
108009
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
543 (defun vc-start-logentry (files comment initial-contents msg logbuf mode action &optional after-hook) |
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
544 "Accept a comment for an operation on FILES. |
95018
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 empty comment. Remember the file's buffer in `vc-parent-buffer' |
107483
2b2a771fc89b
* vc-dispatcher.el (vc-start-logentry): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
107434
diff
changeset
|
552 \(current one if no file). Puts the log-entry buffer in major-mode |
2b2a771fc89b
* vc-dispatcher.el (vc-start-logentry): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
107434
diff
changeset
|
553 MODE, defaulting to `log-edit-mode' if MODE is nil. |
2b2a771fc89b
* vc-dispatcher.el (vc-start-logentry): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
107434
diff
changeset
|
554 AFTER-HOOK specifies the local value for `vc-log-after-operation-hook'." |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
555 (let ((parent |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
556 (if (vc-dispatcher-browsing) |
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
557 ;; 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
|
558 ;; the current buffer. |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
559 (current-buffer) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
560 (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
|
561 (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
|
562 (current-buffer))))) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
563 (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
|
564 (set-buffer (get-buffer-create logbuf)) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
565 (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
|
566 (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
|
567 (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
|
568 (concat " from " (buffer-name vc-parent-buffer))) |
107430
1918e70c8b37
Add special markup processing for commit logs.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106871
diff
changeset
|
569 (vc-log-edit files mode) |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
570 (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
|
571 (when after-hook |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
572 (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
|
573 (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
|
574 (when comment |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
575 (erase-buffer) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
576 (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
|
577 (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
|
578 (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
|
579 (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
|
580 |
96203 | 581 (declare-function vc-dir-move-to-goal-column "vc-dir" ()) |
108009
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
582 ;; vc-finish-logentry is typically called from a log-edit buffer (see |
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
583 ;; vc-start-logentry). |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
584 (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
|
585 "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
|
586 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
|
587 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
|
588 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
|
589 (interactive) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
590 ;; 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
|
591 (unless nocomment |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
592 (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
|
593 ;; 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
|
594 ;; 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
|
595 (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
|
596 (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
|
597 (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
|
598 (error "No log operation is pending")) |
107430
1918e70c8b37
Add special markup processing for commit logs.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106871
diff
changeset
|
599 |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
600 ;; 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
|
601 (let ((logbuf (current-buffer)) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
602 (log-operation vc-log-operation) |
108009
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
603 ;; FIXME: When coming from VC-Dir, we should check that the |
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
604 ;; set of selected files is still equal to vc-log-fileset, |
17d3324f96dd
Make the log-edit comments use RFC822 format throughout.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108002
diff
changeset
|
605 ;; to avoid surprises. |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
606 (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
|
607 (log-entry (buffer-string)) |
108002
c609e6e60b3d
* vc-dispatcher (vc-finish-logentry): Don't mess with the windows/frames.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107483
diff
changeset
|
608 (after-hook vc-log-after-operation-hook)) |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
609 (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
|
610 ;; 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
|
611 (save-excursion |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
612 (funcall log-operation |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
613 log-fileset |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
614 log-entry)) |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
615 ;; Remove checkin window (after the checkin so that if that fails |
95019 | 616 ;; 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
|
617 ;; -- 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
|
618 (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
|
619 (delete-windows-on logbuf (selected-frame)) |
2253b8d4def6
More elimination of buffer name dependencies.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
95017
diff
changeset
|
620 ;; 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
|
621 (kill-buffer logbuf)) |
108002
c609e6e60b3d
* vc-dispatcher (vc-finish-logentry): Don't mess with the windows/frames.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107483
diff
changeset
|
622 (logbuf |
c609e6e60b3d
* vc-dispatcher (vc-finish-logentry): Don't mess with the windows/frames.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107483
diff
changeset
|
623 (with-selected-window (or (get-buffer-window logbuf 0) |
c609e6e60b3d
* vc-dispatcher (vc-finish-logentry): Don't mess with the windows/frames.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107483
diff
changeset
|
624 (selected-window)) |
c609e6e60b3d
* vc-dispatcher (vc-finish-logentry): Don't mess with the windows/frames.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107483
diff
changeset
|
625 (with-current-buffer logbuf |
c609e6e60b3d
* vc-dispatcher (vc-finish-logentry): Don't mess with the windows/frames.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107483
diff
changeset
|
626 (bury-buffer))))) |
94576
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
627 ;; 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
|
628 (when log-fileset |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
629 (mapc |
7de38dedf0a6
Move the command-closure machinery to vc-dispatcher.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94573
diff
changeset
|
630 (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
|
631 log-fileset)) |
94729
bf91c987049c
Remove VC-Dired and backend dir-state methods.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94728
diff
changeset
|
632 (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
|
633 (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
|
634 (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
|
635 |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
636 (defun vc-dispatcher-browsing () |
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
637 "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
|
638 (derived-mode-p 'vc-dir-mode)) |
1f66528f35c3
(vc-dispatcher-browsing): Use derived-mode-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94778
diff
changeset
|
639 |
96203 | 640 ;; These are unused. |
641 ;; (defun vc-dispatcher-in-fileset-p (fileset) | |
642 ;; (let ((member nil)) | |
643 ;; (while (and (not member) fileset) | |
644 ;; (let ((elem (pop fileset))) | |
645 ;; (if (if (file-directory-p elem) | |
646 ;; (eq t (compare-strings buffer-file-name nil (length elem) | |
647 ;; elem nil nil)) | |
648 ;; (eq (current-buffer) (get-file-buffer elem))) | |
649 ;; (setq member t)))) | |
650 ;; member)) | |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
651 |
96203 | 652 ;; (defun vc-dispatcher-selection-set (&optional observer) |
653 ;; "Deduce a set of files to which to apply an operation. Return a cons | |
654 ;; cell (SELECTION . FILESET), where SELECTION is what the user chose | |
655 ;; and FILES is the flist with any directories replaced by the listed files | |
656 ;; within them. | |
94984
b8d24d4a4bdc
Eliminate exoensive (vc-expand-dirs) calls.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94859
diff
changeset
|
657 |
96203 | 658 ;; If we're in a directory display, the fileset is the list of marked files (if |
659 ;; there is one) else the file on the current line. If not in a directory | |
660 ;; display, but the current buffer visits a file, the fileset is a singleton | |
661 ;; containing that file. Otherwise, throw an error." | |
662 ;; (let ((selection | |
663 ;; (cond | |
664 ;; ;; Browsing with vc-dir | |
665 ;; ((vc-dispatcher-browsing) | |
666 ;; ;; If no files are marked, temporarily mark current file | |
667 ;; ;; and choose on that basis (so we get subordinate files) | |
668 ;; (if (not (vc-dir-marked-files)) | |
669 ;; (prog2 | |
670 ;; (vc-dir-mark-file) | |
671 ;; (cons (vc-dir-marked-files) (vc-dir-marked-only-files)) | |
672 ;; (vc-dir-unmark-all-files t)) | |
673 ;; (cons (vc-dir-marked-files) (vc-dir-marked-only-files)))) | |
674 ;; ;; Visiting an eligible file | |
675 ;; ((buffer-file-name) | |
676 ;; (cons (list buffer-file-name) (list buffer-file-name))) | |
677 ;; ;; No eligible file -- if there's a parent buffer, deduce from there | |
678 ;; ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer) | |
679 ;; (with-current-buffer vc-parent-buffer | |
680 ;; (vc-dispatcher-browsing)))) | |
681 ;; (with-current-buffer vc-parent-buffer | |
682 ;; (vc-dispatcher-selection-set))) | |
683 ;; ;; No good set here, throw error | |
684 ;; (t (error "No fileset is available here"))))) | |
685 ;; ;; We assume, in order to avoid unpleasant surprises to the user, | |
686 ;; ;; that a fileset is not in good shape to be handed to the user if the | |
687 ;; ;; buffers visiting the fileset don't match the on-disk contents. | |
688 ;; (unless observer | |
689 ;; (save-some-buffers | |
690 ;; nil (lambda () (vc-dispatcher-in-fileset-p (cdr selection))))) | |
691 ;; selection)) | |
94647
d0547efd97db
More policy-mechanism separation.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94637
diff
changeset
|
692 |
94854
4c35f4ccba9e
(vc-hooks, ewoc): Require.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
693 (provide 'vc-dispatcher) |
4c35f4ccba9e
(vc-hooks, ewoc): Require.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
694 |
94613 | 695 ;; 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
|
696 ;;; vc-dispatcher.el ends here |