在 Emacs 中编辑 PHP 的好设置是什么?
我将在今年夏天为我的工作做一些 PHP 编辑,并且正在寻找一个有效的 Emacs 设置来编辑它.我已经在 Emacs 上投入了大量资金,所以切换到另一个编辑器是不值得的.
I'm going to be doing some PHP editing for my job this summer, and am looking for an effective Emacs setup for editing it. I'm already heavily invested in Emacs, so switching to another editor is not worthwhile.
现在,我有 nXhtml-mode,它提供了一个 PHP 模式带有语法高亮(至少有三种不同的语法)以及用于编辑嵌入 HTML 中的 PHP 的 MuMaMo.我刚开始使用 Auto-Complete 和 Anything 分别用于编程和一般 Emacs 内容.
Right now, I have nXhtml-mode, which provides a PHP mode with syntax highlighting (there are at least three different ones in the wild) as well as MuMaMo for editing PHP embedded in HTML. I just started using Auto-Complete and Anything for programming and general Emacs stuff, respectively.
我真正想要的是一种让 Emacs 真正理解项目的有效方法,而不仅仅是突出显示.Etags 看起来是个不错的选择,但看起来生成新标签的过程有点艰巨和手动(或至少不是隐形的).Etags 的好处在于它们可以与任何东西和自动完成很好地集成.其他可能的选择是 gtags(虽然我对安装非 elisp 文件犹豫不决,只是为了复杂性)、vtags 或 Semantic,我以前弄过它并且设置起来似乎很复杂,而且它看起来不支持 PHP.
What I'm really looking for is an effective way to get Emacs to really understand the project, beyond just highlighting. Etags looks like a good option, but it looks like the process for generating new tags is kind of arduous and manual (or at least not invisible). The nice thing about Etags is that they integrate well with Anything and Auto-Complete. Other potential options are gtags (though I'm hesitant to install non-elisp files, just for the complexity), vtags, or Semantic, which I've messed with before and seems complicated to set up, plus it doesn't look like it has support for PHP.
另一个选项是 Imenu,但它只适用于当前缓冲区,我想能够跳转到其他文件中的函数定义(最好使用Anything来完成名称).
Another option is Imenu, but it only works for the current buffer, and I would like to be able to jump to function definitions in other files (preferably using Anything for completion of the name).
我将从事的项目并不大(总共大约 30,000 行),所以 Etags 的开销可能不会是一个大问题,但如果有更好的,我宁愿不使用它解决方案.
The projects I will be working on are not that big (about 30,000 lines total), so the overhead of Etags probably won't be that big of an issue, but I'd rather not use it if there is a better solution.
那么您首选的 PHP 编辑系统是什么?
So what is your preferred PHP editing system?
推荐答案
除了你已经熟悉的功能,我建议你做以下.
In addition to features you are already familiar with, I suggest you the followings.
我不使用 ETag,但 SO 如何使用 emacs 以编程方式创建/更新 TAGS 文件.虽然没有发布好的答案,但它可能是获得想法的一个很好的切入点.
I do not use ETags, but there is a question already on SO How to programmatically create/update a TAGS file with emacs. No good answer was posted, though, but it may be a good entry point to get an idea.
Flymake 是一种进行动态语法检查的模式.它也支持 PHP.它会在您键入时立即提示语法错误.Emacs 23 附带的 Flymake 版本包含 PHP 支持.如果您有以前的版本,请查看 Sacha Chua 在 Emacs 和 PHP:使用 Flymake 进行即时语法检查.
Flymake is a mode to get on the fly syntax checking. It has support for PHP as well. It hints at syntax errors immediately as you type. The Flymake version shipped with Emacs 23 contains PHP support. If you have previous version, check Sacha Chua's post on Emacs and PHP: On-the-fly syntax checking with Flymake.
另一个有用的包是 Geben,它允许您调试脚本交互地.对于 PHP,您可以使用 XDebug.有关于如何做到这一点的详细教程,请参阅 用geben在emacs中调试php.
Another useful package is Geben that allows you to debug your scripts interactively. For PHP, you can use XDebug. There is a detailed tutorial on how to do that, see Debug php in emacs with geben.
PHP 模式有一个很好的功能,可以在您的网络浏览器中查找 PHP 手册中的函数定义(M-x php-search-documentation
或 C-c C-f
).您可以将其与 Emacs-W3M 结合使用,无需离开 Emacs 即可获取相关手册页.
PHP Mode has a nice feature to lookup the function's definition in PHP's manual in your web browser (M-x php-search-documentation
or C-c C-f
). You can combine it with Emacs-W3M to get the relevant manual page without leaving Emacs.
相关文章