annotate lisp/vc-hooks.el @ 3507:d25bc92a64b4

(Fx_open_connection): Make `data' unsigned char.
author Richard M. Stallman <rms@gnu.org>
date Sat, 05 Jun 1993 20:52:02 +0000
parents 763bc1ba714e
children c6f3d2af0df7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3 ;; Copyright (C) 1992 Free Software Foundation, Inc.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
4
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
6 ;; Version: 5.3
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
7
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 ;; any later version.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 ;;; Commentary:
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26 ;; See the commentary of vc.el.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28 ;;; Code:
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
29
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
30 (defvar vc-master-templates
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31 '(("%sRCS/%s,v" . RCS) ("%s%s,v" . RCS) ("%sRCS/%s" . RCS)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32 ("%sSCCS/s.%s" . SCCS) ("%ss.%s". SCCS))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 "*Where to look for version-control master files.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 The first pair corresponding to a given back end is used as a template
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35 when creating new masters.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
36
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
37 (defvar vc-make-backup-files nil
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38 "*If non-nil, backups of registered files are made according to
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39 the make-backup-files variable. Otherwise, prevents backups being made.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
41 ;; 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
42 (if (not (assoc 'vc-mode minor-mode-alist))
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
43 (setq minor-mode-alist (cons '(vc-mode vc-mode)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44 minor-mode-alist)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
45
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
46 (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
47 (put 'vc-mode 'permanent-local t)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49 ;; We need a notion of per-file properties because the version
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 ;; control state of a file is expensive to derive --- we don't
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 ;; want to recompute it even on every find.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52
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
53 (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
54 (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
55
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
56 (defvar vc-file-prop-obarray [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 "Obarray for per-file properties.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 (defun vc-file-setprop (file property value)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60 ;; set per-file property
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61 (put (intern file vc-file-prop-obarray) property value))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 (defun vc-file-getprop (file property)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64 ;; get per-file property
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65 (get (intern file vc-file-prop-obarray) property))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
67 ;;; actual version-control code starts here
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
68
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 (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
70 (let (handler handlers)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
71 (if (boundp 'file-name-handler-alist)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
72 (save-match-data
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
73 (setq handlers file-name-handler-alist)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
74 (while (and (consp handlers) (null handler))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
75 (if (and (consp (car handlers))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
76 (stringp (car (car handlers)))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
77 (string-match (car (car handlers)) file))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
78 (setq handler (cdr (car handlers))))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
79 (setq handlers (cdr handlers)))))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
80 (if handler
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
81 (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
82 ;; 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
83 (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
84 (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
85 (catch 'found
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
86 (mapcar
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
87 (function (lambda (s)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
88 (let ((trial (format (car s) dirname basename)))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
89 (if (and (file-exists-p trial)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
90 ;; Make sure the file we found with name
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
91 ;; TRIAL is not the source file itself.
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
92 ;; That can happen with RCS-style names
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
93 ;; if the file name is truncated
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
94 ;; (e.g. to 14 chars). See if either
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
95 ;; directory or attributes differ.
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
96 (or (not (string= dirname
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
97 (file-name-directory trial)))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
98 (not (equal
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
99 (file-attributes file)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
100 (file-attributes trial)))))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
101 (throw 'found (cons trial (cdr s)))))))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
102 vc-master-templates)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
103 nil)))))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
104
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
105 (defun vc-backend-deduce (file)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
106 "Return the version-control type of a file, nil if it is not registered"
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
107 (and file
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
108 (or (vc-file-getprop file 'vc-backend)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
109 (vc-file-setprop file 'vc-backend (cdr (vc-registered file))))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
110
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
111 (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
112 "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
113 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
114 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
115 of the buffer."
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
116 (interactive)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
117 (if (vc-backend-deduce (buffer-file-name))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
118 (vc-next-action nil)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
119 (toggle-read-only)))
2620
d26f75fd9f5e (vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 2491
diff changeset
120 (define-key global-map "\C-x\C-q" 'vc-toggle-read-only)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
121
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
122 (defun vc-mode-line (file &optional label)
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
123 "Set `vc-mode' to display type of version control for FILE.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
124 The value is set in the current buffer, which should be the buffer
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
125 visiting FILE."
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
126 (interactive (list buffer-file-name nil))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
127 (let ((vc-type (vc-backend-deduce file)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
128 (if vc-type
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
129 (progn
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
130 (setq vc-mode
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
131 (concat " " (or label (symbol-name vc-type))))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
132 ;; force update of mode line
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
133 (set-buffer-modified-p (buffer-modified-p))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
134 vc-type))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
135
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
136 ;;; install a call to the above as a find-file hook
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
137 (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
138 ;; 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
139 ;; 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
140 (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
141 (vc-file-setprop buffer-file-name 'vc-backend nil))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
142 (if (and (vc-mode-line buffer-file-name) (not vc-make-backup-files))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
143 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
144 (make-local-variable 'make-backup-files)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
145 (setq make-backup-files nil))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
146
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
147 (or (memq 'vc-find-file-hook find-file-hooks)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
148 (setq find-file-hooks
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
149 (cons 'vc-find-file-hook find-file-hooks)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
150
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
151 ;;; more hooks, this time for file-not-found
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
152 (defun vc-file-not-found-hook ()
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
153 "When file is not found, try to check it out from RCS or SCCS.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
154 Returns t if checkout was successful, nil otherwise."
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
155 (if (vc-backend-deduce buffer-file-name)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
156 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
157 (require 'vc)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
158 (not (vc-error-occurred (vc-checkout buffer-file-name))))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
159
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
160 (or (memq 'vc-file-not-found-hook find-file-not-found-hooks)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
161 (setq find-file-not-found-hooks
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
162 (cons 'vc-file-not-found-hook find-file-not-found-hooks)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
163
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
164 ;;; 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
165 ;;; 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
166 ;;; want to call them from random buffers.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
167
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
168 (setq vc-prefix-map (lookup-key global-map "\C-xv"))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
169 (if (not (keymapp vc-prefix-map))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
170 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
171 (setq vc-prefix-map (make-sparse-keymap))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
172 (define-key global-map "\C-xv" vc-prefix-map)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
173 (define-key vc-prefix-map "a" 'vc-update-change-log)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
174 (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
175 (define-key vc-prefix-map "d" 'vc-directory)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
176 (define-key vc-prefix-map "h" 'vc-insert-headers)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
177 (define-key vc-prefix-map "i" 'vc-register)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
178 (define-key vc-prefix-map "l" 'vc-print-log)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
179 (define-key vc-prefix-map "r" 'vc-retrieve-snapshot)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
180 (define-key vc-prefix-map "s" 'vc-create-snapshot)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
181 (define-key vc-prefix-map "u" 'vc-revert-buffer)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
182 (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
183 (define-key vc-prefix-map "=" 'vc-diff)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
184 ))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
185
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
186 (provide 'vc-hooks)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
187
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
188 ;;; vc-hooks.el ends here