diff --git a/ini-mode.el b/ini-mode.el new file mode 100644 index 0000000..c5a70b9 --- /dev/null +++ b/ini-mode.el @@ -0,0 +1,51 @@ +;;; ini-mode.el --- major mode for INI -*- lexical-binding:t -*- + +;; Copyright (C) 2024 Jeremy Baxter + +;; Author: Jeremy Baxter +;; Maintainer: Jeremy Baxter +;; Created: July 2024 +;; Keywords: ini + +;; This file is not part of GNU Emacs. + +;; ini-mode.el 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 of the License, or +;; (at your option) any later version. +;; +;; ini-mode.el 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 ini-mode.el. If not, see . + +;;; Commentary: + +;; ini-mode.el provides `ini-mode', an implementation of a simple +;; font-locking major mode for INI. + +;; TODO: fix section keys refusing to highlight initially + +;;; Code: + +(require 'font-lock) + +(defvar ini-mode-font-lock-keywords + '(("\\([#;].*$\\)" . font-lock-comment-face) + ("[ \t]*\\[\\(.+\\)\\]" . 'font-lock-type-face) + ("\\(^[^=]+\\)" . 'font-lock-keyword-face) + ("=\\(.+$\\)" 1 'font-lock-string-face)) + "Keywords for font locking in `ini-mode'.") + +(define-derived-mode ini-mode nil "INI" + "Major mode for editing INI." + + (font-lock-mode) + (font-lock-add-keywords nil ini-mode-font-lock-keywords)) + +(provide 'ini-mode) + +;;; ini-mode.el ends here