aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-05-07 17:20:29 +0000
committerStefan Monnier2003-05-07 17:20:29 +0000
commit5232a436d6f0179ab35fa418d23edc38ea21420a (patch)
treef49b3473cf60d84721802e170addfb9f5020ec4f
parent766f275a71d360b7a6ec7253d9a99685a7de5e05 (diff)
downloademacs-5232a436d6f0179ab35fa418d23edc38ea21420a.tar.gz
emacs-5232a436d6f0179ab35fa418d23edc38ea21420a.zip
Consistently use buffer-file-name variable rather than function.
(vc-handled-backends): Add SVN and MCVS. (vc-mode-line): Call vc-backend only once.
-rw-r--r--lisp/vc-hooks.el61
1 files changed, 31 insertions, 30 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index d57ec54f460..8978aba3077 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -5,7 +5,7 @@
5;; Author: FSF (see vc.el for full credits) 5;; Author: FSF (see vc.el for full credits)
6;; Maintainer: Andre Spiegel <spiegel@gnu.org> 6;; Maintainer: Andre Spiegel <spiegel@gnu.org>
7 7
8;; $Id: vc-hooks.el,v 1.146 2002/10/17 15:46:06 lektu Exp $ 8;; $Id: vc-hooks.el,v 1.147 2003/02/05 23:14:06 lektu Exp $
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -45,7 +45,7 @@
45(defvar vc-header-alist ()) 45(defvar vc-header-alist ())
46(make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header) 46(make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header)
47 47
48(defcustom vc-handled-backends '(RCS CVS SCCS) 48(defcustom vc-handled-backends '(RCS CVS SVN MCVS SCCS)
49 "*List of version control backends for which VC will be used. 49 "*List of version control backends for which VC will be used.
50Entries in this list will be tried in order to determine whether a 50Entries in this list will be tried in order to determine whether a
51file is under that sort of version control. 51file is under that sort of version control.
@@ -281,7 +281,7 @@ backend is tried first."
281(defun vc-backend (file) 281(defun vc-backend (file)
282 "Return the version control type of FILE, nil if it is not registered." 282 "Return the version control type of FILE, nil if it is not registered."
283 ;; `file' can be nil in several places (typically due to the use of 283 ;; `file' can be nil in several places (typically due to the use of
284 ;; code like (vc-backend (buffer-file-name))). 284 ;; code like (vc-backend buffer-file-name)).
285 (when (stringp file) 285 (when (stringp file)
286 (let ((property (vc-file-getprop file 'vc-backend))) 286 (let ((property (vc-file-getprop file 'vc-backend)))
287 ;; Note that internally, Emacs remembers unregistered 287 ;; Note that internally, Emacs remembers unregistered
@@ -487,7 +487,7 @@ in or out whenever you toggle the read-only flag."
487 (interactive "P") 487 (interactive "P")
488 (if (or (and (boundp 'vc-dired-mode) vc-dired-mode) 488 (if (or (and (boundp 'vc-dired-mode) vc-dired-mode)
489 ;; use boundp because vc.el might not be loaded 489 ;; use boundp because vc.el might not be loaded
490 (vc-backend (buffer-file-name))) 490 (vc-backend buffer-file-name))
491 (vc-next-action verbose) 491 (vc-next-action verbose)
492 (toggle-read-only))) 492 (toggle-read-only)))
493 493
@@ -533,7 +533,7 @@ Before doing that, check if there are any old backups and get rid of them."
533 ;; If the file on disk is still in sync with the repository, 533 ;; If the file on disk is still in sync with the repository,
534 ;; and version backups should be made, copy the file to 534 ;; and version backups should be made, copy the file to
535 ;; another name. This enables local diffs and local reverting. 535 ;; another name. This enables local diffs and local reverting.
536 (let ((file (buffer-file-name))) 536 (let ((file buffer-file-name))
537 (and (vc-backend file) 537 (and (vc-backend file)
538 (vc-up-to-date-p file) 538 (vc-up-to-date-p file)
539 (eq (vc-checkout-model file) 'implicit) 539 (eq (vc-checkout-model file) 'implicit)
@@ -545,7 +545,7 @@ Before doing that, check if there are any old backups and get rid of them."
545 ;; If the file in the current buffer is under version control, 545 ;; If the file in the current buffer is under version control,
546 ;; up-to-date, and locking is not used for the file, set 546 ;; up-to-date, and locking is not used for the file, set
547 ;; the state to 'edited and redisplay the mode line. 547 ;; the state to 'edited and redisplay the mode line.
548 (let ((file (buffer-file-name))) 548 (let ((file buffer-file-name))
549 (and (vc-backend file) 549 (and (vc-backend file)
550 (or (and (equal (vc-file-getprop file 'vc-checkout-time) 550 (or (and (equal (vc-file-getprop file 'vc-checkout-time)
551 (nth 5 (file-attributes file))) 551 (nth 5 (file-attributes file)))
@@ -568,28 +568,29 @@ Before doing that, check if there are any old backups and get rid of them."
568The value is set in the current buffer, which should be the buffer 568The value is set in the current buffer, which should be the buffer
569visiting FILE." 569visiting FILE."
570 (interactive (list buffer-file-name)) 570 (interactive (list buffer-file-name))
571 (if (not (vc-backend file)) 571 (let ((backend (vc-backend file)))
572 (setq vc-mode nil) 572 (if (not backend)
573 (setq vc-mode (concat " " (if vc-display-status 573 (setq vc-mode nil)
574 (vc-call mode-line-string file) 574 (setq vc-mode (concat " " (if vc-display-status
575 (symbol-name (vc-backend file))))) 575 (vc-call mode-line-string file)
576 ;; If the file is locked by some other user, make 576 (symbol-name backend))))
577 ;; the buffer read-only. Like this, even root 577 ;; If the file is locked by some other user, make
578 ;; cannot modify a file that someone else has locked. 578 ;; the buffer read-only. Like this, even root
579 (and (equal file (buffer-file-name)) 579 ;; cannot modify a file that someone else has locked.
580 (stringp (vc-state file)) 580 (and (equal file buffer-file-name)
581 (setq buffer-read-only t)) 581 (stringp (vc-state file))
582 ;; If the user is root, and the file is not owner-writable, 582 (setq buffer-read-only t))
583 ;; then pretend that we can't write it 583 ;; If the user is root, and the file is not owner-writable,
584 ;; even though we can (because root can write anything). 584 ;; then pretend that we can't write it
585 ;; This way, even root cannot modify a file that isn't locked. 585 ;; even though we can (because root can write anything).
586 (and (equal file (buffer-file-name)) 586 ;; This way, even root cannot modify a file that isn't locked.
587 (not buffer-read-only) 587 (and (equal file buffer-file-name)
588 (zerop (user-real-uid)) 588 (not buffer-read-only)
589 (zerop (logand (file-modes (buffer-file-name)) 128)) 589 (zerop (user-real-uid))
590 (setq buffer-read-only t))) 590 (zerop (logand (file-modes buffer-file-name) 128))
591 (force-mode-line-update) 591 (setq buffer-read-only t)))
592 (vc-backend file)) 592 (force-mode-line-update)
593 backend))
593 594
594(defun vc-default-mode-line-string (backend file) 595(defun vc-default-mode-line-string (backend file)
595 "Return string for placement in modeline by `vc-mode-line' for FILE. 596 "Return string for placement in modeline by `vc-mode-line' for FILE.
@@ -698,8 +699,8 @@ Used in `find-file-not-found-hooks'."
698 699
699(defun vc-kill-buffer-hook () 700(defun vc-kill-buffer-hook ()
700 "Discard VC info about a file when we kill its buffer." 701 "Discard VC info about a file when we kill its buffer."
701 (if (buffer-file-name) 702 (if buffer-file-name
702 (vc-file-clearprops (buffer-file-name)))) 703 (vc-file-clearprops buffer-file-name)))
703 704
704(add-hook 'kill-buffer-hook 'vc-kill-buffer-hook) 705(add-hook 'kill-buffer-hook 'vc-kill-buffer-hook)
705 706