aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond1993-03-16 15:47:45 +0000
committerEric S. Raymond1993-03-16 15:47:45 +0000
commit80169ab5392d1bd5df9f6147bbb47e0edcba43fa (patch)
treeffe3cf057d05c72b2794ba35b47f0b4de25fb39b
parent2dd8d31b2fd001bd4a46ec0817caa3e1803b1fd4 (diff)
downloademacs-80169ab5392d1bd5df9f6147bbb47e0edcba43fa.tar.gz
emacs-80169ab5392d1bd5df9f6147bbb47e0edcba43fa.zip
vc-error-occurred: moved to vc-hooks.el in order for ^X^F of a
nonexistent file to work.
-rw-r--r--lisp/vc-hooks.el75
1 files changed, 32 insertions, 43 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index f7de918f043..accb7cabc67 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -3,9 +3,9 @@
3;; Copyright (C) 1992 Free Software Foundation, Inc. 3;; Copyright (C) 1992 Free Software Foundation, Inc.
4 4
5;; Author: Eric S. Raymond <esr@snark.thyrsus.com> 5;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
6;; Version: 4.0 6;; Version: 5.0
7 7
8;; $Id: vc-hooks.el,v 1.6 1992/10/24 20:07:08 rms Exp rms $ 8;; $Id: vc-hooks.el,v 1.48 1993/03/15 21:42:57 esr Exp $
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -51,6 +51,9 @@ the make-backup-files variable. Otherwise, prevents backups being made.")
51;; control state of a file is expensive to derive --- we don't 51;; control state of a file is expensive to derive --- we don't
52;; want to recompute it even on every find. 52;; want to recompute it even on every find.
53 53
54(defmacro vc-error-occurred (&rest body)
55 (list 'condition-case nil (cons 'progn (append body '(nil))) '(error t)))
56
54(defvar vc-file-prop-obarray [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 57(defvar vc-file-prop-obarray [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
55 "Obarray for per-file properties.") 58 "Obarray for per-file properties.")
56 59
@@ -65,40 +68,29 @@ the make-backup-files variable. Otherwise, prevents backups being made.")
65;;; actual version-control code starts here 68;;; actual version-control code starts here
66 69
67(defun vc-registered (file) 70(defun vc-registered (file)
68 (let (handler handlers) 71 ;; Search for a master corresponding to the given file
69 (if (boundp 'file-name-handler-alist) 72 (let ((dirname (or (file-name-directory file) ""))
70 (save-match-data 73 (basename (file-name-nondirectory file)))
71 (setq handlers file-name-handler-alist) 74 (catch 'found
72 (while (and (consp handlers) (null handler)) 75 (mapcar
73 (if (and (consp (car handlers)) 76 (function (lambda (s)
74 (stringp (car (car handlers))) 77 (let ((trial (format (car s) dirname basename)))
75 (string-match (car (car handlers)) file)) 78 (if (and (file-exists-p trial)
76 (setq handler (cdr (car handlers)))) 79 ;; Make sure the file we found with name
77 (setq handlers (cdr handlers))))) 80 ;; TRIAL is not the source file itself.
78 (if handler 81 ;; That can happen with RCS-style names
79 (funcall handler 'vc-registered file) 82 ;; if the file name is truncated
80 ;; Search for a master corresponding to the given file 83 ;; (e.g. to 14 chars). See if either
81 (let ((dirname (or (file-name-directory file) "")) 84 ;; directory or attributes differ.
82 (basename (file-name-nondirectory file))) 85 (or (not (string= dirname
83 (catch 'found 86 (file-name-directory trial)))
84 (mapcar 87 (not (equal
85 (function (lambda (s) 88 (file-attributes file)
86 (let ((trial (format (car s) dirname basename))) 89 (file-attributes trial)))))
87 (if (and (file-exists-p trial) 90 (throw 'found (cons trial (cdr s)))))))
88 ;; Make sure the file we found with name 91 vc-master-templates)
89 ;; TRIAL is not the source file itself. 92 nil)
90 ;; That can happen with RCS-style names 93 ))
91 ;; if the file name is truncated
92 ;; (e.g. to 14 chars). See if either
93 ;; directory or attributes differ.
94 (or (not (string= dirname
95 (file-name-directory trial)))
96 (not (equal
97 (file-attributes file)
98 (file-attributes trial)))))
99 (throw 'found (cons trial (cdr s)))))))
100 vc-master-templates)
101 nil)))))
102 94
103(defun vc-backend-deduce (file) 95(defun vc-backend-deduce (file)
104 "Return the version-control type of a file, nil if it is not registered" 96 "Return the version-control type of a file, nil if it is not registered"
@@ -107,7 +99,7 @@ the make-backup-files variable. Otherwise, prevents backups being made.")
107 (vc-file-setprop file 'vc-backend (cdr (vc-registered file)))))) 99 (vc-file-setprop file 'vc-backend (cdr (vc-registered file))))))
108 100
109(defun vc-toggle-read-only () 101(defun vc-toggle-read-only ()
110 "If the file in the current buffer is under version control, perform the 102 "If the file in the current buffer id under version control, perform the
111logical next version-control action; otherwise, just toggle the buffer's 103logical next version-control action; otherwise, just toggle the buffer's
112read-only flag." 104read-only flag."
113 (interactive) 105 (interactive)
@@ -119,7 +111,6 @@ read-only flag."
119 "Set `vc-mode-string' to display type of version control for FILE. 111 "Set `vc-mode-string' to display type of version control for FILE.
120The value is set in the current buffer, which should be the buffer 112The value is set in the current buffer, which should be the buffer
121visiting FILE." 113visiting FILE."
122 (interactive (list buffer-file-name nil))
123 (let ((vc-type (vc-backend-deduce file))) 114 (let ((vc-type (vc-backend-deduce file)))
124 (if vc-type 115 (if vc-type
125 (progn 116 (progn
@@ -134,9 +125,6 @@ visiting FILE."
134 125
135;;; install a call to the above as a find-file hook 126;;; install a call to the above as a find-file hook
136(defun vc-find-file-hook () 127(defun vc-find-file-hook ()
137 ;; Recompute whether file is version controlled,
138 ;; if user has killed the buffer and revisited.
139 (vc-file-setprop buffer-file-name 'vc-backend nil)
140 (if (and (vc-mode-line buffer-file-name) (not vc-make-backup-files)) 128 (if (and (vc-mode-line buffer-file-name) (not vc-make-backup-files))
141 (progn 129 (progn
142 (make-local-variable 'make-backup-files) 130 (make-local-variable 'make-backup-files)
@@ -170,7 +158,7 @@ Returns t if checkout was successful, nil otherwise."
170 (define-key global-map "\C-xv" vc-prefix-map) 158 (define-key global-map "\C-xv" vc-prefix-map)
171 (define-key vc-prefix-map "a" 'vc-update-change-log) 159 (define-key vc-prefix-map "a" 'vc-update-change-log)
172 (define-key vc-prefix-map "c" 'vc-cancel-version) 160 (define-key vc-prefix-map "c" 'vc-cancel-version)
173 (define-key vc-prefix-map "d" 'vc-directory) 161 (define-key vc-prefix-map "=" 'vc-diff)
174 (define-key vc-prefix-map "h" 'vc-insert-headers) 162 (define-key vc-prefix-map "h" 'vc-insert-headers)
175 (define-key vc-prefix-map "i" 'vc-register) 163 (define-key vc-prefix-map "i" 'vc-register)
176 (define-key vc-prefix-map "l" 'vc-print-log) 164 (define-key vc-prefix-map "l" 'vc-print-log)
@@ -178,9 +166,10 @@ Returns t if checkout was successful, nil otherwise."
178 (define-key vc-prefix-map "s" 'vc-create-snapshot) 166 (define-key vc-prefix-map "s" 'vc-create-snapshot)
179 (define-key vc-prefix-map "u" 'vc-revert-buffer) 167 (define-key vc-prefix-map "u" 'vc-revert-buffer)
180 (define-key vc-prefix-map "v" 'vc-next-action) 168 (define-key vc-prefix-map "v" 'vc-next-action)
181 (define-key vc-prefix-map "=" 'vc-diff) 169 (define-key vc-prefix-map "d" 'vc-directory)
182 )) 170 ))
183 171
184(provide 'vc-hooks) 172(provide 'vc-hooks)
185 173
186;;; vc-hooks.el ends here 174;;; vc-hooks.el ends here
175