使用 ENSIME 时的 Scala 许可证横幅

发布于 2024-09-28 12:13:39 字数 141 浏览 10 评论 0原文

我正在尝试开始使用 ENSIME 通过 SBT 进行 Scala 开发。我应该如何管理许可证标头?我曾经在 Eclipse 中使用版权向导,看起来不错。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴者 2024-10-05 12:13:39

Emacs 有多种模板方法,这实际上取决于您的工作流程。对于版权,您可能只想向每个打开的新文件添加版权消息。上次我这样做是使用骨架包——现在有更新的包了。

也许是最容易设置的,但不是最灵活的。就是放置你的版权信息
到文件 scala.template 中并将该文件名添加到自动插入列表中。

(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]\\|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")

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

可以手动删除版权并调用自动插入。这可以通过宏来完成,也许在保存文件时调用。

对于更通用的版权消息自动更新,您可能需要查看版权包所采用的方法。使用此包检查版权可以在保存时使用 before-save-hook 执行。 http://www.gnu.org/software/emacs/manual /html_node/autotype/Copyrights.html

请参阅 http://www.emacswiki.org/emacs/自动文件头
也可以尝试在谷歌上搜索 auto-header.el 这也可能有帮助。

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.

小姐丶请自重 2024-10-05 12:13:39

我不认为 Emacs 有这样的东西,更不用说 ENSIME,但你可以轻松定义 abbrev 用于许可证标头并在需要时展开它。

这就是 Emacs 的伟大之处 - 它可能不完全有您所寻找的东西,但它肯定有您需要的一切。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文