Emacs,C++向量的代码完成
我是 Emacs 新手,并且 我有以下代码作为示例。 我已经安装了 GNU Emacs 23.1.1 (i386-mingw-nt6.1.7600),安装cedet-1.0pre7.tar.gz。 ,安装ELPA,以及公司。 您可以在底部找到我的简单 Emacs 配置。
问题是,当我在 main() 中输入 q[0] 并按 .(点)时,我看到了 37 个成员向量,而不是 Person,尽管 first_name 和 last_name 是预期的。函数 greet() 中的完成工作按预期进行,但与向量无关。
我的问题是,如何完成向量元素的代码完成?
#include <iostream>
#include <vector>
using namespace std;
class Person
{
public:
string first_name;
string last_name;
};
void greet(Person a_person)
{
// a_person.first_name is completed as expected!
cout << a_person.first_name << "|";
cout << a_person.last_name << endl;
};
int main()
{
vector<Person> q(2);
Person guy1;
guy1.first_name = "foo";
guy1.last_name = "bar";
Person guy2;
guy2.first_name = "stack";
guy2.last_name = "overflow";
q[0] = guy1;
q[1] = guy2;
greet(guy1);
greet(guy2);
// cout q[0]. I want to see first_name or last_name here!
}
我的 Emacs 配置:
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
(load-file "~/.emacs.d/cedet/common/cedet.el")
(semantic-load-enable-excessive-code-helpers)
(require 'semantic-ia)
(global-srecode-minor-mode 1)
(semantic-add-system-include "/gcc/include/c++/4.4.2" 'c++-mode)
(semantic-add-system-include "/gcc/i386-pc-mingw32/include" 'c++-mode)
(semantic-add-system-include "/gcc/include" 'c++-mode)
(defun my-semantic-hook ()
(imenu-add-to-menubar "TAGS"))
(add-hook 'semantic-init-hooks 'my-semantic-hook)
I am new to Emacs, and
I have the following code as a sample.
I have installed GNU Emacs 23.1.1 (i386-mingw-nt6.1.7600), installed cedet-1.0pre7.tar.gz. , installed ELPA, and company.
You can find my simple Emacs configuration at the bottom.
The problem is, when I type q[0] in main() and press . (dot), I see the 37 members of the vector, not Person although first_name and last_name are expected. The completion works as expected in the function greet() but it has nothing to do with vector.
My question is, how can I accomplish code completion for vector elements too?
#include <iostream>
#include <vector>
using namespace std;
class Person
{
public:
string first_name;
string last_name;
};
void greet(Person a_person)
{
// a_person.first_name is completed as expected!
cout << a_person.first_name << "|";
cout << a_person.last_name << endl;
};
int main()
{
vector<Person> q(2);
Person guy1;
guy1.first_name = "foo";
guy1.last_name = "bar";
Person guy2;
guy2.first_name = "stack";
guy2.last_name = "overflow";
q[0] = guy1;
q[1] = guy2;
greet(guy1);
greet(guy2);
// cout q[0]. I want to see first_name or last_name here!
}
My Emacs configuration:
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
(load-file "~/.emacs.d/cedet/common/cedet.el")
(semantic-load-enable-excessive-code-helpers)
(require 'semantic-ia)
(global-srecode-minor-mode 1)
(semantic-add-system-include "/gcc/include/c++/4.4.2" 'c++-mode)
(semantic-add-system-include "/gcc/i386-pc-mingw32/include" 'c++-mode)
(semantic-add-system-include "/gcc/include" 'c++-mode)
(defun my-semantic-hook ()
(imenu-add-to-menubar "TAGS"))
(add-hook 'semantic-init-hooks 'my-semantic-hook)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是语义分析器的一个已知问题。我目前无法处理 gcc STL 中使用的 Template Specialization (你的问题源于来自 allocator.h 中的这种专业化)。这已在邮件列表中进行了讨论:
http://thread.gmane。 org/gmane.emacs.semantic/2137/focus=2147
This is a known problem with the Semantic analyzer. I currently cannot deal with Template Specialization, which is used in the gcc STL (your problem stems from such a specialization in allocator.h). This has been discussed on the mailing list:
http://thread.gmane.org/gmane.emacs.semantic/2137/focus=2147
GCCSense
在 Emacs 中完成 C++ 代码的示例:
GCCSense
An example of completion of a C++ code in Emacs: