03/09/21 20:34
XHTMLだと原則終了タグも書かなきゃならないので、タグ書きがめ
んどう。そこで、ミニバッファでタグの要素を打ち込んでカーソ
ル位置にタグを挿入するかんたんなS式
;; insert-htmltag
(defun insert-htmltag (str)
"Insert a pair of HTML tags.
Insert a pair of HTML tags read from
mini buffer at the cursor point."
(interactive "sInput tag: ")
(let ((elm (car (split-string str))))
(if (stringp elm)
(progn (insert "<"str"></"elm">")
(forward-char (- (+ 3 (length elm))))))))
(setq html-helper-mode-hook
'(lambda ()
(define-key html-helper-mode-map "\C-ct" 'insert-htmltag)))
たとえば、ミニバッファで
div class="hoge" と入力すると
<div class="hoge"></div> とカレントバッファに挿入され、カー
ソルもタグのあいだに移動ずみです。
HTML-helper-mode のキーバインドを覚えきらないんで(^_^;)