blob: 54ae981b71bb6bac50d111f297090da64427a29d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
(defvar xroff--request-regexp
(rx "<"
(group (+ (or "\\>"
(not (in "> ")))))
(group (* (or "\\>"
(not ?>))))
">"))
(defvar xroff--single-escape-regexp
(rx "\\" any))
(defvar xroff--identifier-escape-regexp
(rx "\\"
(any "FfgkmnOsYZ*$")
(? (any "+-"))
(or (not (any "([+-"))
(seq "(" any any)
(seq "[" (* (not "]")) "]"))))
(defvar xroff--parameter-escape-regexp
(rx "\\"
(any "ABbCDHhLlMNoRSVvwXxz")
"'" (* (not "'")) "'"))
(defconst xroff-font-lock-keywords
`(("<!--.*-->"
(0 font-lock-comment-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))
(,xroff--parameter-escape-regexp
(0 xroff-escape-face))
(,(concat "\\\\" xroff--parameter-escape-regexp)
(0 nil t))
(,xroff--identifier-escape-regexp
(0 xroff-escape-face))
(,(concat "\\\\" xroff--identifier-escape-regexp)
(0 nil t))
(,xroff--single-escape-regexp
(0 xroff-escape-face))
(,(concat "\\\\" xroff--single-escape-regexp)
(0 nil t))
(,"\\\\\\\\"
(0 xroff-escape-face t))))
(defface xroff-escape
'((t (:foreground "gray")))
"`xroff-mode' face used to highlight backslash escapes.")
(defvar xroff-escape-face 'xroff-escape)
(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 "<\\([^>]\\)+>")
(setq-local paragraph-separate "$\\|\\]>")
(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)))
;; (setq-local font-lock-multiline t)
(setq-local comment-start-skip "<!--[ \t]*")
(setq-local comment-end-skip "[ \t]*--[ \t\n]*>")
(visual-line-mode 1))
|