changeset 82027:1350ba0c0448

* vc-cvs.el (vc-cvs-mode-line-string): Add support for tooltips for branches and new files. * vc-hooks.el (vc-default-mode-line-string): Move mouse-face and local-map handling ... (vc-mode-line): ... here. Improve handling of help-echo. * vc.el (mode-line-string): Document help-echo usage.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 22 Jul 2007 19:04:11 +0000
parents db5b57e9fc79
children ff5079ea60b8
files lisp/ChangeLog lisp/vc-cvs.el lisp/vc-hooks.el lisp/vc.el
diffstat 4 files changed, 59 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Jul 22 16:50:21 2007 +0000
+++ b/lisp/ChangeLog	Sun Jul 22 19:04:11 2007 +0000
@@ -1,3 +1,14 @@
+2007-07-22  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-cvs.el (vc-cvs-mode-line-string): Add support for tooltips
+	for branches and new files.
+
+	* vc-hooks.el (vc-default-mode-line-string): Move mouse-face and
+	local-map handling ...
+	(vc-mode-line): ... here. Improve handling of help-echo.
+
+	* vc.el (mode-line-string): Document help-echo usage.
+
 2007-07-22  Michael Albinus  <michael.albinus@gmx.de>
 
 	Sync with Tramp 2.1.10.
--- a/lisp/vc-cvs.el	Sun Jul 22 16:50:21 2007 +0000
+++ b/lisp/vc-cvs.el	Sun Jul 22 19:04:11 2007 +0000
@@ -258,14 +258,25 @@
 Compared to the default implementation, this function does two things:
 Handle the special case of a CVS file that is added but not yet
 committed and support display of sticky tags."
-  (let ((sticky-tag (vc-file-getprop file 'vc-cvs-sticky-tag))
-	(string (if (string= (vc-workfile-version file) "0")
-		    ;; A file that is added but not yet committed.
-		    "CVS @@"
-		  (vc-default-mode-line-string 'CVS file))))
-    (if (zerop (length sticky-tag))
-	string
-      (concat string "[" sticky-tag "]"))))
+  (let* ((sticky-tag (vc-file-getprop file 'vc-cvs-sticky-tag))
+	 help-echo
+	 (string 
+	  (if (string= (vc-workfile-version file) "0")
+	      ;; A file that is added but not yet committed.
+	      (progn
+		(setq help-echo "Added file (needs commit) under CVS")
+		"CVS @@")
+	    (let ((def-ml (vc-default-mode-line-string 'CVS file)))
+	      (setq help-echo 
+		    (get-text-property 0 'help-echo def-ml))
+	      def-ml))))
+    (propertize 
+     (if (zerop (length sticky-tag))
+	 string
+       (setq help-echo (format "%s on the '%s' branch" 
+			       help-echo sticky-tag))
+       (concat string "[" sticky-tag "]"))
+     'help-echo help-echo)))
 
 (defun vc-cvs-dired-state-info (file)
   "CVS-specific version of `vc-dired-state-info'."
--- a/lisp/vc-hooks.el	Sun Jul 22 16:50:21 2007 +0000
+++ b/lisp/vc-hooks.el	Sun Jul 22 19:04:11 2007 +0000
@@ -719,12 +719,29 @@
 The value is set in the current buffer, which should be the buffer
 visiting FILE."
   (interactive (list buffer-file-name))
-  (let ((backend (vc-backend file)))
+  (let ((backend (vc-backend file))
+	ml-string ml-echo)
     (if (not backend)
 	(setq vc-mode nil)
-      (setq vc-mode (concat " " (if vc-display-status
-				    (vc-call mode-line-string file)
-				  (symbol-name backend))))
+      (setq ml-string (vc-call mode-line-string file))
+      (setq ml-echo (get-text-property 0 'help-echo ml-string))
+      (setq vc-mode
+	    (concat
+	     " "
+	     (if vc-display-status
+		 (propertize
+		  ml-string
+		  'mouse-face 'mode-line-highlight
+		  'help-echo 
+		  (concat (if ml-echo
+			      ml-echo
+			    (format "File under the %s version control system"
+				    backend))
+			  "\nmouse-1: Version Control menu")
+		  'local-map (let ((map (make-sparse-keymap)))
+			       (define-key map [mode-line down-mouse-1]
+				 'vc-menu-map) map))
+	       (symbol-name backend))))
       ;; If the file is locked by some other user, make
       ;; the buffer read-only.  Like this, even root
       ;; cannot modify a file that someone else has locked.
@@ -768,13 +785,10 @@
 	    ;; Not just for the 'edited state, but also a fallback
 	    ;; for all other states.  Think about different symbols
 	    ;; for 'needs-patch and 'needs-merge.
-	    (setq state-echo "Edited file")
+	    (setq state-echo "Locally modified file")
 	    (concat backend ":" rev)))
-     'mouse-face 'mode-line-highlight
-     'local-map (let ((map (make-sparse-keymap)))
-		  (define-key map [mode-line down-mouse-1] 'vc-menu-map) map)
      'help-echo (concat state-echo " under the " backend 
-			" version control system\nmouse-1: VC Menu"))))
+			" version control system"))))
 
 (defun vc-follow-link ()
   "If current buffer visits a symbolic link, visit the real file.
--- a/lisp/vc.el	Sun Jul 22 16:50:21 2007 +0000
+++ b/lisp/vc.el	Sun Jul 22 19:04:11 2007 +0000
@@ -166,9 +166,12 @@
 ;;
 ;; - mode-line-string (file)
 ;;
-;;   If provided, this function should return the VC-specific mode line
-;;   string for FILE.  The default implementation deals well with all
-;;   states that `vc-state' can return.
+;;   If provided, this function should return the VC-specific mode
+;;   line string for FILE. The returned string should have a
+;;   `help-echo' property which is the text to be displayed as a
+;;   tooltip when the mouse hovers over the VC entry on the mode-line.
+;;   The default implementation deals well with all states that
+;;   `vc-state' can return.
 ;;
 ;; - dired-state-info (file)
 ;;