Mercurial > emacs
annotate lisp/vc-hooks.el @ 11315:c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
"/" to avoid infinite loop while expanding filename.
(ange-ftp-message): Don't truncate message in batch mode.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 09 Apr 1995 03:08:18 +0000 |
parents | 332014233a2c |
children | 540868154dc9 |
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 |
10176
332014233a2c
(vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents:
9869
diff
changeset
|
164 (defun vc-toggle-read-only (&optional verbose) |
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 |
10176
332014233a2c
(vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents:
9869
diff
changeset
|
168 of the buffer. |
332014233a2c
(vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents:
9869
diff
changeset
|
169 If you provide a prefix argument, we pass it on to `vc-next-action'." |
332014233a2c
(vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents:
9869
diff
changeset
|
170 (interactive "P") |
904 | 171 (if (vc-backend-deduce (buffer-file-name)) |
10176
332014233a2c
(vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents:
9869
diff
changeset
|
172 (vc-next-action verbose) |
904 | 173 (toggle-read-only))) |
2620
d26f75fd9f5e
(vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents:
2491
diff
changeset
|
174 (define-key global-map "\C-x\C-q" 'vc-toggle-read-only) |
904 | 175 |
176 (defun vc-mode-line (file &optional label) | |
2491
5f3061858f47
vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
177 "Set `vc-mode' to display type of version control for FILE. |
904 | 178 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
|
179 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
|
180 control system name." |
2218
13be90dfef0c
Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents:
2213
diff
changeset
|
181 (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
|
182 (if file |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
183 (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
|
184 (setq vc-mode |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
185 (if vc-type |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
186 (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
|
187 (if vc-display-status |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
188 (vc-status file vc-type))))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
189 ;; 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
|
190 ;; locking it first. |
7568
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
191 (and vc-type |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
192 (not buffer-read-only) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
193 (zerop (user-uid)) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
194 (require 'vc) |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
195 (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
|
196 (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
|
197 (and (null vc-type) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
198 (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 (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
|
200 (if link-type |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
201 (message |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
202 "Warning: symbolic link to %s-controlled source file" |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
203 link-type)))) |
7568
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
204 (force-mode-line-update) |
83bd6547675c
(vc-mode-line): Do nothing if FILE is nil.
Richard M. Stallman <rms@gnu.org>
parents:
7483
diff
changeset
|
205 ;;(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
|
206 vc-type))) |
904 | 207 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
208 (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
|
209 ;; 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
|
210 ;; 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
|
211 ;; 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
|
212 ;; 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
|
213 ;; 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
|
214 ;; 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
|
215 ;; 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
|
216 |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
217 ;; Algorithm: |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
218 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
219 ;; 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
|
220 ;; |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
221 ;; 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
|
222 ;; 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
|
223 ;; 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
|
224 ;; 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
|
225 ;; separating them, like newlines; the string " user1:revision1 |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
226 ;; user2:revision2 ..." is returned. |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
227 ;; |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
228 ;; 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
|
229 ;; 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
|
230 ;; find the revision number. |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
231 ;; |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
232 ;; 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
|
233 ;; 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
|
234 |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
235 ;; Limitations: |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
236 |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
237 ;; 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
|
238 ;; 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
|
239 ;; 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
|
240 |
3989
c24f84e2f019
(vc-name): Moved from vc.el; vc-rcs-status now uses it.
Paul Eggert <eggert@twinsun.com>
parents:
3974
diff
changeset
|
241 (let ((master (vc-name file)) |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
242 found |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
243 status) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
244 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
245 ;; 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
|
246 ;; 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
|
247 (if (and master vc-type) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
248 (save-excursion |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
249 |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
250 ;; Create work buffer. |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
251 (set-buffer (get-buffer-create " *vc-status*")) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
252 (setq buffer-read-only nil |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
253 default-directory (file-name-directory master)) |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
254 (erase-buffer) |
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
255 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
256 ;; 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
|
257 (cond |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
258 |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
259 ;; RCS code. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
260 ((eq vc-type 'RCS) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
261 ;; 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
|
262 ;; If not, then keep including more. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
263 (while |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
264 (not (or found |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
265 (let ((s (buffer-size))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
266 (goto-char (1+ s)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
267 (zerop (car (cdr (insert-file-contents |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
268 master nil s (+ s 8192)))))))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
269 (beginning-of-line) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
270 (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
|
271 |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
272 (if found |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
273 ;; 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
|
274 (let* ((lock-pattern |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
275 (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
|
276 (regexp-quote (user-login-name)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
277 ":\\)?")) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
278 (locks |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
279 (save-restriction |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
280 (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
|
281 (goto-char (point-min)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
282 (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
|
283 (replace-match (if (eobp) "" ":") t t)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
284 (buffer-string)))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
285 (setq status |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
286 (if (not (string-equal locks "")) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
287 locks |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
288 (goto-char (point-min)) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
289 (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
|
290 (concat "-" |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
291 (buffer-substring (match-beginning 1) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
292 (match-end 1))) |
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 |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
295 ;; SCCS code. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
296 ((eq vc-type 'SCCS) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
297 ;; 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
|
298 (insert master) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
299 (search-backward "/s.") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
300 (delete-char 2) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
301 (insert "/p") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
302 (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
|
303 ;; No lock. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
304 (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
|
305 exec-path))) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
306 (erase-buffer) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
307 (insert "-") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
308 (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
|
309 (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
|
310 ;; Locks exist. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
311 (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
|
312 (while (looking-at "[^ ]+ \\([^ ]+\\) \\([^ ]+\\).*\n") |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
313 (replace-match " \\2:\\1")) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
314 (setq status (buffer-string)) |
9248
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
315 (aset status 0 ?:))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
316 ;; CVS code. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
317 ((eq vc-type 'CVS) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
318 (let ((version (vc-file-getprop |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
319 file 'vc-your-latest-version))) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
320 (setq status (concat ":" (if (string= "0" version) |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
321 " @@" ;added, not yet committed. |
325cee61ab7f
(vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents:
8982
diff
changeset
|
322 version)))))) |
8982
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
323 |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
324 ;; Clean work buffer. |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
325 (erase-buffer) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
326 (set-buffer-modified-p nil) |
2a81d1c79162
(vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents:
7568
diff
changeset
|
327 status)))) |
3900
c6f3d2af0df7
(vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
3459
diff
changeset
|
328 |
904 | 329 ;;; install a call to the above as a find-file hook |
330 (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
|
331 ;; 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
|
332 ;; 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
|
333 (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
|
334 (vc-file-setprop buffer-file-name 'vc-backend nil)) |
904 | 335 (if (and (vc-mode-line buffer-file-name) (not vc-make-backup-files)) |
336 (progn | |
6545
3715d5bfad50
(vc-find-file-hook): Set backup-inhibited.
Richard M. Stallman <rms@gnu.org>
parents:
5783
diff
changeset
|
337 ;; 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
|
338 ;; 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
|
339 (make-local-variable 'backup-inhibited) |
3715d5bfad50
(vc-find-file-hook): Set backup-inhibited.
Richard M. Stallman <rms@gnu.org>
parents:
5783
diff
changeset
|
340 (setq backup-inhibited t)))) |
904 | 341 |
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
|
342 (add-hook 'find-file-hooks 'vc-find-file-hook) |
904 | 343 |
344 ;;; more hooks, this time for file-not-found | |
345 (defun vc-file-not-found-hook () | |
346 "When file is not found, try to check it out from RCS or SCCS. | |
347 Returns t if checkout was successful, nil otherwise." | |
348 (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
|
349 (save-excursion |
904 | 350 (require 'vc) |
351 (not (vc-error-occurred (vc-checkout buffer-file-name)))))) | |
352 | |
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
|
353 (add-hook 'find-file-not-found-hooks 'vc-file-not-found-hook) |
904 | 354 |
355 ;;; 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
|
356 ;;; 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
|
357 ;;; want to call them from random buffers. |
904 | 358 |
359 (setq vc-prefix-map (lookup-key global-map "\C-xv")) | |
360 (if (not (keymapp vc-prefix-map)) | |
361 (progn | |
362 (setq vc-prefix-map (make-sparse-keymap)) | |
363 (define-key global-map "\C-xv" vc-prefix-map) | |
364 (define-key vc-prefix-map "a" 'vc-update-change-log) | |
365 (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
|
366 (define-key vc-prefix-map "d" 'vc-directory) |
904 | 367 (define-key vc-prefix-map "h" 'vc-insert-headers) |
368 (define-key vc-prefix-map "i" 'vc-register) | |
369 (define-key vc-prefix-map "l" 'vc-print-log) | |
370 (define-key vc-prefix-map "r" 'vc-retrieve-snapshot) | |
371 (define-key vc-prefix-map "s" 'vc-create-snapshot) | |
372 (define-key vc-prefix-map "u" 'vc-revert-buffer) | |
373 (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
|
374 (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
|
375 (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
|
376 |
9869
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
377 (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
|
378 ;; 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
|
379 ;; vc-menu-map. |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
380 () |
ae7a27dc719d
Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents:
9826
diff
changeset
|
381 ;;(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
|
382 ;; '("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
|
383 (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
|
384 (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
|
385 (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
|
386 (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
|
387 '("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
|
388 (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
|
389 (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
|
390 '("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
|
391 (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
|
392 (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
|
393 (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
|
394 (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
|
395 '("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
|
396 (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
|
397 '("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
|
398 (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
|
399 (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
|
400 (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
|
401 (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
|
402 (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
|
403 (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
|
404 (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
|
405 '(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
|
406 (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
|
407 (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
|
408 (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
|
409 (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
|
410 (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
|
411 (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
|
412 (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
|
413 ) |
904 | 414 |
415 (provide 'vc-hooks) | |
416 | |
417 ;;; vc-hooks.el ends here |