対応する括弧を入れ込む

書いてると括弧が足りなくなったり打つのが面倒だったりしたので。
KusunokiProject - [xyzzy]
http://web.archive.org/web/20040408232830/http://www.haide.net/~tsukushi/xyzzy/
ここの括弧を挿入する奴を入れてみた。そのままだとToggleとかしないので、Toggleできるようにして

;------------------------------------------------------------
;対応する括弧を無理やり挿入
(defvar *parenthesis-complete-off* nil)
(defun toggle-parenthesis-complete()
  (interactive)
  (cond (*parenthesis-complete-off*
		 (add-hook '*post-command-hook* 'parenthesis-complete)
		 (setq *parenthesis-complete-off* nil)
		 (message "parenthesis-complete on"))
		(t
		 (delete-hook '*post-command-hook* 'parenthesis-complete)
		 (setq *parenthesis-complete-off* t)
		 (message "parenthesis-complete off"))
	))

(defun parenthesis-complete()
  (when (eq *this-command* 'self-insert-command)
	(cond ((looking-back "\(") (insert ")") (backward-char))
		  ((looking-back "\{") (insert "}") (backward-char))
		  ((looking-back "\[") (insert "]") (backward-char))
		  )
	))

始め(eq *this-command* 'self-insert-command)の意味がよく分からなかったが、一応キーバインドとかを考えているんだろうということで納得した。

■追記
書き間違えていたのを、一応治しておいた。