forked from edavis10/emacs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
todo-list-mode.el
172 lines (144 loc) · 6.41 KB
/
todo-list-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
;;; todo-list-mode.el -- Major mode for highlighting a numbered todo list.
;; Copyright (C) 2009 Billy Lamberta
;; Author: Billy Lamberta <[email protected]>
;; Created: Jan 2009
;; Keywords: todo
;; URL: http://www.lamberta.org/blog/todo-list-mode
;; $Revision: 0.01 $
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Description:
;; Major mode for highlighting a numbered todo list.
;; This is a simple mode that uses a number of regexp's to
;; determine the color of a particular line based on the assigned
;; priority number.
;; The format for a given line is:
;; number (0-4), [optional lower case letter], tab, task text
;; It will also recognize hash style comments to the end of the line.
;; Example:
;; 0 This is a header line that will always be on top.
;; 1 Run around the block.
;; 1 Wash behind my ears.
;; 2a Learn some more Lisp.
;; 2b Fly a kite.
;; 3 Say I'm sorry.
;; 4 Peace to all mankind.
;; Faces are defined in this file below. Feel free to add more or
;; change the colors to suit your own style.
;; Sort on the assigned priority number:
;; Select a region (C-x h for entire buffer), M-x sort-lines
;;; Code:
(setq todo-list-highlight-regexps '(
;;regexp keyword matches:
;;beg line|number|letter?|tab|any char|any chars|end line
("^0[a-z]? .*$" 0 todo-list-zero-face t)
("^1[a-z]? .*$" 0 todo-list-one-face t)
("^2[a-z]? .*$" 0 todo-list-two-face t)
("^3[a-z]? .*$" 0 todo-list-three-face t)
("^4[a-z]? .*$" 0 todo-list-four-face t)
("^A[a-z]? .*$" 0 todo-list-annual-face t)
("^D[a-z]? .*$" 0 todo-list-dream-face t)
("^L[a-z]? .*$" 0 todo-list-life-face t)
("^X .*$"0 todo-list-complete-face t)
("#.*$" 0 font-lock-comment-face t)
("#[\-_A-Za-z0-9]+" 0 todo-list-hashtag-face t)
))
(define-derived-mode todo-list-mode fundamental-mode
"todo-list-mode"
"Major mode for syntax color highlighting of a numbered todo list."
(setq font-lock-defaults '(todo-list-highlight-regexps))
)
;;
;;define custom faces for todo-list mode
;;
(defface todo-list-zero-face'(
(((class color) (background dark)) (:foreground "dark grey" :slant italic))
(((class color) (background light)) (:foreground "black" :slant italic))
(t (:bold t :italic t)))
"Todo-List mode face used for level 0 task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-zero-face 'todo-list-zero-face
"Todo-List mode face used for level 0 task.")
(defface todo-list-one-face'(
(((class color) (background dark)) (:foreground "Red"))
(((class color) (background light)) (:foreground "Red"))
(t (:bold t :italic t)))
"Todo-List mode face used for level 1 task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-one-face 'todo-list-one-face
"Todo-List mode face used for level 1 task.")
(defface todo-list-two-face'(
(((class color) (background dark)) (:foreground "IndianRed1"))
(((class color) (background light)) (:foreground "Red3"))
(t (:bold t :italic t)))
"Todo-List mode face used for level 2 task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-two-face 'todo-list-two-face
"Todo-List mode face used for level 2 task.")
(defface todo-list-three-face'(
(((class color) (background dark)) (:foreground "white"))
(((class color) (background light)) (:foreground "white"))
(t (:bold t :italic t)))
"Todo-List mode face used for level 3 task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-three-face 'todo-list-three-face
"Todo-List mode face used for level 3 task.")
(defface todo-list-four-face'(
(((class color) (background dark)) (:foreground "grey60"))
(((class color) (background light)) (:foreground "grey60"))
(t (:bold t :italic t)))
"Todo-List mode face used for level 4 task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-four-face 'todo-list-four-face
"Todo-List mode face used for level 4 task.")
(defface todo-list-annual-face'(
(((class color) (background dark)) (:foreground "#00ff00" :bold t))
(((class color) (background light)) (:foreground "#00ff00" :bold t))
(t (:bold t :italic t)))
"Todo-List mode face used for annual level task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-annual-face 'todo-list-annual-face
"Todo-List mode face used for annual level task.")
(defface todo-list-dream-face'(
(((class color) (background dark)) (:foreground "#00ff00" :italic t))
(((class color) (background light)) (:foreground "#00ff00" :italic t))
(t (:bold t :italic t)))
"Todo-List mode face used for dream level task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-dream-face 'todo-list-dream-face
"Todo-List mode face used for dream level task.")
(defface todo-list-life-face'(
(((class color) (background dark)) (:foreground "#00ff00"))
(((class color) (background light)) (:foreground "#00ff00"))
(t (:bold t :italic t)))
"Todo-List mode face used for life task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-life-face 'todo-list-life-face
"Todo-List mode face used for life task.")
(defface todo-list-complete-face'(
(((class color) (background dark)) (:foreground "gray22"))
(((class color) (background light)) (:foreground "gray75"))
(t (:bold t :italic t)))
"Todo-List mode face used for completed task."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-complete-face 'todo-list-complete-face
"Todo-List mode face used for completed task.")
(defface todo-list-hashtag-face'(
(((class color) (background dark)) (:foreground "#4186be" :underline t))
(((class color) (background light)) (:foreground "#4186be" :underline t))
(t (:bold t :italic t :underline t)))
"Todo-List mode face used by hashtags."
:group 'todo-list-mode-highlighting-faces)
(defvar todo-list-hashtag-face 'todo-list-hashtag-face
"Todo-List mode face used by hashtags.")
(provide 'todo-list-mode)