lundi 3 mai 2010

emacs 自动补全括号

;;-----------------------------------------------------------------------
;;自动补全括号
;;输入左边的括号,就会自动补全右边的部分.包括(), "", [] , {} , 等等。
(defun mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(?\" ? _ " \"")
(?\' ? _ " '")
(?\( ? _ " )")
(?\[ ? _ " ]")
(?\{ ? _ " } ")
))
(setq skeleton-pair t)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'f90-mode-hook 'mode-auto-pair)

Aucun commentaire:

Enregistrer un commentaire