aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOscar Fuentes2014-11-16 05:40:10 +0100
committerOscar Fuentes2014-11-16 06:16:41 +0100
commitd409545938d636156b7d0a4ce889197d8fa03e65 (patch)
treeb99ba9ff4a5365a52f4db20949f4945cb190ff40
parent86009dd5d886f1101358990e4f8f69a5d1467eb8 (diff)
downloademacs-d409545938d636156b7d0a4ce889197d8fa03e65.tar.gz
emacs-d409545938d636156b7d0a4ce889197d8fa03e65.zip
Add faces for the VC modeline state indicator
* lisp/vc/vc-hooks.el: (vc-state-faces, vc-state-base-face) (vc-up-to-date-state, vc-needs-update-state) (vc-locked-state, vc-locally-added-state) (vc-conflict-state, vc-removed-state) (vc-missing-state, vc-edited-state): New faces. (vc-default-mode-line-string): Use them
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/vc/vc-hooks.el72
2 files changed, 84 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 634412ec989..cfb7900aa36 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12014-11-16 Oscar Fuentes <ofv@wanadoo.es>
2
3 Add faces for the VC modeline state indicator.
4 * lisp/vc/vc-hooks.el:
5 (vc-state-faces, vc-state-base-face)
6 (vc-up-to-date-state, vc-needs-update-state)
7 (vc-locked-state, vc-locally-added-state)
8 (vc-conflict-state, vc-removed-state)
9 (vc-missing-state, vc-edited-state):
10 New faces.
11 (vc-default-mode-line-string): Use them
12
12014-11-16 Stefan Monnier <monnier@iro.umontreal.ca> 132014-11-16 Stefan Monnier <monnier@iro.umontreal.ca>
2 14
3 * emacs-lisp/backquote.el (backquote-process): Optimize away the ,' case. 15 * emacs-lisp/backquote.el (backquote-process): Optimize away the ,' case.
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index df660d193e2..6359e19b80a 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -32,6 +32,69 @@
32 32
33(eval-when-compile (require 'cl-lib)) 33(eval-when-compile (require 'cl-lib))
34 34
35;; Faces
36
37(defgroup vc-state-faces nil
38 "Faces used in the mode line by the VC state indicator."
39 :group 'vc-faces
40 :group 'mode-line
41 :version "25.1")
42
43(defface vc-state-base-face
44 '((default :inherit mode-line))
45 "Base face for VC state indicator."
46 :group 'vc-faces
47 :group 'mode-line
48 :version "25.1")
49
50(defface vc-up-to-date-state
51 '((default :inherit vc-state-base-face))
52 "Face for VC modeline state when the file is up to date."
53 :version "25.1"
54 :group 'vc-faces)
55
56(defface vc-needs-update-state
57 '((default :inherit vc-state-base-face))
58 "Face for VC modeline state when the file needs update."
59 :version "25.1"
60 :group 'vc-faces)
61
62(defface vc-locked-state
63 '((default :inherit vc-state-base-face))
64 "Face for VC modeline state when the file locked."
65 :version "25.1"
66 :group 'vc-faces)
67
68(defface vc-locally-added-state
69 '((default :inherit vc-state-base-face))
70 "Face for VC modeline state when the file is locally added."
71 :version "25.1"
72 :group 'vc-faces)
73
74(defface vc-conflict-state
75 '((default :inherit vc-state-base-face))
76 "Face for VC modeline state when the file contains merge conflicts."
77 :version "25.1"
78 :group 'vc-faces)
79
80(defface vc-removed-state
81 '((default :inherit vc-state-base-face))
82 "Face for VC modeline state when the file was removed from the VC system."
83 :version "25.1"
84 :group 'vc-faces)
85
86(defface vc-missing-state
87 '((default :inherit vc-state-base-face))
88 "Face for VC modeline state when the file is missing from the file system."
89 :version "25.1"
90 :group 'vc-faces)
91
92(defface vc-edited-state
93 '((default :inherit vc-state-base-face))
94 "Face for VC modeline state when the file is up to date."
95 :version "25.1"
96 :group 'vc-faces)
97
35;; Customization Variables (the rest is in vc.el) 98;; Customization Variables (the rest is in vc.el)
36 99
37(defcustom vc-ignore-dir-regexp 100(defcustom vc-ignore-dir-regexp
@@ -800,33 +863,42 @@ This function assumes that the file is registered."
800 (let* ((backend-name (symbol-name backend)) 863 (let* ((backend-name (symbol-name backend))
801 (state (vc-state file backend)) 864 (state (vc-state file backend))
802 (state-echo nil) 865 (state-echo nil)
866 (face nil)
803 (rev (vc-working-revision file backend))) 867 (rev (vc-working-revision file backend)))
804 (propertize 868 (propertize
805 (cond ((or (eq state 'up-to-date) 869 (cond ((or (eq state 'up-to-date)
806 (eq state 'needs-update)) 870 (eq state 'needs-update))
807 (setq state-echo "Up to date file") 871 (setq state-echo "Up to date file")
872 (setq face 'vc-up-to-date-state)
808 (concat backend-name "-" rev)) 873 (concat backend-name "-" rev))
809 ((stringp state) 874 ((stringp state)
810 (setq state-echo (concat "File locked by" state)) 875 (setq state-echo (concat "File locked by" state))
876 (setq face 'vc-locked-state)
811 (concat backend-name ":" state ":" rev)) 877 (concat backend-name ":" state ":" rev))
812 ((eq state 'added) 878 ((eq state 'added)
813 (setq state-echo "Locally added file") 879 (setq state-echo "Locally added file")
880 (setq face 'vc-locally-added-state)
814 (concat backend-name "@" rev)) 881 (concat backend-name "@" rev))
815 ((eq state 'conflict) 882 ((eq state 'conflict)
816 (setq state-echo "File contains conflicts after the last merge") 883 (setq state-echo "File contains conflicts after the last merge")
884 (setq face 'vc-conflict-state)
817 (concat backend-name "!" rev)) 885 (concat backend-name "!" rev))
818 ((eq state 'removed) 886 ((eq state 'removed)
819 (setq state-echo "File removed from the VC system") 887 (setq state-echo "File removed from the VC system")
888 (setq face 'vc-removed-state)
820 (concat backend-name "!" rev)) 889 (concat backend-name "!" rev))
821 ((eq state 'missing) 890 ((eq state 'missing)
822 (setq state-echo "File tracked by the VC system, but missing from the file system") 891 (setq state-echo "File tracked by the VC system, but missing from the file system")
892 (setq face 'vc-missing-state)
823 (concat backend-name "?" rev)) 893 (concat backend-name "?" rev))
824 (t 894 (t
825 ;; Not just for the 'edited state, but also a fallback 895 ;; Not just for the 'edited state, but also a fallback
826 ;; for all other states. Think about different symbols 896 ;; for all other states. Think about different symbols
827 ;; for 'needs-update and 'needs-merge. 897 ;; for 'needs-update and 'needs-merge.
828 (setq state-echo "Locally modified file") 898 (setq state-echo "Locally modified file")
899 (setq face 'vc-edited-state)
829 (concat backend-name ":" rev))) 900 (concat backend-name ":" rev)))
901 'face face
830 'help-echo (concat state-echo " under the " backend-name 902 'help-echo (concat state-echo " under the " backend-name
831 " version control system")))) 903 " version control system"))))
832 904