From: Dan Nicolaescu Date: Sun, 22 Jul 2007 19:04:11 +0000 (+0000) Subject: * vc-cvs.el (vc-cvs-mode-line-string): Add support for tooltips X-Git-Tag: emacs-pretest-23.0.90~11797 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3a12f9f8301f2243bc40791369aa4bde90f8bfe5;p=emacs.git * 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 064e070cded..0ee2b68bf6d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2007-07-22 Dan Nicolaescu + + * 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 Sync with Tramp 2.1.10. diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el index 2daf2f72fba..452d9c16b19 100644 --- a/lisp/vc-cvs.el +++ b/lisp/vc-cvs.el @@ -258,14 +258,25 @@ See also variable `vc-cvs-sticky-date-format-string'." 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'." diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index cbbfd8e7e22..cd5d8db7b0f 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -719,12 +719,29 @@ Before doing that, check if there are any old backups and get rid of them." 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 @@ This function assumes that the file is registered." ;; 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. diff --git a/lisp/vc.el b/lisp/vc.el index 2d33bdf1eef..d12a6c20eee 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -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) ;;