changeset 51370:a7a449bb9443

(vc-call-backend): Give better error message when backend function is missing. (vc-find-file-hook): USe unless. Merge if and cond.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 31 May 2003 17:43:28 +0000
parents 91b1fb194872
children 463499edca88
files lisp/vc-hooks.el
diffstat 1 files changed, 37 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/vc-hooks.el	Sat May 31 16:47:57 2003 +0000
+++ b/lisp/vc-hooks.el	Sat May 31 17:43:28 2003 +0000
@@ -1,11 +1,12 @@
 ;;; vc-hooks.el --- resident support for version-control
 
-;; Copyright (C) 1992,93,94,95,96,98,99,2000  Free Software Foundation, Inc.
+;; Copyright (C) 1992,93,94,95,96,98,99,2000,2003
+;;           Free Software Foundation, Inc.
 
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
 
-;; $Id: vc-hooks.el,v 1.149 2003/05/07 17:22:28 monnier Exp $
+;; $Id: vc-hooks.el,v 1.150 2003/05/08 17:45:08 monnier Exp $
 
 ;; This file is part of GNU Emacs.
 
@@ -195,14 +196,15 @@
     (apply 'vc-default-FUN BACKEND ARGS)
 
 It is usually called via the `vc-call' macro."
-  (let ((f (cdr (assoc function-name (get backend 'vc-functions)))))
-    (unless f
+  (let ((f (assoc function-name (get backend 'vc-functions))))
+    (if f (setq f (cdr f))
       (setq f (vc-find-backend-function backend function-name))
-      (put backend 'vc-functions (cons (cons function-name f)
-				       (get backend 'vc-functions))))
-    (if (consp f)
-	(apply (car f) (cdr f) args)
-      (apply f args))))
+      (push (cons function-name f) (get backend 'vc-functions)))
+    (cond
+     ((null f)
+      (error "Sorry, %s is not implemented for %s" function-name backend))
+     ((consp f)	(apply (car f) (cdr f) args))
+     (t		(apply f args)))))
 
 (defmacro vc-call (fun file &rest args)
   ;; BEWARE!! `file' is evaluated twice!!
@@ -649,39 +651,39 @@
     (vc-file-clearprops buffer-file-name)
     (cond
      ((vc-backend buffer-file-name)
+      ;; Compute the state and put it in the modeline.
       (vc-mode-line buffer-file-name)
-      (cond ((not vc-make-backup-files)
-	     ;; Use this variable, not make-backup-files,
-	     ;; because this is for things that depend on the file name.
-	     (make-local-variable 'backup-inhibited)
-	     (setq backup-inhibited t))))
+      (unless vc-make-backup-files
+	;; Use this variable, not make-backup-files,
+	;; because this is for things that depend on the file name.
+	(set (make-local-variable 'backup-inhibited) t)))
      ((let* ((link (file-symlink-p buffer-file-name))
 	     (link-type (and link (vc-backend (file-chase-links link)))))
-	(if link-type
-            (cond ((eq vc-follow-symlinks nil)
-                   (message
+	(cond ((not link-type) nil)	;Nothing to do.
+	      ((eq vc-follow-symlinks nil)
+	       (message
         "Warning: symbolic link to %s-controlled source file" link-type))
-                  ((or (not (eq vc-follow-symlinks 'ask))
-		       ;; If we already visited this file by following
-		       ;; the link, don't ask again if we try to visit
-		       ;; it again.  GUD does that, and repeated questions
-		       ;; are painful.
-		       (get-file-buffer
-			(abbreviate-file-name
-                         (file-chase-links buffer-file-name))))
+	      ((or (not (eq vc-follow-symlinks 'ask))
+		   ;; If we already visited this file by following
+		   ;; the link, don't ask again if we try to visit
+		   ;; it again.  GUD does that, and repeated questions
+		   ;; are painful.
+		   (get-file-buffer
+		    (abbreviate-file-name
+		     (file-chase-links buffer-file-name))))
 
-		   (vc-follow-link)
-		   (message "Followed link to %s" buffer-file-name)
-		   (vc-find-file-hook))
-                  (t
-                   (if (yes-or-no-p (format
+	       (vc-follow-link)
+	       (message "Followed link to %s" buffer-file-name)
+	       (vc-find-file-hook))
+	      (t
+	       (if (yes-or-no-p (format
         "Symbolic link to %s-controlled source file; follow link? " link-type))
-                       (progn (vc-follow-link)
-                              (message "Followed link to %s" buffer-file-name)
-                              (vc-find-file-hook))
-                     (message
+		   (progn (vc-follow-link)
+			  (message "Followed link to %s" buffer-file-name)
+			  (vc-find-file-hook))
+		 (message
         "Warning: editing through the link bypasses version control")
-                     )))))))))
+		 ))))))))
 
 (add-hook 'find-file-hook 'vc-find-file-hook)