-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhyperlist-mode.el
116 lines (92 loc) · 3.69 KB
/
hyperlist-mode.el
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
;;; hyperlist-mode.el --- A major-mode for viewing Hyperlists -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Wojciech Siewierski
;; Author: Wojciech Siewierski
;; URL: https://github.com/vifon/hyperlist-mode
;; Keywords: outlines
;; Version: 0.9
;; Package-Requires: ((emacs "24"))
;; 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 <https://www.gnu.org/licenses/>.
;;; Commentary:
;; A major-mode for viewing Hyperlists by Geir Isene.
;;
;; See: https://isene.org/hyperlist/
;;; Code:
(defgroup hyperlist nil
"Hyperlist mode."
:group 'outlines)
(defgroup hyperlist-faces nil
"Faces in Hyperlist mode."
:group 'hyperlist)
(defface hyperlist-toplevel
'((t :inherit bold))
"Face for the Hyperlist toplevel headings.")
(defface hyperlist-condition
'((((background light)) :foreground "#008000")
(((background dark)) :foreground "#33a333"))
"Face for the Hyperlist [conditions].")
(defface hyperlist-operator
'((((background light)) :foreground "#000080")
(((background dark)) :foreground "#8C8CFF"))
"Face for the Hyperlist OPERATORS: (capitals + colon).")
(defface hyperlist-tag
'((((background light)) :foreground "#800000")
(((background dark)) :foreground "#ff7777"))
"Face for the Hyperlist tags: (string + colon).")
(defface hyperlist-hashtag
'((((background light)) :foreground "#999900")
(((background dark)) :foreground "#dddd00"))
"Face for the Hyperlist #hashtags.")
(defface hyperlist-quote
'((((background light)) :foreground "#006666")
(((background dark)) :foreground "#33aaaa"))
"Face for the Hyperlist \"quotes\".")
(defface hyperlist-paren
'((t :inherit hyperlist-quote))
"Face for the Hyperlist (parens).")
(defface hyperlist-ref
'((((background light)) :foreground "#660066")
(((background dark)) :foreground "#dd00dd"))
"Face for the Hyperlist (parens).")
(defface hyperlist-stars
'((((background light)) :foreground "#ddd")
(((background dark)) :foreground "#444"))
"Face for the leading outline stars in Hyperlists.")
(defvar hyperlist-mode-font-lock-keywords
'(("^\\*\\([^*].*\\)" 1 'hyperlist-toplevel)
("\\[[^]]*\\]" . 'hyperlist-condition)
("\"[^\"]*\"" . 'hyperlist-quote)
("([^)]*)" . 'hyperlist-paren)
("<[^>]*>" . 'hyperlist-ref)
("\\b[A-Z]+:" . 'hyperlist-operator)
("^\\** *\\(?:\\[[^]]*\\] *\\)?\\(\\(?:\\w\\| \\)+\\w:\\)" 1 'hyperlist-tag)
("\\_<\\(#\\w+\\)\\_>" 1 'hyperlist-hashtag)
("^\\*+" . 'hyperlist-stars)
("\\W\\(\\*.*\\*\\)\\W" 1 'bold)
("\\W\\(/.*/\\)\\W" 1 'italic)
("\\W\\(_.*_\\)\\W" 1 'underline)))
(defvar hyperlist-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ?\" "\"" st)
(modify-syntax-entry ?\( "()" st)
(modify-syntax-entry ?\) ")(" st)
(modify-syntax-entry ?\< "(>" st)
(modify-syntax-entry ?\> ")<" st)
(modify-syntax-entry ?# "_ p" st)
st))
(define-derived-mode hyperlist-mode outline-mode "Hyperlist"
"A major-mode for Hyperlists by Geir Isene."
(setq font-lock-defaults
'(hyperlist-mode-font-lock-keywords
t)))
(add-to-list 'auto-mode-alist '("\\.hl\\'" . hyperlist-mode))
(provide 'hyperlist-mode)
;;; hyperlist-mode.el ends here