|
| 1 | +;;; morganey-mode.el --- Major mode for editing Morganey files -*- lexical-binding: t -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2016 Alexey Kutepov <reximkut@gmail.com> |
| 4 | + |
| 5 | +;; Author: Alexey Kutepov <reximkut@gmail.com> |
| 6 | +;; Maintainer: Alexey Kutepov <reximkut@gmail.com> |
| 7 | +;; URL: https://github.com/morganey-lang/morganey-mode |
| 8 | +;; Version: 0.0.1 |
| 9 | +;; Package-Requires: ((emacs "24.4")) |
| 10 | + |
| 11 | +;; Permission is hereby granted, free of charge, to any person |
| 12 | +;; obtaining a copy of this software and associated documentation |
| 13 | +;; files (the "Software"), to deal in the Software without |
| 14 | +;; restriction, including without limitation the rights to use, copy, |
| 15 | +;; modify, merge, publish, distribute, sublicense, and/or sell copies |
| 16 | +;; of the Software, and to permit persons to whom the Software is |
| 17 | +;; furnished to do so, subject to the following conditions: |
| 18 | + |
| 19 | +;; The above copyright notice and this permission notice shall be |
| 20 | +;; included in all copies or substantial portions of the Software. |
| 21 | + |
| 22 | +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 23 | +;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 24 | +;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 25 | +;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 26 | +;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 27 | +;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 28 | +;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 29 | +;; SOFTWARE. |
| 30 | + |
| 31 | +;;; Commentary: |
| 32 | + |
| 33 | +;; Major mode for editing source files written in Morganey programming |
| 34 | +;; language: https://github.com/morganey-lang/Morganey |
| 35 | + |
| 36 | +;;; Code: |
| 37 | + |
| 38 | +(defconst morganey--keywords |
| 39 | + (list (cons "load" font-lock-keyword-face) |
| 40 | + (cons ":=" font-lock-keyword-face) |
| 41 | + (cons "\\\\" font-lock-keyword-face) |
| 42 | + (cons "λ" font-lock-keyword-face))) |
| 43 | + |
| 44 | +(defconst morganey--syntax-table |
| 45 | + (let ((table (make-syntax-table))) |
| 46 | + (modify-syntax-entry ?/ ". 124" table) |
| 47 | + (modify-syntax-entry ?* ". 23b" table) |
| 48 | + (modify-syntax-entry ?\n ">" table) |
| 49 | + table)) |
| 50 | + |
| 51 | +(define-derived-mode morganey-mode prog-mode "Morganey" |
| 52 | + "Major mode for editing Morganey files" |
| 53 | + (set-syntax-table morganey--syntax-table) |
| 54 | + |
| 55 | + (setq font-lock-defaults '(morganey--keywords)) |
| 56 | + (make-local-variable 'comment-start) |
| 57 | + (setq comment-start "// ") |
| 58 | + (make-local-variable 'comment-end) |
| 59 | + (setq comment-end "") |
| 60 | + (make-local-variable 'comment-start-skip) |
| 61 | + (setq comment-start-skip "//[ \t]*") |
| 62 | + (make-local-variable 'comment-column) |
| 63 | + (setq comment-column 0)) |
| 64 | + |
| 65 | +;;;###autoload |
| 66 | +(add-to-list 'auto-mode-alist '("\\.mgn\\'" . morganey-mode)) |
| 67 | + |
| 68 | +(provide 'morganey-mode) |
| 69 | + |
| 70 | +;;; morganey-mode.el ends here |
0 commit comments