Mercurial > emacs
annotate lisp/vc-hooks.el @ 10003:c5a44b9c6565
(XSETCOMPILED): New macro.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Fri, 18 Nov 1994 02:30:32 +0000 |
parents | ae7a27dc719d |
children | 332014233a2c |
rev | line source |
---|---|
2232
4f9d60f7de9d
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2227
diff
changeset
|
1 ;;; vc-hooks.el --- resident support for version-control |
904 | 2 |
7300 | 3 ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. |
904 | 4 |
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | |
9826
b6bed4a60f84
Add maintainer line in header.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
9248
diff
changeset
|
6 ;; Maintainer: ttn@netcom.com |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
7 ;; Version: 5.3 + CVS hacks by ceder@lysator.liu.se made in Jan-Feb 1994. |
904 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; See the commentary of vc.el. | |
28 | |
29 ;;; Code: | |
30 | |
31 (defvar vc-master-templates | |
32 '(("%sRCS/%s,v" . RCS) ("%s%s,v" . RCS) ("%sRCS/%s" . RCS) | |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
33 ("%sSCCS/s.%s" . SCCS) ("%ss.%s". SCCS) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
34 vc-find-cvs-master) |
904 | 35 "*Where to look for version-control master files. |
36 The first pair corresponding to a given back end is used as a template | |
37 when creating new masters.") | |
38 | |
39 (defvar vc-make-backup-files nil | |
5164
04d6b9e7782a
(vc-make-backup-files): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
4726
diff
changeset
|
40 "*If non-nil, backups of registered files are made as with other files. |
5783
6a97e54241a3
(vc-make-backup-files): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5743
diff
changeset
|
41 If nil (the default), files covered by version control don't get backups.") |
904 | 42 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
43 (defvar vc-display-status t |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
44 "*If non-nil, display revision number and lock status in modeline. |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
45 Otherwise, not displayed.") |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
46 |
904 | 47 ;; Tell Emacs about this new kind of minor mode |
2491
5f3061858f47
vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
48 (if (not (assoc 'vc-mode minor-mode-alist)) |
5f3061858f47
vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
49 (setq minor-mode-alist (cons '(vc-mode vc-mode) |
904 | 50 minor-mode-alist))) |
51 | |
2491
5f3061858f47
vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
52 (make-variable-buffer-local 'vc-mode) |
2620
d26f75fd9f5e
(vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents:
2491
diff
changeset
|
53 (put 'vc-mode 'permanent-local t) |
904 | 54 |
55 ;; We need a notion of per-file properties because the version | |
56 ;; control state of a file is expensive to derive --- we don't | |
57 ;; want to recompute it even on every find. | |
58 | |
2213
9ff513b5d296
vc-error-occurred: moved to vc-hooks.el in order for ^X^F of a
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1951
diff
changeset
|
59 (defmacro vc-error-occurred (&rest body) |
9ff513b5d296
vc-error-occurred: moved to vc-hooks.el in order for ^X^F of a
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1951
diff
changeset
|
60 (list 'condition-case nil (cons 'progn (append body '(nil))) '(error t))) |
9ff513b5d296
vc-error-occurred: moved to vc-hooks.el in order for ^X^F of a
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1951
diff
changeset
|
61 |
904 | 62 (defvar vc-file-prop-obarray [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] |
63 "Obarray for per-file properties.") | |
64 | |
65 (defun vc-file-setprop (file property value) | |
66 ;; set per-file property | |
67 (put (intern file vc-file-prop-obarray) property value)) | |
68 | |
69 (defun vc-file-getprop (file property) | |
70 ;; get per-file property | |
71 (get (intern file vc-file-prop-obarray) property)) | |
72 | |
73 ;;; actual version-control code starts here | |
74 | |
75 (defun vc-registered (file) | |
2218
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
76 (let (handler handlers) |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
77 (if (boundp 'file-name-handler-alist) |
7483
dfd719c64907
(vc-registered): Use find-file-name-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
78 (setq handler (find-file-name-handler file 'vc-registered))) |
2218
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
79 (if handler |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
80 (funcall handler 'vc-registered file) |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
81 ;; Search for a master corresponding to the given file |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
82 (let ((dirname (or (file-name-directory file) "")) |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
83 (basename (file-name-nondirectory file))) |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
84 (catch 'found |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
85 (mapcar |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
86 (function (lambda (s) |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
87 (if (atom s) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
88 (funcall s dirname basename) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
89 (let ((trial (format (car s) dirname basename))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
90 (if (and (file-exists-p trial) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
91 ;; Make sure the file we found with name |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
92 ;; TRIAL is not the source file itself. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
93 ;; That can happen with RCS-style names |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
94 ;; if the file name is truncated |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
95 ;; (e.g. to 14 chars). See if either |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
96 ;; directory or attributes differ. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
97 (or (not (string= dirname |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
98 (file-name-directory trial))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
99 (not (equal |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
100 (file-attributes file) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
101 (file-attributes trial))))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
102 (throw 'found (cons trial (cdr s)))))))) |
2218
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
103 vc-master-templates) |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
104 nil))))) |
904 | 105 |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
106 (defun vc-find-cvs-master (dirname basename) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
107 ;; Check if DIRNAME/BASENAME is handled by CVS. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
108 ;; If it is, do a (throw 'found (cons MASTER 'CVS)). |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
109 ;; Note: If the file is ``cvs add''ed but not yet ``cvs commit''ed |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
110 ;; the MASTER will not actually exist yet. The other parts of VC |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
111 ;; checks for this condition. This function returns something random if |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
112 ;; DIRNAME/BASENAME is not handled by CVS. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
113 (if (and (file-directory-p (concat dirname "CVS/")) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
114 (file-readable-p (concat dirname "CVS/Entries"))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
115 (let ((bufs nil)) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
116 (unwind-protect |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
117 (save-excursion |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
118 (setq bufs (list |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
119 (find-file-noselect (concat dirname "CVS/Entries")))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
120 (set-buffer (car bufs)) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
121 (goto-char (point-min)) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
122 (cond |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
123 ((re-search-forward |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
124 (concat "^/" (regexp-quote basename) "/\\([^/]*\\)/") |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
125 nil t) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
126 ;; We found it. Store away version number, now |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
127 ;; that we are anyhow so close to finding it. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
128 (vc-file-setprop (concat dirname basename) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
129 'vc-your-latest-version |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
130 (buffer-substring (match-beginning 1) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
131 (match-end 1))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
132 (setq bufs (cons (find-file-noselect |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
133 (concat dirname "CVS/Repository")) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
134 bufs)) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
135 (set-buffer (car bufs)) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
136 (let ((master |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
137 (concat (file-name-as-directory |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
138 (buffer-substring (point-min) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
139 (1- (point-max)))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
140 basename |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
141 ",v"))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
142 (throw 'found (cons master 'CVS)))))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
143 (mapcar (function kill-buffer) bufs))))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
144 |
3989
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
145 (defun vc-name (file) |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
146 "Return the master name of a file, nil if it is not registered." |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
147 (or (vc-file-getprop file 'vc-name) |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
148 (let ((name-and-type (vc-registered file))) |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
149 (if name-and-type |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
150 (progn |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
151 (vc-file-setprop file 'vc-backend (cdr name-and-type)) |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
152 (vc-file-setprop file 'vc-name (car name-and-type))))))) |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
153 |
904 | 154 (defun vc-backend-deduce (file) |
3989
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
155 "Return the version-control type of a file, nil if it is not registered." |
904 | 156 (and file |
157 (or (vc-file-getprop file 'vc-backend) | |
3989
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
158 (let ((name-and-type (vc-registered file))) |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
159 (if name-and-type |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
160 (progn |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
161 (vc-file-setprop file 'vc-name (car name-and-type)) |
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
162 (vc-file-setprop file 'vc-backend (cdr name-and-type)))))))) |
904 | 163 |
164 (defun vc-toggle-read-only () | |
2620
d26f75fd9f5e
(vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents:
2491
diff
changeset
|
165 "Change read-only status of current buffer, perhaps via version control. |
d26f75fd9f5e
(vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents:
2491
diff
changeset
|
166 If the buffer is visiting a file registered with version control, |
d26f75fd9f5e
(vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents:
2491
diff
changeset
|
167 then check the file in or out. Otherwise, just change the read-only flag |
d26f75fd9f5e
(vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents:
2491
diff
changeset
|
168 of the buffer." |
904 | 169 (interactive) |
170 (if (vc-backend-deduce (buffer-file-name)) | |
171 (vc-next-action nil) | |
172 (toggle-read-only))) | |
2620
d26f75fd9f5e
(vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents:
2491
diff
changeset
|
173 (define-key global-map "\C-x\C-q" 'vc-toggle-read-only) |
904 | 174 |
175 (defun vc-mode-line (file &optional label) | |
2491
5f3061858f47
vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
176 "Set `vc-mode' to display type of version control for FILE. |
904 | 177 The value is set in the current buffer, which should be the buffer |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
178 visiting FILE. Second optional arg LABEL is put in place of version |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
179 control system name." |
2218
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
180 (interactive (list buffer-file-name nil)) |
7568
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
181 (if file |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
182 (let ((vc-type (vc-backend-deduce file))) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
183 (setq vc-mode |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
184 (if vc-type |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
185 (concat " " (or label (symbol-name vc-type)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
186 (if vc-display-status |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
187 (vc-status file vc-type))))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
188 ;; Even root shouldn't modify a registered file without |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
189 ;; locking it first. |
7568
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
190 (and vc-type |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
191 (not buffer-read-only) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
192 (zerop (user-uid)) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
193 (require 'vc) |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
194 (not (equal (user-login-name) (vc-locking-user file))) |
7568
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
195 (setq buffer-read-only t)) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
196 (and (null vc-type) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
197 (file-symlink-p file) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
198 (let ((link-type (vc-backend-deduce (file-symlink-p file)))) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
199 (if link-type |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
200 (message |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
201 "Warning: symbolic link to %s-controlled source file" |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
202 link-type)))) |
7568
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
203 (force-mode-line-update) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
204 ;;(set-buffer-modified-p (buffer-modified-p)) ;;use this if Emacs 18 |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
205 vc-type))) |
904 | 206 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
207 (defun vc-status (file vc-type) |
4063
cebb261b0f10
(vc-rcs-status): Include head version number in mode line if there
Paul Eggert <eggert@twinsun.com>
parents:
4024
diff
changeset
|
208 ;; Return string for placement in modeline by `vc-mode-line'. |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
209 ;; If FILE is not registered, return nil. |
4063
cebb261b0f10
(vc-rcs-status): Include head version number in mode line if there
Paul Eggert <eggert@twinsun.com>
parents:
4024
diff
changeset
|
210 ;; If FILE is registered but not locked, return " REV" if there is a head |
cebb261b0f10
(vc-rcs-status): Include head version number in mode line if there
Paul Eggert <eggert@twinsun.com>
parents:
4024
diff
changeset
|
211 ;; revision and " @@" otherwise. |
cebb261b0f10
(vc-rcs-status): Include head version number in mode line if there
Paul Eggert <eggert@twinsun.com>
parents:
4024
diff
changeset
|
212 ;; If FILE is locked then return all locks in a string of the |
4159
e0bddf2ba112
(vc-rcs-status): Omit "LOCKER:" if you are the locker.
Paul Eggert <eggert@twinsun.com>
parents:
4104
diff
changeset
|
213 ;; form " LOCKER1:REV1 LOCKER2:REV2 ...", where "LOCKERi:" is empty if you |
e0bddf2ba112
(vc-rcs-status): Omit "LOCKER:" if you are the locker.
Paul Eggert <eggert@twinsun.com>
parents:
4104
diff
changeset
|
214 ;; are the locker, and otherwise is the name of the locker followed by ":". |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
215 |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
216 ;; Algorithm: |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
217 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
218 ;; Check for master file corresponding to FILE being visited. |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
219 ;; |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
220 ;; RCS: Insert the first few characters of the master file into a |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
221 ;; work buffer. Search work buffer for "locks...;" phrase; if not |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
222 ;; found, then keep inserting more characters until the phrase is |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
223 ;; found. Extract the locks, and remove control characters |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
224 ;; separating them, like newlines; the string " user1:revision1 |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
225 ;; user2:revision2 ..." is returned. |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
226 ;; |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
227 ;; SCCS: Check if the p-file exists. If it does, read it and |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
228 ;; extract the locks, giving them the right format. Else use prs to |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
229 ;; find the revision number. |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
230 ;; |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
231 ;; CVS: vc-find-cvs-master has already stored the current revision |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
232 ;; number. Fetch it from the file property. |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
233 |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
234 ;; Limitations: |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
235 |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
236 ;; The output doesn't show which version you are actually looking at. |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
237 ;; The modeline can get quite cluttered when there are multiple locks. |
4063
cebb261b0f10
(vc-rcs-status): Include head version number in mode line if there
Paul Eggert <eggert@twinsun.com>
parents:
4024
diff
changeset
|
238 ;; The head revision is probably not what you want if you've used `rcs -b'. |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
239 |
3989
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
240 (let ((master (vc-name file)) |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
241 found |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
242 status) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
243 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
244 ;; If master file exists, then parse its contents, otherwise we |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
245 ;; return the nil value of this if form. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
246 (if (and master vc-type) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
247 (save-excursion |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
248 |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
249 ;; Create work buffer. |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
250 (set-buffer (get-buffer-create " *vc-status*")) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
251 (setq buffer-read-only nil |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
252 default-directory (file-name-directory master)) |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
253 (erase-buffer) |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
254 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
255 ;; Set the `status' var to the return value. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
256 (cond |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
257 |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
258 ;; RCS code. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
259 ((eq vc-type 'RCS) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
260 ;; Check if we have enough of the header. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
261 ;; If not, then keep including more. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
262 (while |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
263 (not (or found |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
264 (let ((s (buffer-size))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
265 (goto-char (1+ s)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
266 (zerop (car (cdr (insert-file-contents |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
267 master nil s (+ s 8192)))))))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
268 (beginning-of-line) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
269 (setq found (re-search-forward "^locks\\([^;]*\\);" nil t))) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
270 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
271 (if found |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
272 ;; Clean control characters and self-locks from text. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
273 (let* ((lock-pattern |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
274 (concat "[ \b\t\n\v\f\r]+\\(" |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
275 (regexp-quote (user-login-name)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
276 ":\\)?")) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
277 (locks |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
278 (save-restriction |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
279 (narrow-to-region (match-beginning 1) (match-end 1)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
280 (goto-char (point-min)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
281 (while (re-search-forward lock-pattern nil t) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
282 (replace-match (if (eobp) "" ":") t t)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
283 (buffer-string)))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
284 (setq status |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
285 (if (not (string-equal locks "")) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
286 locks |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
287 (goto-char (point-min)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
288 (if (looking-at "head[ \b\t\n\v\f\r]+\\([.0-9]+\\)") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
289 (concat "-" |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
290 (buffer-substring (match-beginning 1) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
291 (match-end 1))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
292 " @@")))))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
293 |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
294 ;; SCCS code. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
295 ((eq vc-type 'SCCS) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
296 ;; Build the name of the p-file and put it in the work buffer. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
297 (insert master) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
298 (search-backward "/s.") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
299 (delete-char 2) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
300 (insert "/p") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
301 (if (not (file-exists-p (buffer-string))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
302 ;; No lock. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
303 (let ((exec-path (if vc-path (append exec-path vc-path) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
304 exec-path))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
305 (erase-buffer) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
306 (insert "-") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
307 (if (zerop (call-process "prs" nil t nil "-d:I:" master)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
308 (setq status (buffer-substring 1 (1- (point-max)))))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
309 ;; Locks exist. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
310 (insert-file-contents (buffer-string) nil nil nil t) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
311 (while (looking-at "[^ ]+ \\([^ ]+\\) \\([^ ]+\\).*\n") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
312 (replace-match " \\2:\\1")) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
313 (setq status (buffer-string)) |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
314 (aset status 0 ?:))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
315 ;; CVS code. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
316 ((eq vc-type 'CVS) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
317 (let ((version (vc-file-getprop |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
318 file 'vc-your-latest-version))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
319 (setq status (concat ":" (if (string= "0" version) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
320 " @@" ;added, not yet committed. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
321 version)))))) |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
322 |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
323 ;; Clean work buffer. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
324 (erase-buffer) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
325 (set-buffer-modified-p nil) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
326 status)))) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
327 |
904 | 328 ;;; install a call to the above as a find-file hook |
329 (defun vc-find-file-hook () | |
2218
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
330 ;; Recompute whether file is version controlled, |
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
331 ;; if user has killed the buffer and revisited. |
3459
763bc1ba714e
(vc-find-file-hook): Check buffer-file-name is non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
2620
diff
changeset
|
332 (if buffer-file-name |
763bc1ba714e
(vc-find-file-hook): Check buffer-file-name is non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
2620
diff
changeset
|
333 (vc-file-setprop buffer-file-name 'vc-backend nil)) |
904 | 334 (if (and (vc-mode-line buffer-file-name) (not vc-make-backup-files)) |
335 (progn | |
6545
3715d5bfad50
(vc-find-file-hook): Set backup-inhibited.
Richard M. Stallman <rms@gnu.org>
parents:
5783
diff
changeset
|
336 ;; Use this variable, not make-backup-files, |
3715d5bfad50
(vc-find-file-hook): Set backup-inhibited.
Richard M. Stallman <rms@gnu.org>
parents:
5783
diff
changeset
|
337 ;; because this is for things that depend on the file name. |
3715d5bfad50
(vc-find-file-hook): Set backup-inhibited.
Richard M. Stallman <rms@gnu.org>
parents:
5783
diff
changeset
|
338 (make-local-variable 'backup-inhibited) |
3715d5bfad50
(vc-find-file-hook): Set backup-inhibited.
Richard M. Stallman <rms@gnu.org>
parents:
5783
diff
changeset
|
339 (setq backup-inhibited t)))) |
904 | 340 |
4655
604a401e05a4
(vc-find-file-hook, vc-file-not-found-hook): Use add-hook to install.
Paul Eggert <eggert@twinsun.com>
parents:
4338
diff
changeset
|
341 (add-hook 'find-file-hooks 'vc-find-file-hook) |
904 | 342 |
343 ;;; more hooks, this time for file-not-found | |
344 (defun vc-file-not-found-hook () | |
345 "When file is not found, try to check it out from RCS or SCCS. | |
346 Returns t if checkout was successful, nil otherwise." | |
347 (if (vc-backend-deduce buffer-file-name) | |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
348 (save-excursion |
904 | 349 (require 'vc) |
350 (not (vc-error-occurred (vc-checkout buffer-file-name)))))) | |
351 | |
4655
604a401e05a4
(vc-find-file-hook, vc-file-not-found-hook): Use add-hook to install.
Paul Eggert <eggert@twinsun.com>
parents:
4338
diff
changeset
|
352 (add-hook 'find-file-not-found-hooks 'vc-file-not-found-hook) |
904 | 353 |
354 ;;; Now arrange for bindings and autoloading of the main package. | |
2491
5f3061858f47
vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
355 ;;; Bindings for this have to go in the global map, as we'll often |
5f3061858f47
vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
356 ;;; want to call them from random buffers. |
904 | 357 |
358 (setq vc-prefix-map (lookup-key global-map "\C-xv")) | |
359 (if (not (keymapp vc-prefix-map)) | |
360 (progn | |
361 (setq vc-prefix-map (make-sparse-keymap)) | |
362 (define-key global-map "\C-xv" vc-prefix-map) | |
363 (define-key vc-prefix-map "a" 'vc-update-change-log) | |
364 (define-key vc-prefix-map "c" 'vc-cancel-version) | |
2218
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
365 (define-key vc-prefix-map "d" 'vc-directory) |
904 | 366 (define-key vc-prefix-map "h" 'vc-insert-headers) |
367 (define-key vc-prefix-map "i" 'vc-register) | |
368 (define-key vc-prefix-map "l" 'vc-print-log) | |
369 (define-key vc-prefix-map "r" 'vc-retrieve-snapshot) | |
370 (define-key vc-prefix-map "s" 'vc-create-snapshot) | |
371 (define-key vc-prefix-map "u" 'vc-revert-buffer) | |
372 (define-key vc-prefix-map "v" 'vc-next-action) | |
2218
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
373 (define-key vc-prefix-map "=" 'vc-diff) |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
374 (define-key vc-prefix-map "~" 'vc-version-other-window))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
375 |
9869
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
376 (if (not (boundp 'vc-menu-map)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
377 ;; Don't do the menu bindings if menu-bar.el wasn't loaded to defvar |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
378 ;; vc-menu-map. |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
379 () |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
380 ;;(define-key vc-menu-map [show-files] |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
381 ;; '("Show Files under VC" . (vc-directory t))) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
382 (define-key vc-menu-map [vc-directory] '("Show Locked Files" . vc-directory)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
383 (define-key vc-menu-map [separator1] '("----")) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
384 (define-key vc-menu-map [vc-rename-file] '("Rename File" . vc-rename-file)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
385 (define-key vc-menu-map [vc-version-other-window] |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
386 '("Show Other Version" . vc-version-other-window)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
387 (define-key vc-menu-map [vc-diff] '("Compare with Last Version" . vc-diff)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
388 (define-key vc-menu-map [vc-update-change-log] |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
389 '("Update ChangeLog" . vc-update-change-log)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
390 (define-key vc-menu-map [vc-print-log] '("Show History" . vc-print-log)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
391 (define-key vc-menu-map [separator2] '("----")) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
392 (define-key vc-menu-map [undo] '("Undo Last Check-In" . vc-cancel-version)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
393 (define-key vc-menu-map [vc-revert-buffer] |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
394 '("Revert to Last Version" . vc-revert-buffer)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
395 (define-key vc-menu-map [vc-insert-header] |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
396 '("Insert Header" . vc-insert-headers)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
397 (define-key vc-menu-map [vc-menu-check-in] '("Check In" . vc-next-action)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
398 (define-key vc-menu-map [vc-check-out] '("Check Out" . vc-toggle-read-only)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
399 (define-key vc-menu-map [vc-register] '("Register" . vc-register)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
400 (put 'vc-rename-file 'menu-enable 'vc-mode) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
401 (put 'vc-version-other-window 'menu-enable 'vc-mode) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
402 (put 'vc-diff 'menu-enable 'vc-mode) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
403 (put 'vc-update-change-log 'menu-enable |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
404 '(eq (vc-backend-deduce (buffer-file-name)) 'RCS)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
405 (put 'vc-print-log 'menu-enable 'vc-mode) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
406 (put 'vc-cancel-version 'menu-enable 'vc-mode) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
407 (put 'vc-revert-buffer 'menu-enable 'vc-mode) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
408 (put 'vc-insert-headers 'menu-enable 'vc-mode) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
409 (put 'vc-next-action 'menu-enable '(and vc-mode (not buffer-read-only))) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
410 (put 'vc-toggle-read-only 'menu-enable '(and vc-mode buffer-read-only)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
411 (put 'vc-register 'menu-enable '(not vc-mode)) |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
412 ) |
904 | 413 |
414 (provide 'vc-hooks) | |
415 | |
416 ;;; vc-hooks.el ends here |