summaryrefslogtreecommitdiffhomepage
path: root/contrib/emacs/mintage-mode.el
blob: 8cfe036848ed3529cfbe22b635b794fd45ddcc12 (plain) (blame)
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
;;; mintage-mode.el --- Major mode for mintage data files -*- lexical-binding: t; -*-

(defconst mintage--number  (rx (or digit ?.)))
(defconst mintage--string  (rx "\"" (*? (not "\"")) "\""))
(defconst mintage--unknown (rx ??))
(defconst mintage--comment (rx bol (* space) ?# (* any)))
(defconst mintage--year    (rx bol (= 4 digit) (? ?- (+ (not space)))))

(defun mintage--font-lock-keywords ()
  `((,mintage--year    . font-lock-constant-face)
    (,mintage--number  . 'font-lock-number-face)
    (,mintage--string  . font-lock-string-face)
    (,mintage--comment . font-lock-comment-face)
    (,mintage--unknown . font-lock-warning-face)))

;;;###autoload
(add-to-list 'auto-mode-alist (cons "mintages/[a-z]\\{2\\}\\'" 'mintage-mode))

;;;###autoload
(define-derived-mode mintage-mode conf-mode "Mintage"
  "Major mode for editing euro-cash.eu mintage files"
  (setq comment-start "#"
        comment-end "")
  (setq font-lock-defaults '(mintage--font-lock-keywords)))

(provide 'mintage-mode)