diff options
author | John Ankarström <john@ankarstrom.se> | 2022-06-10 23:43:19 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-06-10 23:43:19 +0200 |
commit | be7d65efa1ca204f4aa78c054f25f612769eacee (patch) | |
tree | 8b8b7c53290d8ced7e68059d1c1728f32d58a21e /xroff.el | |
parent | c5696be8bfde10ab214feb13f84846afc8a7b149 (diff) | |
download | lightroff-be7d65efa1ca204f4aa78c054f25f612769eacee.tar.gz |
Add xroff.el.
Diffstat (limited to 'xroff.el')
-rw-r--r-- | xroff.el | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/xroff.el b/xroff.el new file mode 100644 index 0000000..8c3ecc2 --- /dev/null +++ b/xroff.el @@ -0,0 +1,49 @@ +(defvar xroff--request-regexp + (rx "<" + (group (+ (or "\\>" + (not (in "> "))))) + (group (* (or "\\>" + (not ?>)))) + ">")) + +(defconst xroff-font-lock-keywords + `(("<!--.*-->" + (0 font-lock-comment-face)) + ("\\\\\\(.\\)" + (1 font-lock-builtin-face)) + (,(concat xroff--request-regexp) + (1 font-lock-keyword-face) + (2 font-lock-string-face)) + (,(concat "\\\\" xroff--request-regexp) + (1 nil t) + (2 nil t)) + ;; ("<FS\\(?: \\(?:\\\\>\\|[^>]\\)*\\)?>\\(.*?\\)<FE\\(?: \\(?:\\\\>\\|[^>]\\)*\\)?>" + ;; 1 font-lock-doc-string) + )) + +(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. + ;; This is desirable because SGML discards a newline that appears + ;; immediately after a start tag or immediately before an end tag. + (setq-local paragraph-start (concat "[ \t]*$\\|\ +\[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>")) + (setq-local paragraph-separate (concat paragraph-start "$")) + (setq-local adaptive-fill-regexp "[ \t]*") + (add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t) + (setq-local indent-line-function 'sgml-indent-line) + (setq-local comment-start "<!-- ") + (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) nil t nil)) + ;; (setq-local font-lock-multiline t) + (setq-local comment-start-skip "<!--[ \t]*") + (setq-local comment-end-skip "[ \t]*--[ \t\n]*>") + (visual-line-mode 1)) |