From 5ca7f75d004574b2ce4f94a6820546d3efef92fe Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 11 Sep 2024 02:12:47 +0200 Subject: Split contrib/ into emacs/ and vim/ --- contrib/emacs/mintage-mode.el | 26 ++++++++++++++++++++++++++ contrib/syntax/mintage.vim | 12 ------------ contrib/vim/syntax/mintage.vim | 13 +++++++++++++ 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 contrib/emacs/mintage-mode.el delete mode 100644 contrib/syntax/mintage.vim create mode 100644 contrib/vim/syntax/mintage.vim diff --git a/contrib/emacs/mintage-mode.el b/contrib/emacs/mintage-mode.el new file mode 100644 index 0000000..8cfe036 --- /dev/null +++ b/contrib/emacs/mintage-mode.el @@ -0,0 +1,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) diff --git a/contrib/syntax/mintage.vim b/contrib/syntax/mintage.vim deleted file mode 100644 index 6327f61..0000000 --- a/contrib/syntax/mintage.vim +++ /dev/null @@ -1,12 +0,0 @@ -if exists('b:current_syntax') - finish -endif -let b:current_syntax = 'mintage' - -syntax match Comment /^\s*#.*/ -syntax match Number /[0-9.]\+/ -syntax match Identifier /\v\d{4}(-\S+)?/ -syntax match String /"[^"]\{-}"/ - -" ‘Todo’ is semantically a better syntax group, but it looks bad -syntax match Error /?/ diff --git a/contrib/vim/syntax/mintage.vim b/contrib/vim/syntax/mintage.vim new file mode 100644 index 0000000..2b03b41 --- /dev/null +++ b/contrib/vim/syntax/mintage.vim @@ -0,0 +1,13 @@ +if exists('b:current_syntax') + finish +endif +let b:current_syntax = 'mintage' + +syntax match Comment /^\s*#.*/ +syntax match Number /[0-9.]\+/ +syntax match Identifier /\v\d{4}(-\S+)?/ +syntax match String /"[^"]\{-}"/ + + +" ‘Todo’ is semantically a better syntax group, but it looks bad +syntax match Error /?/ -- cgit v1.2.3