简体   繁体   English

使用emacs语义与ede和company-mode来完成和导航

[英]using emacs semantic with ede and company-mode to complete and navigate

I followed http://tuhdo.github.io/c-ide.html#orgheadline33 tutorial to build ac/c++ IDE using emacs. 我按照http://tuhdo.github.io/c-ide.html#orgheadline33教程来使用emacs构建ac / c ++ IDE。

However I have problems using semantic to complete with company-mode and navigate. 但是我在使用语义来完成公司模式和导航时遇到了问题。 The thing is that when I try to tell semantic where is other library or codes is using semantic-add-system-include, it only works with c++ includes. 事实是,当我尝试告诉语义其他库或代码在哪里使用语义添加系统包含时,它仅适用于c ++包含。

If I add (semantic-add-system-include "~/mylib") , semantic won't parse the files in ~/mylib and so company won't work. 如果我添加(semantic-add-system-include "~/mylib") ,语义将无法解析〜/ mylib中的文件,因此公司将无法正常工作。 But if I use (semantic-add-system-include "/usr/include/c++/4.5.2/") this will work. 但是,如果我使用(semantic-add-system-include "/usr/include/c++/4.5.2/")则可以使用。 How do make it work with other codes or headers? 如何使其与其他代码或标头一起使用?

I also tried to use EDE. 我也尝试使用EDE。 My project directory is like this: 我的项目目录如下:

/project root  
    /lib1  
    /lib2   

and I tried 我尝试了

(ede-cpp-root-project "myproject"
                      :file "/home/user/myproject/Makefile"
                      :include-path '("/lib1"
                                      "/lib2")
                      )

and

(ede-cpp-root-project "myproject"
                      :file "/home/user/myproject/Makefile"
                      :system-include-path '("/home/user")
                      )

However, when I type 但是,当我键入

#include <myproject/lib1/xx.h>

in my source file, semantic won't parse the correct file and offer the complete candidate. 在我的源文件中,语义将无法解析正确的文件并提供完整的候选对象。

I just want semantic parse the correct file when I type #include <myproject/lib1/xx.h> . 当我输入#include <myproject/lib1/xx.h>时,我只想语义分析正确的文件。 Can I achieve this with semantic or/and EDE? 我可以使用语义或/和EDE实现此目的吗?

I have something like the following in my semantic-mode-hook . 我的semantic-mode-hook The variable semantic-dependency-system-include-path is mode-local. 变量semantic-dependency-system-include-path是模式本地的。 Try redefining your-c-include-dirs or your-c++-include-dirs in the following. 尝试在下面重新定义your-c-include-dirsyour-c++-include-dirs

(defun your-semantic-hook ()
  ;; these are buffer-local
  (mapc (lambda (dir)
          (semantic-add-system-include dir 'c-mode))
        your-c-include-dirs)
  (mapc (lambda (dir)
          (semantic-add-system-include dir 'c++-mode))
        your-c++-include-dirs))

(add-hook 'semantic-mode-hook 'your-semantic-hook)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM