changeset 93333:53eee5c271f4

* vc.el: Add new backend function 'status-extra-headers. (vc-default-status-extra-headers): New function. (vc-status-headers): Call 'status-extra-headers. Add colors. * vc-git.el (vc-git-status-extra-headers): New function.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 28 Mar 2008 03:50:26 +0000
parents bf0cafc88be5
children c598ce296aea
files lisp/ChangeLog lisp/vc-git.el lisp/vc.el
diffstat 3 files changed, 33 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Mar 28 02:47:59 2008 +0000
+++ b/lisp/ChangeLog	Fri Mar 28 03:50:26 2008 +0000
@@ -1,3 +1,11 @@
+2008-03-28  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el: Add new backend function 'status-extra-headers.
+	(vc-default-status-extra-headers): New function.
+	(vc-status-headers): Call 'status-extra-headers.  Add colors.
+
+	* vc-git.el (vc-git-status-extra-headers): New function.
+
 2008-03-28  Glenn Morris  <rgm@gnu.org>
 
 	* calendar/cal-menu.el (cal-menu-holidays-menu)
--- a/lisp/vc-git.el	Fri Mar 28 02:47:59 2008 +0000
+++ b/lisp/vc-git.el	Fri Mar 28 03:50:26 2008 +0000
@@ -264,6 +264,18 @@
        `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer)))
     (current-buffer)))
 
+(defun vc-git-status-extra-headers (dir)
+  (let ((str (with-output-to-string
+               (with-current-buffer standard-output
+                 (vc-git--out-ok "symbolic-ref" "HEAD")))))
+    (concat
+     (propertize "Branch     : " 'face 'font-lock-type-face)
+     (propertize 
+      (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
+	  (match-string 2 str)
+	"not (detached HEAD)")
+       'face 'font-lock-variable-name-face))))
+
 ;;; STATE-CHANGING FUNCTIONS
 
 (defun vc-git-create-repo ()
--- a/lisp/vc.el	Fri Mar 28 02:47:59 2008 +0000
+++ b/lisp/vc.el	Fri Mar 28 03:50:26 2008 +0000
@@ -182,6 +182,10 @@
 ;;   change.
 ;;   This is a replacement for dir-state.
 ;;
+;; - status-extra-headers (dir)
+;;   
+;;   Return a string that will be added to the *vc-status* buffer header.
+;;
 ;; * working-revision (file)
 ;;
 ;;   Return the working revision of FILE.  This is the revision fetched
@@ -2655,11 +2659,17 @@
 
 (defvar vc-status nil)
 
+(defun vc-default-status-extra-headers (backend dir)
+  "Extra      : Add backend specific headers here")
+
 (defun vc-status-headers (backend dir)
   (concat
-   (format "VC backend : %s\n" backend)
-   "Repository : The repository goes here\n"
-   (format "Working dir: %s\n" dir)))
+   (propertize "VC backend : " 'face 'font-lock-type-face)
+   (propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face)
+   (propertize "Working dir: " 'face 'font-lock-type-face)
+   (propertize (format "%s\n" dir) 'face 'font-lock-variable-name-face)
+   (vc-call-backend backend 'status-extra-headers dir)
+   "\n"))
 
 (defun vc-status-printer (fileentry)
   "Pretty print FILEENTRY."