Friday, 24 March 2006

Emacs-fu

Emacs just rules. Lately, I've been trying to figure out how abbrev mode can be used nicely with skeletons. The following is a skeleton to produce a Java "main" method and is due toJorgen Shaefer:

(add-hook 'java-mode-hook 'fc-java-setup)


(defun fc-java-setup ()
(c-set-style "k&r")
(setq c-basic-offset 4)
(c-set-offset 'case-label '+)
(define-abbrev java-mode-abbrev-table "main" "" 'java-main-skeleton)
(define-skeleton java-main-skeleton
"Insert a Java main function."
> "public static void main (String[] args) {\n"
_ "\n"
"}" >)
)

technorati tags: , , , ,

No comments:

Post a Comment