From 4b03365723a61dcad79e6df3052621382702f0b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 13 Jun 2022 23:48:27 +0200 Subject: xroff.el: Clean up. --- xroff.el | 55 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 15 deletions(-) (limited to 'xroff.el') diff --git a/xroff.el b/xroff.el index 54ae981..38272fd 100644 --- a/xroff.el +++ b/xroff.el @@ -1,10 +1,30 @@ +;;; xroff.el --- major mode for xroff -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 John Ankarström + +;; Author: John Ankarström +;; Created: 10 Jul 2022 +;; Version: 0.1 + +;; Keywords: troff groff +;; URL: http://ankarstrom.se/~john/etc/xroff + +;; This file is not part of GNU Emacs. + +;; Permission to use, copy, modify and/or distribute this software for +;; any purpose with or without fee is hereby granted. + +;;; Commentary: + +;; Major mode for xroff, an alternative, XML-like syntax for troff. + +;;; Code: + (defvar xroff--request-regexp (rx "<" - (group (+ (or "\\>" - (not (in "> "))))) - (group (* (or "\\>" - (not ?>)))) - ">")) + (group (+ (or "\\>" (not (in "> "))))) + (group (* (or "\\>" (not ?>)))) + ">")) (defvar xroff--single-escape-regexp (rx "\\" any)) @@ -23,34 +43,42 @@ "'" (* (not "'")) "'")) (defconst xroff-font-lock-keywords - `(("" + `(;; Comment. + ("" (0 font-lock-comment-face)) + ;; Request. (,(concat xroff--request-regexp) - (1 font-lock-keyword-face) - (2 font-lock-string-face)) + (1 font-lock-keyword-face keep) + (2 font-lock-string-face keep)) (,(concat "\\\\" xroff--request-regexp) (1 nil t) (2 nil t)) + ;; Parameter escape (e.g., \l'...'). (,xroff--parameter-escape-regexp (0 xroff-escape-face)) (,(concat "\\\\" xroff--parameter-escape-regexp) (0 nil t)) + ;; Identifier escape (e.g., \n(PI). (,xroff--identifier-escape-regexp (0 xroff-escape-face)) (,(concat "\\\\" xroff--identifier-escape-regexp) (0 nil t)) + ;; Single escape (e.g., \%). (,xroff--single-escape-regexp (0 xroff-escape-face)) (,(concat "\\\\" xroff--single-escape-regexp) (0 nil t)) + ;; Escaped backslash. (,"\\\\\\\\" (0 xroff-escape-face t)))) (defface xroff-escape '((t (:foreground "gray"))) - "`xroff-mode' face used to highlight backslash escapes.") + "`xroff-mode' face used to highlight backslash escapes." + :group 'xroff) (defvar xroff-escape-face 'xroff-escape) +;;;###autoload (define-derived-mode xroff-mode text-mode "Xroff" "Major mode for editing documents with xroff syntax." ;; A start or end tag by itself on a line separates a paragraph. @@ -65,14 +93,11 @@ (setq-local comment-end " -->") ;; (setq-local comment-indent-function 'sgml-comment-indent) ;; (setq-local comment-line-break-function 'sgml-comment-indent-new-line) - (setq-local skeleton-further-elements '((completion-ignore-case t))) - (setq-local skeleton-end-hook - (lambda () - (or (eolp) - (not (or (eq v2 '\n) (eq (car-safe v2) '\n))) - (newline-and-indent)))) (setq-local font-lock-defaults '((xroff-font-lock-keywords))) ;; (setq-local font-lock-multiline t) (setq-local comment-start-skip "