-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-html-mode.el
34 lines (30 loc) · 1.03 KB
/
setup-html-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
(defun skip-to-next-blank-line ()
(interactive)
(let ((inhibit-changing-match-data t))
(forward-char 1)
(unless (search-forward-regexp "^\\s *$" nil t)
(forward-char -1))))
(defun skip-to-previous-blank-line ()
(interactive)
(let ((inhibit-changing-match-data t))
(forward-char -1)
(unless (search-backward-regexp "^\\s *$" nil t)
(forward-char 1))))
(defun html-wrap-in-tag (beg end)
(interactive "r")
(let ((oneline? (= (line-number-at-pos beg) (line-number-at-pos end))))
(deactivate-mark)
(goto-char end)
(unless oneline? (newline-and-indent))
(insert "</div>")
(goto-char beg)
(insert "<div>")
(unless oneline? (newline-and-indent))
(indent-region beg (+ end 11))
(goto-char (+ beg 4))))
(eval-after-load "sgml-mode"
'(progn
(define-key html-mode-map (kbd "C-<down>") 'skip-to-next-blank-line)
(define-key html-mode-map (kbd "C-<up>") 'skip-to-previous-blank-line)
(define-key html-mode-map (kbd "C-c C-w") 'html-wrap-in-tag)))
(provide 'setup-html-mode)