使用ENSIME时Scala的许可横幅 [英] License banners for Scala when using ENSIME

查看:107
本文介绍了使用ENSIME时Scala的许可横幅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图用SBT开始使用ENSIME进行Scala开发。如何管理许可证标题?我曾经在Eclipse中使用版权向导,似乎很好。

$ b $ Emacs有很多方法可以模板,这取决于你的工作流程。对于版权,您可能只想向每个打开的新文件添加版权信息。最后一次我用这个骨架包装---现在有更新的包。



也许最容易设置,但不是最灵活。将您的版权信息
放在一个文件scala.template中,并将该文件名添加到auto-insert-alist。

 (setq auto-insert-directory〜/ emacs.d / templates)
(add-to-list'auto-insert-alist'((\\.scala\\ 。Scala source)。scala.template))

scala.template是一个文件您要将其插入到每个新的scala文件中。为了自动执行新文件,需要将自动插入功能添加到find-file-hook中。

 (add -hook'find-file-hook'auto-insert)

这个机制非常强大,可能使用需要用户输入而不是简单文件的功能或模板。例如对于C ++头文件:

 ((\\.\\([Hh] \\\ \\ | hp \\\\\\\''C / C ++标头)
(upcase
(concat
(file-name-nondirectory
(file-name-sans-extension buffer-file-name))
_
(file-name-extension buffer-file-name)))
# ifndefstr n#definestr\\\
\\\
_\\\
\\\
#endif)

请参阅 http://www.emacswiki.org/emacs/AutoInsertMode# toc1



可以删除版权并手动调用自动插入。这可能是通过一个宏来完成的,也许在您保存文件时可能会被调用。



为了更多功能的版权信息自动更新,您可能需要查看所采用的方法版权包。使用这个软件包检查版权可以使用前保存挂钩进行保存。 http://www.gnu.org/software/emacs/manual /html_node/autotype/Copyrights.html



请参阅 http://www.emacswiki.org/emacs/AutomaticFileHeaders
还可以尝试googling for auto-header.el,这也可能有帮助。


I'm trying 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.

这篇关于使用ENSIME时Scala的许可横幅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆