;;; mmt-mode.el --- Support for MMT -*- lexical-binding: t; -*- ;; Copyright (C) 2021, 2022, 2023 Philip Kaludercic ;; Author: Philip Kaludercic ;; Keywords: languages ;; This program 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. ;; This program 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 this program. If not, see . ;;; Commentary: ;; Primitive Emacs support for MMT (https://uniformal.github.io/). ;;; Code: (eval-when-compile (require 'rx)) (defun mmt-mode-insert-bar () "Cycle MMT delimiters or insert one." (interactive) (cond ((looking-back "❚" nil) (replace-match "|")) ((looking-back "❙" nil) (replace-match "❚")) ((looking-back "|" nil) (replace-match "❙")) ((insert "|")))) ;;;###autoload (define-generic-mode mmt-mode '(("//" . "❙")) '("namespace" "fixmeta" "theory" "view" "type" "ur" "⟶" "include") `((,(rx (or "❘" "❙" "❚" ":" "#" "=")) 0 font-lock-builtin-face prepend) (,(rx ":" (group (+? anychar)) (or "❘" "❙" "=")) 1 font-lock-type-face prepend) (,(rx "#" (group (+? anychar)) (or "❘" "❙")) 1 font-lock-preprocessor-face prepend) (,(rx (or "=" "❙") (* space) (group (+ alnum))) 1 font-lock-function-name-face) (,(rx (or (: "{" (+? anychar) "}") (: "[" (+? anychar) "]"))) 0 font-lock-variable-name-face prepend) (,(rx (or "theory" "view") (+ space) (group (+ (or alnum "_")))) 1 font-lock-type-face)) '("\\.mmt\\'") (list (lambda () (local-set-key (kbd "C-") #'mmt-mode-insert-bar) (local-set-key (kbd "M-") "⟶") (set-input-method 'TeX)))) (provide 'mmt-mode) ;;; mmt-mode.el ends here