I'm 开发者_如何学Ctrying to start using ENSIME for Scala development with SBT. How should I manage license headers? I used to use Copyright Wizard in Eclipse and that seemed fine.
Emacs has many ways to template, it really depends on what your workflow is. For copyright you might just want to add a copyright message to each new file opened. Last time I did this was with the skeleton package--- there are newer packages now.
Perhaps the easiest to set up, but not the most flexible. Is to place your copyright message into a file scala.template and add that filename to the auto-insert-alist.
(setq auto-insert-directory "~/emacs.d/templates")
(add-to-list 'auto-insert-alist '(( "\\.scala\\'" . "Scala source" ) . "scala.template"))
scala.template is a file with which you want to insert into each new scala file. To do this automatically for new files the auto-insert function needs to be added to the find-file-hook.
(add-hook 'find-file-hook 'auto-insert)
This mechanism is very powerful, it is possible to use functions or templates that require user input instead of a simple file. For example for C++ header files:
(("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "C / C++ header")
(upcase
(concat
(file-name-nondirectory
(file-name-sans-extension buffer-file-name))
"_"
(file-name-extension buffer-file-name)))
"#ifndef " str n "#define " str "\n\n" _ "\n\n#endif")
See http://www.emacswiki.org/emacs/AutoInsertMode#toc1
It is possible to remove the copyright and call auto-insert manually. This might be done via a macro, perhaps called when you save the file.
For more versatile auto-updating of copyright messages you might want to look at the approach taken by the copyright package. Checking the copyright using this package can be performed on save using the before-save-hook. http://www.gnu.org/software/emacs/manual/html_node/autotype/Copyrights.html
See http://www.emacswiki.org/emacs/AutomaticFileHeaders . Also try googling for auto-header.el which might help too.
I don't think Emacs has something like this, let alone ENSIME, but you can easily define an abbrev for the license header and expand it when you need it.
This is the greatness of Emacs - it might not have exactly what you look for, but it certainly has everything that you need.
精彩评论