-
Notifications
You must be signed in to change notification settings - Fork 0
/
html-conf.el
38 lines (33 loc) · 1008 Bytes
/
html-conf.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
(setq mhtml-tag-relative-indent 'ignore)
(add-hook 'html-mode-hook 'asc:init-html-mode)
(defun asc:init-html-mode ()
(idle-highlight-mode 1)
(add-hook 'before-save-hook 'delete-trailing-whitespace t t)
(setq c-basic-offset 2
tab-width 2))
(defun asc:html-tag ()
"Insert a tag appropriate after a keyword."
(let ((end (point))
tag)
(backward-word-strictly)
(setq tag (buffer-substring (point) end))
(insert "<")
(forward-word-strictly)
(insert ">")
(save-excursion
(insert "</" tag ">"))))
(defun asc:html-escape (start end)
"HTML escape the region.
Turns < & > → < & >."
(interactive "r")
(save-excursion
(goto-char start)
(let ((m (make-marker)))
(set-marker m end)
(while (< (point) m)
(case (char-after)
(?< (delete-char 1) (insert "<"))
(?& (delete-char 1) (insert "&"))
(?> (delete-char 1) (insert ">"))
(t (forward-char))))
(set-marker m nil))))