关于在 C++ 项目中使用 emacs 有什么好的建议吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Any good advice on using emacs for C++ project?
提问by Serge
I'm looking for a good article on using emacs as C/C++ IDE.
我正在寻找一篇关于使用 emacs 作为 C/C++ IDE 的好文章。
Something like Steve Yegge's "Effective emacs".
类似于 Steve Yegge 的“Effective emacs”。
采纳答案by Blair Conrad
No specific article, really, but I've found EmacsWikito be full of useful information. Consider checking out these entries:
没有具体的文章,真的,但我发现EmacsWiki充满了有用的信息。考虑检查这些条目:
- CPlusPlusas a starting point for many C++-related articles, and
- CppTemplateto define a template that can give you a good skeleton when you start new files
- CPlusPlus作为许多 C++ 相关文章的起点,以及
- CppTemplate定义一个模板,可以在你开始新文件时给你一个很好的骨架
回答by Serge
I've recently stumbled upon this articlewhich is quite good.
我最近偶然发现了这篇文章,它非常好。
EDIT: Yep the link is no longer valid. It seems like they've changed their url recently and it doesn't redirect properly. Hopefully it will be back soon. Anyway the article was called "Benjamin Rutt's Emacs C development tips". I managed to find a copy here.
编辑:是的,链接不再有效。似乎他们最近更改了网址,但无法正确重定向。希望它很快就会回来。无论如何,这篇文章被称为“Benjamin Rutt 的 Emacs C 开发技巧”。我设法在这里找到了一份副本。
回答by Alex Ott
I'm planning to write such article in near future, but you can now take my configurationof Cedet+ Emacs, that helps me to effectively edit C++ sources. If you'll have questions, you could ask me directly
我打算在不久的将来写这样的文章,但您现在可以使用我的Cedet+ Emacs配置,这有助于我有效地编辑 C++ 源代码。有问题可以直接问我
回答by optikos
Be aware that Emacs' C++ mode is based on only regular expressions, not a grammar. Hence, the syntax highlighting is not based strictly on the syntax of the language itself, but rather is largely based on commonplace formatting. The Emacs syntax highlighting of C++ often makes mistakes.
请注意,Emacs 的 C++ 模式仅基于正则表达式,而不是语法。因此,语法高亮并不是严格基于语言本身的语法,而是主要基于常见的格式。C++ 的 Emacs 语法高亮经常出错。
The problem is not limited to syntax hightlighting. The same defective design applies to the automatic formatting. All this said, I have been using only Emacs for all of my editing of C++ source code for over 20 years, since the cfront days. (I usually turn off electric key bindings, because of Emacs' defective regex-based design. Regexes do not have enough expressive power to describe the C++ syntax accurately.
问题不仅限于语法高亮。同样有缺陷的设计也适用于自动格式化。综上所述,自 cfront 时代以来,我一直只使用 Emacs 来编辑 C++ 源代码超过 20 年。(我通常关闭电子键绑定,因为 Emacs 基于正则表达式的设计有缺陷。正则表达式没有足够的表达能力来准确描述 C++ 语法。
回答by Flow
I recommend ggtagsand irony-mode. Other then that you may want to use helm-agto search ("grep") for strings in your codebase.
我推荐ggtags和irony-mode。除此之外,您可能希望使用helm-ag在代码库中搜索(“grep”)字符串。