1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00

(vc-call-backend): Give better error message when backend function is missing.

(vc-find-file-hook): USe unless.  Merge if and cond.
This commit is contained in:
Stefan Monnier 2003-05-31 17:43:28 +00:00
parent 1cca5da4fa
commit 0bfb74a943

View File

@ -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 @@ and else calls
(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 @@ current, and kill the buffer that visits the link."
(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)