annotate lisp/vc-hooks.el @ 1567:c0c9fc68a006

* lisp.h [not MULTI_FRAME]: Don't declare the Lisp_Frame tag.
author Jim Blandy <jimb@redhat.com>
date Sat, 07 Nov 1992 07:35:20 +0000
parents 341c17b20f2a
children ef257d7ca34a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1 ;;; vc-hooks.el -- resident support for version-control
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>
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
6 ;; Version: 4.0
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
7
1474
341c17b20f2a (vc-prefix-map): Put vc-diff on = and vc-directory on d.
Richard M. Stallman <rms@gnu.org>
parents: 1457
diff changeset
8 ;; $Id: vc-hooks.el,v 1.5 1992/10/20 18:43:33 rms Exp rms $
904
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 ;; This file is part of GNU Emacs.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; 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
13 ;; 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
14 ;; the Free Software Foundation; either version 2, or (at your option)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; any later version.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; 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
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; 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
23 ;; 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
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
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 ;;; Commentary:
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 ;; See the commentary of vc.el.
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 ;;; Code:
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32 (defvar vc-master-templates
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 '(("%sRCS/%s,v" . RCS) ("%s%s,v" . RCS) ("%sRCS/%s" . RCS)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 ("%sSCCS/s.%s" . SCCS) ("%ss.%s". SCCS))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35 "*Where to look for version-control master files.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
36 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
37 when creating new masters.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39 (defvar vc-make-backup-files nil
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40 "*If non-nil, backups of registered files are made according to
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
41 the make-backup-files variable. Otherwise, prevents backups being made.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
42
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
43 ;; Tell Emacs about this new kind of minor mode
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44 (if (not (assoc 'vc-mode-string minor-mode-alist))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
45 (setq minor-mode-alist (cons '(vc-mode-string vc-mode-string)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
46 minor-mode-alist)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
47
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48 (make-variable-buffer-local 'vc-mode-string)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 ;; We need a notion of per-file properties because the version
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 ;; 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
52 ;; want to recompute it even on every find.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54 (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
55 "Obarray for per-file properties.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
56
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 (defun vc-file-setprop (file property value)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58 ;; set per-file property
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 (put (intern file vc-file-prop-obarray) property value))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61 (defun vc-file-getprop (file property)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 ;; get per-file property
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 (get (intern file vc-file-prop-obarray) property))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65 ;;; actual version-control code starts here
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 (defun vc-registered (file)
1457
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
68 (let (handler handlers)
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
69 (if (boundp 'file-name-handler-alist)
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
70 (save-match-data
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
71 (setq handlers file-name-handler-alist)
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
72 (while (and (consp handlers) (null handler))
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
73 (if (and (consp (car handlers))
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
74 (stringp (car (car handlers)))
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
75 (string-match (car (car handlers)) file))
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
76 (setq handler (cdr (car handlers))))
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
77 (setq handlers (cdr handlers)))))
1455
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
78 (if handler
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
79 (funcall handler 'vc-registered file)
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
80 ;; Search for a master corresponding to the given file
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
81 (let ((dirname (or (file-name-directory file) ""))
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
82 (basename (file-name-nondirectory file)))
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
83 (catch 'found
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
84 (mapcar
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
85 (function (lambda (s)
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
86 (let ((trial (format (car s) dirname basename)))
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
87 (if (and (file-exists-p trial)
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
88 ;; Make sure the file we found with name
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
89 ;; TRIAL is not the source file itself.
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
90 ;; That can happen with RCS-style names
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
91 ;; if the file name is truncated
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
92 ;; (e.g. to 14 chars). See if either
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
93 ;; directory or attributes differ.
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
94 (or (not (string= dirname
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
95 (file-name-directory trial)))
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
96 (not (equal
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
97 (file-attributes file)
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
98 (file-attributes trial)))))
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
99 (throw 'found (cons trial (cdr s)))))))
b5a0e08b0dbe (vc-registered): Look for a vc-registered handler.
Richard M. Stallman <rms@gnu.org>
parents: 1224
diff changeset
100 vc-master-templates)
1457
7f3e86c53165 (vc-registered): Look for handler only if file-name-handler-alist is bound.
Richard M. Stallman <rms@gnu.org>
parents: 1455
diff changeset
101 nil)))))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
102
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
103 (defun vc-backend-deduce (file)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
104 "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
105 (and file
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
106 (or (vc-file-getprop file 'vc-backend)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
107 (vc-file-setprop file 'vc-backend (cdr (vc-registered file))))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
108
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
109 (defun vc-toggle-read-only ()
1224
981b00f8fe77 (vc-toggle-read-only): Doc fix.
Roland McGrath <roland@gnu.org>
parents: 926
diff changeset
110 "If the file in the current buffer is under version control, perform the
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
111 logical next version-control action; otherwise, just toggle the buffer's
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
112 read-only flag."
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
113 (interactive)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
114 (if (vc-backend-deduce (buffer-file-name))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
115 (vc-next-action nil)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
116 (toggle-read-only)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
117
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
118 (defun vc-mode-line (file &optional label)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
119 "Set `vc-mode-string' to display type of version control for FILE.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
120 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
121 visiting FILE."
1224
981b00f8fe77 (vc-toggle-read-only): Doc fix.
Roland McGrath <roland@gnu.org>
parents: 926
diff changeset
122 (interactive (list buffer-file-name nil))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
123 (let ((vc-type (vc-backend-deduce file)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
124 (if vc-type
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
125 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
126 (if (null (current-local-map))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
127 (use-local-map (make-sparse-keymap)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
128 (define-key (current-local-map) "\C-x\C-q" 'vc-toggle-read-only)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
129 (setq vc-mode-string
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
130 (concat " " (or label (symbol-name vc-type))))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
131 ;; force update of mode line
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
132 (set-buffer-modified-p (buffer-modified-p))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
133 vc-type))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
134
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
135 ;;; install a call to the above as a find-file hook
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
136 (defun vc-find-file-hook ()
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
137 (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
138 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
139 (make-local-variable 'make-backup-files)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
140 (setq make-backup-files nil))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
141
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
142 (or (memq 'vc-find-file-hook find-file-hooks)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
143 (setq find-file-hooks
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
144 (cons 'vc-find-file-hook find-file-hooks)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
145
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
146 ;;; more hooks, this time for file-not-found
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
147 (defun vc-file-not-found-hook ()
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
148 "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
149 Returns t if checkout was successful, nil otherwise."
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
150 (if (vc-backend-deduce buffer-file-name)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
151 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
152 (require 'vc)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
153 (not (vc-error-occurred (vc-checkout buffer-file-name))))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
154
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
155 (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
156 (setq find-file-not-found-hooks
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
157 (cons 'vc-file-not-found-hook find-file-not-found-hooks)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
158
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
159 ;;; Now arrange for bindings and autoloading of the main package.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
160 ;;; Bindings for this have to go in the global map, as it may have
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
161 ;;; to coexist with a lot of different major modes.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
162
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
163 (setq vc-prefix-map (lookup-key global-map "\C-xv"))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
164 (if (not (keymapp vc-prefix-map))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
165 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
166 (setq vc-prefix-map (make-sparse-keymap))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
167 (define-key global-map "\C-xv" vc-prefix-map)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
168 (define-key vc-prefix-map "a" 'vc-update-change-log)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
169 (define-key vc-prefix-map "c" 'vc-cancel-version)
1474
341c17b20f2a (vc-prefix-map): Put vc-diff on = and vc-directory on d.
Richard M. Stallman <rms@gnu.org>
parents: 1457
diff changeset
170 (define-key vc-prefix-map "d" 'vc-directory)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
171 (define-key vc-prefix-map "h" 'vc-insert-headers)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
172 (define-key vc-prefix-map "i" 'vc-register)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
173 (define-key vc-prefix-map "l" 'vc-print-log)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
174 (define-key vc-prefix-map "r" 'vc-retrieve-snapshot)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
175 (define-key vc-prefix-map "s" 'vc-create-snapshot)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
176 (define-key vc-prefix-map "u" 'vc-revert-buffer)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
177 (define-key vc-prefix-map "v" 'vc-next-action)
1474
341c17b20f2a (vc-prefix-map): Put vc-diff on = and vc-directory on d.
Richard M. Stallman <rms@gnu.org>
parents: 1457
diff changeset
178 (define-key vc-prefix-map "=" 'vc-diff)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
179 ))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
180
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
181 (provide 'vc-hooks)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
182
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
183 ;;; vc-hooks.el ends here