在Emacs中编辑PHP的好方法是什么? [英] What is a good setup for editing PHP in Emacs?

查看:154
本文介绍了在Emacs中编辑PHP的好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今年夏天,我将为我的工作做一些PHP编辑,并寻找一个有效的Emacs设置进行编辑。我已经大量投资Emacs,所以切换到另一个编辑器是不值得的。



现在,我有一个 nXhtml模式,它提供了一种具有语法高亮显示功能的PHP模式(在野外至少有三个不同的)以及MuMaMo for编辑嵌入HTML的PHP​​。我刚刚开始使用自动完成任何一个用于编程和一般Emacs的东西



我真正寻找的是一个有效的方式让Emacs真正了解这个项目,而不仅仅是突出显示。 Etags 看起来像一个很好的选择,但是看起来像生成新标签的过程是一种艰巨的任务和手动(或至少不可见)。 Etags的好处是它们与Anything和Auto-Complete完美结合。其他潜在的选项是 gtags (虽然我犹豫安装非elisp文件,只是为了复杂性), vtags 语义,我之前已经搞砸了,看起来很复杂,再加上它不支持PHP。



另一个选项是 Imenu ,但它只起作用对于当前的缓冲区,我希望能够跳转到其他文件中的函数定义(最好使用Anything来完成名称)。



项目我将工作不是那么大(总共约30,000行),所以Etag的开销大概不会是那么大的问题,但是如果有更好的解决方案,我宁愿不使用它。



那么你最喜欢的PHP编辑系统是什么?

解决方案

除了你已经熟悉的功能之外,我建议你以下。



ETags



我不使用ETag,但是在SO 如何使用emacs以编程方式创建/更新TAGS文件 的。没有好的答案被发布,但是可能是一个很好的切入点。



调试



Flymake 是进行语法检查的一种模式。它也支持PHP。它在您键入时立即提示语法错误。 Emacs 23附带的Flymake版本包含PHP支持。如果您有以前的版本,请检查Sacha Chua的帖子 Emacs和PHP:使用Flymake进行即时语法检查



另一个有用的软件包是 Geben ,允许您以交互方式调试脚本。对于PHP,您可以使用XDebug。有一个关于如何做到这一点的详细教程,请参阅 使用geben在emacs中调试php



文档查找



PHP模式有一个很好的功能,可以在您的Web浏览器中查看PHP手册中的函数定义( Mx php-search-documentation Cc Cf )。您可以将其与 Emacs-W3M 结合使用,以获取相关的手册页,而不必离开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.

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.

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.

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).

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.

So what is your preferred PHP editing system?

解决方案

In addition to features you are already familiar with, I suggest you the followings.

ETags

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.

Debugging

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.

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.

Documentation lookup

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.

这篇关于在Emacs中编辑PHP的好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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