Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: cc78cb206e
Fetching contributors…

Cannot retrieve contributors at this time

89 lines (71 sloc) 3.022 kB
(defun skip-to-next-blank-line ()
(let ((inhibit-changing-match-data t))
(skip-syntax-forward " >")
(unless (search-forward-regexp "^\\s *$" nil t)
(goto-char (point-max)))))
(defun skip-to-previous-blank-line ()
(let ((inhibit-changing-match-data t))
(skip-syntax-backward " >")
(unless (search-backward-regexp "^\\s *$" nil t)
(goto-char (point-min)))))
(defun html-wrap-in-tag (beg end)
(interactive "r")
(let ((oneline? (= (line-number-at-pos beg) (line-number-at-pos end))))
(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"
(define-key html-mode-map [remap forward-paragraph] 'skip-to-next-blank-line)
(define-key html-mode-map [remap backward-paragraph] 'skip-to-previous-blank-line)
(define-key html-mode-map (kbd "C-c C-w") 'html-wrap-in-tag)
(define-key html-mode-map (kbd "/") nil) ;; no buggy matching of slashes
(require 'tagedit)
;; paredit lookalikes
(define-key html-mode-map (kbd "s-<right>") 'tagedit-forward-slurp-tag)
(define-key html-mode-map (kbd "C-)") 'tagedit-forward-slurp-tag)
(define-key html-mode-map (kbd "s-<left>") 'tagedit-forward-barf-tag)
(define-key html-mode-map (kbd "C-}") 'tagedit-forward-barf-tag)
(define-key html-mode-map (kbd "M-r") 'tagedit-raise-tag)
(add-hook 'html-mode-hook (lambda () (tagedit-mode 1)))
;; no paredit equivalents
(define-key html-mode-map (kbd "s-k") 'tagedit-kill-attribute)
(define-key html-mode-map (kbd "s-<return>") 'tagedit-toggle-multiline-tag)))
(autoload 'zencoding-mode "zencoding-mode")
(autoload 'zencoding-expand-line "zencoding-mode")
(defun zencoding-expand-or-indent-for-tab ()
(unless (and (memq last-command yas/expand-only-for-last-commands)
(defun --setup-zencoding-mode ()
(add-to-list 'zencoding-self-closing-tags "hr")
(set (make-local-variable 'yas/fallback-behavior)
'(apply zencoding-expand-or-indent-for-tab)))
(add-hook 'sgml-mode-hook '--setup-zencoding-mode)
(eval-after-load 'zencoding-mode
(define-key zencoding-mode-keymap (kbd "C-j") nil)
(define-key zencoding-mode-keymap (kbd "<C-return>") nil)
(define-key zencoding-mode-keymap (kbd "C-c C-j") 'zencoding-expand-line)
(defun zencoding-transform-yas (ast)
(let ((zencoding-leaf-function (lambda () "$0")))
(zencoding-transform ast)))
(defun zencoding-indent (text)
"Indent the text"
(if text
(replace-regexp-in-string "\n" "\n " (concat "\n" text))
(diminish 'zencoding-mode)
(provide 'setup-html-mode)
Jump to Line
Something went wrong with that request. Please try again.