Commit 0bfb74a9 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

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

(vc-find-file-hook): USe unless.  Merge if and cond.
parent 1cca5da4
;;; vc-hooks.el --- resident support for version-control ;;; 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) ;; Author: FSF (see vc.el for full credits)
;; Maintainer: Andre Spiegel <spiegel@gnu.org> ;; 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. ;; This file is part of GNU Emacs.
...@@ -195,14 +196,15 @@ and else calls ...@@ -195,14 +196,15 @@ and else calls
(apply 'vc-default-FUN BACKEND ARGS) (apply 'vc-default-FUN BACKEND ARGS)
It is usually called via the `vc-call' macro." It is usually called via the `vc-call' macro."
(let ((f (cdr (assoc function-name (get backend 'vc-functions))))) (let ((f (assoc function-name (get backend 'vc-functions))))
(unless f (if f (setq f (cdr f))
(setq f (vc-find-backend-function backend function-name)) (setq f (vc-find-backend-function backend function-name))
(put backend 'vc-functions (cons (cons function-name f) (push (cons function-name f) (get backend 'vc-functions)))
(get backend 'vc-functions)))) (cond
(if (consp f) ((null f)
(apply (car f) (cdr f) args) (error "Sorry, %s is not implemented for %s" function-name backend))
(apply f args)))) ((consp f) (apply (car f) (cdr f) args))
(t (apply f args)))))
(defmacro vc-call (fun file &rest args) (defmacro vc-call (fun file &rest args)
;; BEWARE!! `file' is evaluated twice!! ;; BEWARE!! `file' is evaluated twice!!
...@@ -649,39 +651,39 @@ current, and kill the buffer that visits the link." ...@@ -649,39 +651,39 @@ current, and kill the buffer that visits the link."
(vc-file-clearprops buffer-file-name) (vc-file-clearprops buffer-file-name)
(cond (cond
((vc-backend buffer-file-name) ((vc-backend buffer-file-name)
;; Compute the state and put it in the modeline.
(vc-mode-line buffer-file-name) (vc-mode-line buffer-file-name)
(cond ((not vc-make-backup-files) (unless vc-make-backup-files
;; Use this variable, not make-backup-files, ;; Use this variable, not make-backup-files,
;; because this is for things that depend on the file name. ;; because this is for things that depend on the file name.
(make-local-variable 'backup-inhibited) (set (make-local-variable 'backup-inhibited) t)))
(setq backup-inhibited t))))
((let* ((link (file-symlink-p buffer-file-name)) ((let* ((link (file-symlink-p buffer-file-name))
(link-type (and link (vc-backend (file-chase-links link))))) (link-type (and link (vc-backend (file-chase-links link)))))
(if link-type (cond ((not link-type) nil) ;Nothing to do.
(cond ((eq vc-follow-symlinks nil) ((eq vc-follow-symlinks nil)
(message (message
"Warning: symbolic link to %s-controlled source file" link-type)) "Warning: symbolic link to %s-controlled source file" link-type))
((or (not (eq vc-follow-symlinks 'ask)) ((or (not (eq vc-follow-symlinks 'ask))
;; If we already visited this file by following ;; If we already visited this file by following
;; the link, don't ask again if we try to visit ;; the link, don't ask again if we try to visit
;; it again. GUD does that, and repeated questions ;; it again. GUD does that, and repeated questions
;; are painful. ;; are painful.
(get-file-buffer (get-file-buffer
(abbreviate-file-name (abbreviate-file-name
(file-chase-links buffer-file-name)))) (file-chase-links buffer-file-name))))
(vc-follow-link) (vc-follow-link)
(message "Followed link to %s" buffer-file-name) (message "Followed link to %s" buffer-file-name)
(vc-find-file-hook)) (vc-find-file-hook))
(t (t
(if (yes-or-no-p (format (if (yes-or-no-p (format
"Symbolic link to %s-controlled source file; follow link? " link-type)) "Symbolic link to %s-controlled source file; follow link? " link-type))
(progn (vc-follow-link) (progn (vc-follow-link)
(message "Followed link to %s" buffer-file-name) (message "Followed link to %s" buffer-file-name)
(vc-find-file-hook)) (vc-find-file-hook))
(message (message
"Warning: editing through the link bypasses version control") "Warning: editing through the link bypasses version control")
))))))))) ))))))))
(add-hook 'find-file-hook 'vc-find-file-hook) (add-hook 'find-file-hook 'vc-find-file-hook)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment