changeset 82843:768766d373a7

* vc-git.el (vc-git-mode-line-string): New function.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 25 Aug 2007 20:04:26 +0000
parents c71eaf555f05
children a25b7156354b
files lisp/ChangeLog lisp/vc-git.el
diffstat 2 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Aug 25 17:06:06 2007 +0000
+++ b/lisp/ChangeLog	Sat Aug 25 20:04:26 2007 +0000
@@ -1,3 +1,7 @@
+2007-08-25  Alexandre Julliard  <julliard@winehq.org>
+
+	* vc-git.el (vc-git-mode-line-string): New function.
+
 2007-08-25  Alan Mackenzie  <acm@muc.de>
 
 	* progmodes/cc-langs.el (c-other-decl-block-key-in-symbols-alist):
--- a/lisp/vc-git.el	Sat Aug 25 17:06:06 2007 +0000
+++ b/lisp/vc-git.el	Sat Aug 25 20:04:26 2007 +0000
@@ -57,7 +57,7 @@
 ;; - latest-on-branch-p (file)			   NOT NEEDED
 ;; * checkout-model (file)			   OK
 ;; - workfile-unchanged-p (file)		   OK
-;; - mode-line-string (file)			   NOT NEEDED
+;; - mode-line-string (file)			   OK
 ;; - dired-state-info (file)			   OK
 ;; STATE-CHANGING FUNCTIONS
 ;; * create-repo ()				   OK
@@ -208,6 +208,18 @@
          (string-match "[0-7]\\{6\\} blob \\([0-9a-f]\\{40\\}\\)\t[^\0]+\0" head)
          (string= (car (split-string sha1 "\n")) (match-string 1 head)))))
 
+(defun vc-git-mode-line-string (file)
+  "Return string for placement into the modeline for FILE."
+  (let* ((branch (vc-git-workfile-version file))
+         (def-ml (vc-default-mode-line-string 'Git file))
+         (help-echo (get-text-property 0 'help-echo def-ml)))
+    (if (zerop (length branch))
+        (propertize
+         (concat def-ml "!")
+         'help-echo (concat help-echo "\nNo current branch (detached HEAD)"))
+      (propertize def-ml
+                  'help-echo (concat help-echo "\nCurrent branch: " branch)))))
+
 (defun vc-git-dired-state-info (file)
   "Git-specific version of `vc-dired-state-info'."
   (let ((git-state (vc-state file)))