Merge today's change by eric with everybody else's
[bpt/emacs.git] / lisp / vc-hooks.el
index bbaf0cf..e2f6aa2 100644 (file)
@@ -3,9 +3,9 @@
 ;; Copyright (C) 1992 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
-;; Version: 4.0
+;; Version: 5.0
 
-;;     $Id: vc-hooks.el,v 1.3 1992/09/27 00:45:57 roland Exp rms $     
+;;     $Id: vc-hooks.el,v 1.8.1.1 1993/03/16 20:17:07 eggert Exp $     
 
 ;; This file is part of GNU Emacs.
 
@@ -51,6 +51,9 @@ the make-backup-files variable.  Otherwise, prevents backups being made.")
 ;; control state of a file is expensive to derive --- we don't
 ;; want to recompute it even on every find.
 
+(defmacro vc-error-occurred (&rest body)
+  (list 'condition-case nil (cons 'progn (append body '(nil))) '(error t)))
+
 (defvar vc-file-prop-obarray [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
   "Obarray for per-file properties.")
 
@@ -65,14 +68,16 @@ the make-backup-files variable.  Otherwise, prevents backups being made.")
 ;;; actual version-control code starts here
 
 (defun vc-registered (file)
-  (let (handler (handlers file-name-handler-alist))
-    (save-match-data
-     (while (and (consp handlers) (null handler))
-       (if (and (consp (car handlers))
-               (stringp (car (car handlers)))
-               (string-match (car (car handlers)) file))
-          (setq handler (cdr (car handlers))))
-       (setq handlers (cdr handlers))))
+  (let (handler handlers)
+    (if (boundp 'file-name-handler-alist)
+       (save-match-data
+         (setq handlers file-name-handler-alist)
+         (while (and (consp handlers) (null handler))
+           (if (and (consp (car handlers))
+                    (stringp (car (car handlers)))
+                    (string-match (car (car handlers)) file))
+               (setq handler (cdr (car handlers))))
+           (setq handlers (cdr handlers)))))
     (if handler
        (funcall handler 'vc-registered file)
       ;; Search for a master corresponding to the given file
@@ -96,8 +101,7 @@ the make-backup-files variable.  Otherwise, prevents backups being made.")
                                   (file-attributes trial)))))
                    (throw 'found (cons trial (cdr s)))))))
           vc-master-templates)
-         nil)
-       ))))
+         nil)))))
 
 (defun vc-backend-deduce (file)
   "Return the version-control type of a file, nil if it is not registered"
@@ -133,6 +137,9 @@ visiting FILE."
 
 ;;; install a call to the above as a find-file hook
 (defun vc-find-file-hook ()
+  ;; Recompute whether file is version controlled,
+  ;; if user has killed the buffer and revisited.
+  (vc-file-setprop buffer-file-name 'vc-backend nil)
   (if (and (vc-mode-line buffer-file-name) (not vc-make-backup-files))
       (progn
        (make-local-variable 'make-backup-files)
@@ -166,7 +173,7 @@ Returns t if checkout was successful, nil otherwise."
       (define-key global-map "\C-xv" vc-prefix-map)
       (define-key vc-prefix-map "a" 'vc-update-change-log)
       (define-key vc-prefix-map "c" 'vc-cancel-version)
-      (define-key vc-prefix-map "d" 'vc-diff)
+      (define-key vc-prefix-map "d" 'vc-directory)
       (define-key vc-prefix-map "h" 'vc-insert-headers)
       (define-key vc-prefix-map "i" 'vc-register)
       (define-key vc-prefix-map "l" 'vc-print-log)
@@ -174,7 +181,7 @@ Returns t if checkout was successful, nil otherwise."
       (define-key vc-prefix-map "s" 'vc-create-snapshot)
       (define-key vc-prefix-map "u" 'vc-revert-buffer)
       (define-key vc-prefix-map "v" 'vc-next-action)
-      (define-key vc-prefix-map "=" 'vc-directory)
+      (define-key vc-prefix-map "=" 'vc-diff)
       ))
 
 (provide 'vc-hooks)