Mercurial > emacs
comparison lisp/vc-hooks.el @ 82070:62454e8b7dd5
(vc-mode-line-map): New const.
(vc-mode-line): Use it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 23 Jul 2007 21:07:03 +0000 |
parents | b9e06163e85b |
children | b98604865ea0 492971a3f31f |
comparison
equal
deleted
inserted
replaced
82069:ed4cade83fcc | 82070:62454e8b7dd5 |
---|---|
714 (if (featurep 'vc) | 714 (if (featurep 'vc) |
715 ;; If VC is not loaded, then there can't be | 715 ;; If VC is not loaded, then there can't be |
716 ;; any VC Dired buffer to synchronize. | 716 ;; any VC Dired buffer to synchronize. |
717 (vc-dired-resynch-file file))))) | 717 (vc-dired-resynch-file file))))) |
718 | 718 |
719 (defconst vc-mode-line-map | |
720 (let ((map (make-sparse-keymap))) | |
721 (define-key map [mode-line down-mouse-1] 'vc-menu-map) | |
722 map)) | |
723 | |
719 (defun vc-mode-line (file) | 724 (defun vc-mode-line (file) |
720 "Set `vc-mode' to display type of version control for FILE. | 725 "Set `vc-mode' to display type of version control for FILE. |
721 The value is set in the current buffer, which should be the buffer | 726 The value is set in the current buffer, which should be the buffer |
722 visiting FILE." | 727 visiting FILE." |
723 (interactive (list buffer-file-name)) | 728 (interactive (list buffer-file-name)) |
724 (let ((backend (vc-backend file)) | 729 (let ((backend (vc-backend file))) |
725 ml-string ml-echo) | |
726 (if (not backend) | 730 (if (not backend) |
727 (setq vc-mode nil) | 731 (setq vc-mode nil) |
728 (setq ml-string (vc-call mode-line-string file)) | 732 (let* ((ml-string (vc-call mode-line-string file)) |
729 (setq ml-echo (get-text-property 0 'help-echo ml-string)) | 733 (ml-echo (get-text-property 0 'help-echo ml-string))) |
730 (setq vc-mode | 734 (setq vc-mode |
731 (concat | 735 (concat |
732 " " | 736 " " |
733 (if vc-display-status | 737 (if (null vc-display-status) |
734 (propertize | 738 (symbol-name backend) |
735 ml-string | 739 (propertize |
736 'mouse-face 'mode-line-highlight | 740 ml-string |
737 'help-echo | 741 'mouse-face 'mode-line-highlight |
738 (concat (if ml-echo | 742 'help-echo |
739 ml-echo | 743 (concat (or ml-echo |
740 (format "File under the %s version control system" | 744 (format "File under the %s version control system" |
741 backend)) | 745 backend)) |
742 "\nmouse-1: Version Control menu") | 746 "\nmouse-1: Version Control menu") |
743 'local-map (let ((map (make-sparse-keymap))) | 747 'local-map vc-mode-line-map))))) |
744 (define-key map [mode-line down-mouse-1] | |
745 'vc-menu-map) map)) | |
746 (symbol-name backend)))) | |
747 ;; If the file is locked by some other user, make | 748 ;; If the file is locked by some other user, make |
748 ;; the buffer read-only. Like this, even root | 749 ;; the buffer read-only. Like this, even root |
749 ;; cannot modify a file that someone else has locked. | 750 ;; cannot modify a file that someone else has locked. |
750 (and (equal file buffer-file-name) | 751 (and (equal file buffer-file-name) |
751 (stringp (vc-state file)) | 752 (stringp (vc-state file)) |