(vc-find-file-hook, vc-file-not-found-hook): Use add-hook to install.
[bpt/emacs.git] / lisp / vc-hooks.el
index 092084f..b258a40 100644 (file)
@@ -142,11 +142,11 @@ The value is set in the current buffer, which should be the buffer
 visiting FILE."
   (interactive (list buffer-file-name nil))
   (let ((vc-type (vc-backend-deduce file)))
-    (if vc-type
-        (setq vc-mode
-              (concat " " (or label (symbol-name vc-type))
-                     (if (and vc-rcs-status (eq vc-type 'RCS))
-                          (vc-rcs-status file)))))
+    (setq vc-mode
+         (and vc-type
+              (concat " " (or label (symbol-name vc-type))
+                      (if (and vc-rcs-status (eq vc-type 'RCS))
+                          (vc-rcs-status file)))))
     ;; force update of mode line
     (set-buffer-modified-p (buffer-modified-p))
     vc-type))
@@ -210,20 +210,20 @@ visiting FILE."
              (let* ((lock-pattern
                      (concat "[ \b\t\n\v\f\r]+\\("
                              (regexp-quote (user-login-name))
-                             ":\\|\\)"))
+                             ":\\)?"))
                     (locks
                      (save-restriction
                        (narrow-to-region (match-beginning 1) (match-end 1))
                        (goto-char (point-min))
                        (while (re-search-forward lock-pattern nil t)
-                         (replace-match " " t t))
+                         (replace-match (if (eobp) "" "-") t t))
                        (buffer-string)))
                     (status
                      (if (not (string-equal locks ""))
                          locks
                        (goto-char (point-min))
                        (if (looking-at "head[ \b\t\n\v\f\r]+\\([.0-9]+\\)")
-                           (concat " " (buffer-substring (match-beginning 1)
+                           (concat "-" (buffer-substring (match-beginning 1)
                                                          (match-end 1)))
                          " @@"))))
                ;; Clean work buffer.
@@ -242,9 +242,7 @@ visiting FILE."
        (make-local-variable 'make-backup-files)
        (setq make-backup-files nil))))
 
-(or (memq 'vc-find-file-hook find-file-hooks)
-    (setq find-file-hooks
-         (cons 'vc-find-file-hook find-file-hooks)))
+(add-hook 'find-file-hooks 'vc-find-file-hook)
 
 ;;; more hooks, this time for file-not-found
 (defun vc-file-not-found-hook ()
@@ -255,9 +253,7 @@ Returns t if checkout was successful, nil otherwise."
        (require 'vc)
        (not (vc-error-occurred (vc-checkout buffer-file-name))))))
 
-(or (memq 'vc-file-not-found-hook find-file-not-found-hooks)
-    (setq find-file-not-found-hooks
-         (cons 'vc-file-not-found-hook find-file-not-found-hooks)))
+(add-hook 'find-file-not-found-hooks 'vc-file-not-found-hook)
 
 ;;; Now arrange for bindings and autoloading of the main package.
 ;;; Bindings for this have to go in the global map, as we'll often