Initial revision
[bpt/emacs.git] / lisp / vc-hooks.el
index a079590..fc84af9 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
 ;; Version: 4.0
 
-;;     $Id: vc-hooks.el,v 1.2 1992/08/04 07:21:29 jimb Exp roland $    
+;;     $Id: vc-hooks.el,v 1.5 1992/10/20 18:43:33 rms Exp rms $        
 
 ;; This file is part of GNU Emacs.
 
@@ -65,29 +65,40 @@ the make-backup-files variable.  Otherwise, prevents backups being made.")
 ;;; actual version-control code starts here
 
 (defun vc-registered (file)
-  ;; Search for a master corresponding to the given file
-  (let ((dirname (or (file-name-directory file) ""))
-       (basename (file-name-nondirectory file)))
-    (catch 'found
-      (mapcar
-       (function (lambda (s)
-         (let ((trial (format (car s) dirname basename)))
-           (if (and (file-exists-p trial)
-                    ;; Make sure the file we found with name
-                    ;; TRIAL is not the source file itself.
-                    ;; That can happen with RCS-style names
-                    ;; if the file name is truncated
-                    ;; (e.g. to 14 chars).  See if either
-                    ;; directory or attributes differ.
-                    (or (not (string= dirname
-                                      (file-name-directory trial)))
-                        (not (equal
-                              (file-attributes file)
-                              (file-attributes trial)))))
-               (throw 'found (cons trial (cdr s)))))))
-       vc-master-templates)
-      nil)
-    ))
+  (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
+      (let ((dirname (or (file-name-directory file) ""))
+           (basename (file-name-nondirectory file)))
+       (catch 'found
+         (mapcar
+          (function (lambda (s)
+             (let ((trial (format (car s) dirname basename)))
+               (if (and (file-exists-p trial)
+                        ;; Make sure the file we found with name
+                        ;; TRIAL is not the source file itself.
+                        ;; That can happen with RCS-style names
+                        ;; if the file name is truncated
+                        ;; (e.g. to 14 chars).  See if either
+                        ;; directory or attributes differ.
+                        (or (not (string= dirname
+                                          (file-name-directory trial)))
+                            (not (equal
+                                  (file-attributes file)
+                                  (file-attributes trial)))))
+                   (throw 'found (cons trial (cdr s)))))))
+          vc-master-templates)
+         nil)))))
 
 (defun vc-backend-deduce (file)
   "Return the version-control type of a file, nil if it is not registered"
@@ -156,7 +167,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)
@@ -164,7 +175,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)