(defface opentaxsolver-comment-face '((t (:inherit font-lock-comment-face))) "Comments" :group 'opentaxsolver-faces) (defface opentaxsolver-form-title-face '((t (:foreground "green" :weight bold))) "Form title") (defface opentaxsolver-thousands-face '((t (:foreground "yellow" :weight bold))) "Digits signifying at least thousands") (defface opentaxsolver-cents-face '((t (:foreground "gray"))) "Digits standing for fractions of dollars") (defface opentaxsolver-line-face '((t (:foreground "light slate blue" :weight bold))) "Titles of lines") (setq opentaxsolver-font-lock-keywords `(("Title\\(.*\\)$" . 'opentaxsolver-form-title-face) ("^ *[[:alpha:]][[:alnum:]_+?#:/-]+" . 'opentaxsolver-line-face) ("\\([0-9]+\\)[0-9]\\{3\\}\\." (1 'opentaxsolver-thousands-face)) ("\\.[0-9]\\{1,2\\}" . 'opentaxsolver-cents-face))) (define-derived-mode opentaxsolver-mode prog-mode "OTS" "Major mode for editing OpenTaxSolver files." ;; OTS has issues parsing some lines with no whitespace at their end; thus, we ;; do not remove trailing whitespace in OTS files (setq-local whitespace-style '(face)) (setq font-lock-defaults '(opentaxsolver-font-lock-keywords)) ;; { } is typically comments (... except for cap gains share descriptions, ;; which do end up in the final results, but we'll ignore this for the time ;; being.) (modify-syntax-entry ?{ "<" opentaxsolver-mode-syntax-table) (modify-syntax-entry ?} ">" opentaxsolver-mode-syntax-table)) (add-to-list 'auto-mode-alist '("US_1040_.*" . opentaxsolver-mode)) (provide 'opentaxsolver-mode)