-
Notifications
You must be signed in to change notification settings - Fork 2
/
tj3-mode.el
111 lines (91 loc) · 3.27 KB
/
tj3-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
;;; tj3-mode.el --- major mode for editing TaskJuggler 3 files
;; 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 this program. If not, see <http://www.gnu.org/licenses/>.
;; Copyright (C) 2018 Christophe Rhodes <christophe@rhodes.io>
;; Author: Christophe Rhodes <christophe@rhodes.io>
;; URL: https://github.com/csrhodes/tj3-mode
;;; Commentary:
;; A major mode for editing TaskJuggler 3 source files.
;; TaskJuggler 3 is a project management tool taking descriptions of
;; resources, tasks and other project elements and attributes in plain
;; text. A command-line application performs task scheduling,
;; resource allocation, and constructs reports. For mor information
;; about TaskJuggler, visit <http://taskjuggler.org/>.
;; This major mode supports simple keyword-based font locking.
;;; Code:
(defgroup tj3 nil "Major mode for editing TaskJuggler 3 source files"
:tag "TaskJuggler 3"
:group 'languages)
(defvar tj3-iddef-properties
(list "account"
"resource"
"shift"
"task"))
(defvar tj3-properties
(list "account"
"auxdir"
"balance"
"copyright"
"flags"
"include"
"leaves"
"limits"
"macro"
"navigator"
"projectid"
"projectids"
"rate"
"resource"
"shift"
"statussheet"
;; supplement
"task"
"timesheet"
"vacation"))
(defvar tj3-reports
(list "accountreport"
"export"
"icalreport"
"nikureport"
"resourcereport"
"statussheetreport"
"tagfile"
"taskreport"
"textreport"
"timesheetreport"
"tracereport"))
(defvar tj3-font-lock-keywords
`(
(,(concat "^" (regexp-opt tj3-reports "\\(?1:") "\\(?:\\s-+\\(?2:\\w+\\)\\)?")
(1 'font-lock-keyword-face) (2 'font-lock-variable-name-face))
(,(concat "^\\s-*" (regexp-opt tj3-iddef-properties "\\(?1:") "\\(?:\\s-+\\(?2:\\w+\\)\\)?")
(1 'font-lock-keyword-face) (2 'font-lock-function-name-face))))
(defvar tj3-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?\" "\"" table)
(modify-syntax-entry ?{ "(}" table)
(modify-syntax-entry ?} "){" table)
(modify-syntax-entry ?\[ "(]" table)
(modify-syntax-entry ?\] ")[" table)
(modify-syntax-entry ?\( "()" table)
(modify-syntax-entry ?\) ")(" table)
(modify-syntax-entry ?# "<" table)
(modify-syntax-entry ?\n ">" table)
table))
(define-derived-mode tj3-mode prog-mode "tj3"
"Major mode for editing TaskJuggler 3 source files.
\\{tj3-mode-map}."
:group 'tj3
:syntax-table tj3-mode-syntax-table
(setq font-lock-defaults (list '(tj3-font-lock-keywords) nil)))
(add-to-list 'auto-mode-alist '("\\.tj[pi]\\'" . tj3-mode))
(provide 'tj3-mode)
;;; tj3-mode.el ends here