使用方法如下, 在c++ 源程序中输入:
newclass<SPC>
然后再 minibuffer 的提示中
Class Name: A
输入你的新类的名称 , 例子中的为 A 结果 newclass 变成了
class A { public: A(){ } virtual ~A(){ } A(const A& other) { } A& operator=( const A& other) { return *this; } };
配置方法, 在 .emacs 中
(define-abbrev-table c++-mode-abbrev-table)
'(("newclass" "" skeleton-new-class 1)))
(define-skeleton skeleton-new-class
"generate a class" "Class Name:"
> "\nclass " str
> "\n{"
> "\npublic:"
> "\n" str "(){"
> "\n}"
> "\nvirtual ~" str "(){"
> "\n}"
> "\n" str "(const " str "& other) {"
> "\n}"
> "\n" str "& operator=( const " str "& other) {"
> "\nreturn *this;"
> "\n}"
> "\n};"
)