-
Notifications
You must be signed in to change notification settings - Fork 6
/
n3-mode.el
72 lines (57 loc) · 2.28 KB
/
n3-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
;;; n3-mode.el --- mode for Notation 3
;; Original work by 2003-2007 Hugo Haas <[email protected]>
;; re-worked and re-published by kurtjx (c) 2010 <[email protected]>
;; For documentation on Notation 3, see:
;; http://www.w3.org/DesignIssues/Notation3.html
;; This file 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, or (at your option)
;; any later version.
;; This file 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.
;; For a full copy of the GNU GPL see http://www.gnu.org/licenses.
;;; Comentary:
;; Goals:
;; - sytax highlighting
;; - completion
;; - indentation
;; What it does now:
;; - Syntax highlighting
;; - comment/uncomment block with M-;
;;; Code:
;; the command to comment/uncomment text
(defun n3-comment-dwim (arg)
"Comment or uncomment current line or region in a smart way.
For detail, see `comment-dwim'."
(interactive "*P")
(require 'newcomment)
(let ((deactivate-mark nil) (comment-start "#") (comment-end ""))
(comment-dwim arg)))
(setq n3-highlights
'(("\\(@prefix\\)\\>" 1 font-lock-keyword-face t)
("\\(a\\)\\>" 1 font-lock-keyword-face t)
("\\(\\S-*?:\\)" 1 font-lock-type-face t)
(":\\(.+?\\)[ ;.]" 1 font-lock-constant-face t)
("\\(<.*?>\\)" 1 font-lock-function-name-face t)
("\\(\\\".*?\\\"\\)" 1 font-lock-string-face t)
; Bug: some trailing characters are highlighted; restricting comments regexp
; ("\\(#.*\\)" 1 font-lock-comment-face t)
("^\\s-*\\(#.*\\)" 1 font-lock-comment-face t)
)
)
;;(define-generic-mode 'n3-mode
(define-derived-mode n3-mode fundamental-mode "n3-mode"
;; setup tab key not working :/
;;(setq c-basic-offset 4)
;; syntax highlighting
(setq font-lock-defaults '(n3-highlights))
;; modify the keymap M-; comments/uncomments region
(define-key n3-mode-map [remap comment-dwim] 'n3-comment-dwim)
;; comments: “# ...”
(modify-syntax-entry ?# "< b" n3-mode-syntax-table)
(modify-syntax-entry ?\n "> b" n3-mode-syntax-table)
;; description
"Mode for Notation 3 documents."
)