Emacs:使用和初始化 CEDET

发布于 2024-09-05 23:13:17 字数 1033 浏览 8 评论 0原文

我使用带有 CEDET 和自动完成功能的 Emacs 来完成代码。最初我设置了 CEDET,以便每次 Emacs 启动时都会加载它。

然而,这花了相当长的时间,所以我认为只在需要时加载它是明智的,即 - 就我而言 - 当进入 C++ 模式时。

因此,我将原始函数移至进入 C++ 模式时调用的 lambda:

; cscope for c(++) programming (finding symbols, etc.)
(require 'xcscope)

; C++ stuff
(add-hook 'c++-mode-hook
      (lambda ()
        (load-file "/usr/share/emacs/site-lisp/cedet-common/cedet.el")
        (global-ede-mode 1) ; enable project management system
        (semantic-load-enable-code-helpers) ; enable prototype help and smart completion
        (require 'auto-complete-config)
        (add-to-list 'ac-dictionary-directories "~/elisp/ac-dict")
        (add-to-list 'ac-sources 'ac-source-semantic)
        (local-set-key (kbd "C-:") 'semantic-ia-complete-symbol-menu) ; set shortcut for auto completion.
        (local-set-key (kbd "C-.") 'ac-complete-semantic)
        (ac-config-default)
        )
      )

没有错误,但出现以下问题: 当 Emacs 第一次进入 C++ 模式时,代码完成无法正常工作。但如果 Emacs 第二次进入 C++ 模式,一切都会正常。

有人知道我做错了什么吗?

I'm using Emacs with CEDET and auto complete for code completion. Originally I set up CEDET so it loads at Emacs start up every time.

However, this took quite a long time, so i thought it would be clever to load it just if needed, i.e. - in my case - when entering C++-Mode.

So I moved the original function into a lambda that is called when entering C++-mode:

; cscope for c(++) programming (finding symbols, etc.)
(require 'xcscope)

; C++ stuff
(add-hook 'c++-mode-hook
      (lambda ()
        (load-file "/usr/share/emacs/site-lisp/cedet-common/cedet.el")
        (global-ede-mode 1) ; enable project management system
        (semantic-load-enable-code-helpers) ; enable prototype help and smart completion
        (require 'auto-complete-config)
        (add-to-list 'ac-dictionary-directories "~/elisp/ac-dict")
        (add-to-list 'ac-sources 'ac-source-semantic)
        (local-set-key (kbd "C-:") 'semantic-ia-complete-symbol-menu) ; set shortcut for auto completion.
        (local-set-key (kbd "C-.") 'ac-complete-semantic)
        (ac-config-default)
        )
      )

There are no errors, but I have the following problem: When Emacs enters C++-mode for the first time, code completion does not work properly. But if Emacs enters C++-mode the second time, everything works just fine.

Does anybody know what I'm doing wrong?

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

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

发布评论

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

评论(1

半衬遮猫 2024-09-12 23:13:17

CEDET 初始化设置了它自己的 C 和 C++ 模式挂钩。如果它在运行相同的钩子时安装了它的钩子,那么它就不会运行,并且您的第一个缓冲区将不会初始化。

您可以做的是在启动时加载 CEDET,然后在 C 模式挂钩中初始化代码帮助程序。这样,C++ 模式将使用 mode-local 进行初始化,但额外的函数将在钩子运行后安装,因此可能会起作用。我自己没试过。

我认为 EDE 模式并不慢,因此在初始化时也可以这样做。

CEDET initialization sets up C and C++ mode hooks of it's own. If it installs it's hook while it is running the same hook, then it won't run, and your first buffer won't have initialized.

What you could do is load CEDET at startup, but then init the code helpers in the C mode hook. That way C++ mode will initialize with mode-local, but the extra functions will be installed after the hook runs, so that may work. I hadn't tried it myself.

I think EDE mode isn't slow, so it is probably ok to do that at init time too.

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