Can you take a project like linux kernel or other small projects and go through setting cedet up step by step ?
Why is it so complex just to set this up ? One would want to understand the project they're working on,
not to understand the complexities of cedet itself. Sorry, I'm ranting like this but I'm frustrated setting this
up.
I'm not sure about this - It's better to ask in cedet-devel mailing list
CEDET uses system search paths to search for include files. Besides this it uses project-specific include paths, that you can define with EDE projects. For existing C++ project you can use ede-cpp-root-project as described in article and in you can see more examples in my CEDET config - http://github.com/alexott/emac...
In the chapter "using EDE for C/C++ projects", it reads: " Instead of specifying paths as lists, you can also provide
function, that will perform search of include files in your project. You can read about
it in the EDE manual." could you provide the link? I've only found that one and not sure to find the information. Are you talking about loc-fn ? (Anyway, maybe better to insert the link in your article?)
Hi
sorry for delay - you can read about it in the ' ede-cpp-root-project' section of EDE manual that is included into CEDET distribution - search for description of :locate-fcn slot there.
P.S. documentation is also available online: http://www.randomsample.de/ced...
With or without auto-complete, the completion for std:: gives about 1000+ suggestions. Something is wrong.
Am I doing anything obviously wrong with the cedet settings ?
https://github.com/maindoor/em...
config looks ok for me. Regarding the number of completions you should take into account that all C functions are imported into std:: namespace...
Hi. Can you give the emacs lisp code for using CEDET-1.1 with Qt4. Thanks in advance.
Look to this blog post: http://alexott.blogspot.de/200...
The latest cedet from bzr repo as of 30 october does not display the symref correctly.
if we search for some_func it lists all the places that has an "{" which is one line below
some_func. This is legacy code. One would still expect to see some_func in the list.
When I am inside a function, semantic-symref anywhere in the function asks if I want to symref the function name and works. semantic-symref-symbol does not accept any of the functions or symbols. says [No Match].
What could be wrong ?
Looks like a bug, please report to cedet mailing list
Just observed: I do get this error:
file mode specification error: (void-variable ac-sources)
Looks like it is related. describe-variable also doesn't know about ac-sources.
Looks like I am missing a crucial package. any suggestions ?
In my config, I'm using auto-complete package, and it looks like it doesn't installed (or not loaded on your machine).
For CEDET from bzr, you can use following setup as a base: https://gist.github.com/393012...
Your link above "my config" goes to a 404 page. Can you provide a valid path ?
fixed, thank you
Can you update this for emacs24 ? It has been out for a while and soon it is going to be all 24.
I get EIEIO version 1.3 is already loaded; load CEDET at the beginning of your init file to avoid this.
I plan to update article soon. In the meantime you can try following config: https://gist.github.com/393012... - it's for bzr version, but should also work with built-in CEDET
Although I used a the cedet-1.1 package everything worked as supposed. thanks for this great article I think it's very useful for both beginners and experts
s/(require 'semantic-ia)/(require 'semantic/ia)/
Ditto for semanticdb and semantic/db
Thank you David, I simply don't have time to update article to new layout :-(
Maybe it would make sense to open up maintenance to others, e.g. move the article to github so you can accept pull requests, move it to EmacsWiki, etc.
btw, my site is available on github: https://github.com/alexott/ale...
The article states, "Currently it's better to use the development version of Cedet." Is that still the case?
Yep, 1.1 isn't released yet (although it should be released in the next weeks). But usually, there are a lot of bug fixes and new functionality between releases, so it's better to use development snapshots...
${VariableName} sematic-complete-analyze-inline(0|?
Hi,
I am using Semantic for members completion.
Refer this article and some others, it do works.
But I found a problem with coding between #ifdef MACRO_XXX and #endif code segment.
If MACRO_XXX wasn't defined, it wouldn't do completion in that scope.
For example, in this code segment:
#ifdef CONFIG_SUSPEND
/*
* When SPI wake up from off-mode, CS is in activate state. If it was in
* unactive state when driver was suspend, then force it to unactive state at
* wake up.
*/
static int omap2_mcspi_resume(struct device *dev)
{
struct spi_master *master = dev_get_drvdata(dev);
struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
struct omap2_mcspi_cs *cs;
…
#endif
I couldn't do members completion for cs, master, mcspi etc.
In other code scope in the same file, it worked fine.
Is there any convenient way to get it do members completion in this
#ifdef/#endif code segment without obviously define CONFIG_SUSPEND
in this file while don't affect other files?Thanks!
Hello,
CONFIG_SUSPEND is declared in autoconf.h, this file must be seen by semantic to be able to recongnize all the defines there. No need to define that macro manually !
This can be done in emacs configuration file by adding this line:
(add-to-list 'semantic-lex-c-preprocessor-symbol-file "/home/abdellatif/android/kernel/include/generated/autoconf.h")
And of course specifying your autoconf.h located in your linux kernel source path.
An interesting note: you should use emacs and semantic BZR versions.
Regards
Hi Alex,
I am using CEDET configuration mostly from your emacs file with appropriate modifications. I use a C++ medical image processing library called ITK, which is heavily templated. My cedet configs are as follows:
(semantic-load-enable-excessive-code-helpers)(global-ede-mode 1)(semantic-load-enable-semantic-debugging-helpers)(global-srecode-minor-mode 1)(ede-enable-generic-projects)
(semantic-add-system-include "path/to/include/directory" 'c++-mode)
(require 'semantic-decorate-include)(setq-mode-local c-mode semanticdb-find-default-throttle '(project unloaded system recursive))(setq-mode-local c++-mode semanticdb-find-default-throttle '(project unloaded system recursive))(setq-mode-local erlang-mode semanticdb-find-default-throttle '(project unloaded system recursive))(require 'eassist);; customisation of modes(defun alexott/cedet-hook () (local-set-key [(control return)] 'semantic-ia-complete-symbol-menu) (local-set-key "\C-c?" 'semantic-ia-complete-symbol) ;; (local-set-key "\C-c>" 'semantic-complete-analyze-inline) (local-set-key "\C-c=" 'semantic-decoration-include-visit) (local-set-key "\C-cj" 'semantic-ia-fast-jump) (local-set-key "\C-cq" 'semantic-ia-show-doc) (local-set-key "\C-cs" 'semantic-ia-show-summary) (local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle) ); other stuff.....; a sample project(ede-cpp-root-project "ITK-Test" :name "ITK Test Project" :file "c:\\Users\\acer\\Documents\\Code\\ITK\\Translate\\CMakeLists.txt" :include-path '("./"))
However when i visit a smart pointer and try to find its completion after "->" using \C-?, the message i get is "cannot find types for blah". Can you pl. give some hints? The corresponding include file is shown as visited.
Most probably, i am not being clear here; I can post the entire file(essentially your .emacs file)at other blog.
thanks,
krishnan
Hello
Could you provide more information on Emacs & CEDET version used? It's recommended to use CEDET from bzr, as fixes are constantly posted. After you'll try newest version (don't forget to delete semanticdb cache files) and if will not work, then try to create small sample of your code, and post it into cedet development mailing list, so C++ grammar hackers could fix this.
My emacs version is 23.1.1 and cedet is 1. I will try out your suggestion.
Thanks.
Ok, i was using a bzr version, now i upgraded to 8112 and deleted semanticdb files. no business results. will post in mailing list.
Hello,
Thank you for the valuable article.
I am trying to use Emacs as an IDE in my Linux kernel development projects. So I installed CEDET and GNU Global (gtags) with no problems.
When I open a C source code belonging to my Linux kernel source folder, the linux project is detected automatically. Functions, variables, headers and other keywords are highlighted correctly.
Through the ~/.emacs file I configured semantic's code completion and intellisense. So when I press C-<spc> the code completion menu appears and I can choose what's needed.
The issue is when I use preprocessor defines, the intellisense system shows the menu on the current location but doesn't detect the right things when invoked (C-<spc>). Even I close and restart emacs the same behavior is reproduced.
The test code is:
//----------------------------------------------------------------------------------------
typedef struct{ int p1; #ifdef __KERNEL__ int p2; #endif
#ifdef USE1
char p3; #endif#ifdef __LINUX_ARM_ARCH__
int p4;
#endif
}OBJ;OBJ g_obj;//----------------------------------------------------------------------------------------__KERNEL__ , USE1 and __LINUX_ARM_ARCH__ are already defined as follows:__KERNEL__ : (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("__KERNEL__" . "")) in .emacsUSE1 : defined in a header file included by the current C source file.__LINUX_ARM_ARCH__ : (add-to-list 'semantic-lex-c-preprocessor-symbol-file "/home/abdellatif/kernel/include/generated/autoconf.h") in .emacsIn the .emacs file I also added all the needed includes and defines required by GCC cross compiler (GCC for ARM) to build the kernel project.I also tried to force semantic to use GCC cross compiler command line in place of the system GCC to preprocess correctly but haven't found how to do that."M-x semantic-c-describe-environment" command shows right Include Path Summary. The defines set in .emacs are shown (__KERNEL__, autoconf.h, ...) correctly but the GCC system settings are also listed.The .emacs file and the software versions are shown below.Any help or indication is welcomed :)Best regards
############# Software versions #############- Emacs (23.2.1)- Ubuntu machine (natty, 11.04)- Cedet 1.0 (from http://cedet.sourceforge.net/)... .emacs #############;load CEDET(load-file "~/Documents/my_emacs/cedet-1.0/common/cedet.el")(require 'ede)(global-ede-mode t); turn on which-func support (plus all other code helpers)(semantic-load-enable-gaudy-code-helpers)(semantic-load-enable-excessive-code-helpers); turn on all "useful" features(setq semantic-load-turn-useful-things-on t)(setq-mode-local c-mode semanticdb-find-default-throttle '(project unloaded system recursive));init names completion, and displaying of information for tags & classes(require 'semantic-ia);preprocessing of source code(require 'semantic-c)(semantic-reset-system-include 'c-mode)(semantic-reset-system-include 'c++-mode)(semantic-add-system-include "/home/abdellatif/toolchain/arm-eabi-4.4.3/lib/gcc/arm-eabi/4.4.3/include" 'c-mode)(semantic-add-system-include "/home/abdellatif/kernel/arch/arm/include" 'c-mode)(semantic-add-system-include "/home/abdellatif/kernel/include" 'c-mode)(semantic-add-system-include "/home/abdellatif/kernel/arch/arm/mach-omap2/include" 'c-mode)(semantic-add-system-include "/home/abdellatif/kernel/arch/arm/plat-omap/include" 'c-mode)(add-to-list 'semantic-lex-c-preprocessor-symbol-file "/home/abdellatif/kernel/include/generated/autoconf.h")(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("__KERNEL__" . ""))(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("__LINUX_ARM_ARCH__" . "7"))(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("KBUILD_STR(s)" . "#s"))(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("KBUILD_BASENAME" . "KBUILD_STR(main)"))(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("KBUILD_MODNAME" . "KBUILD_STR(main)"));semantic integration with imenu (display of a menu with a list of functions, variables, and other tags)(defun my-semantic-hook () (imenu-add-to-menubar "TAGS"))(add-hook 'semantic-init-hooks 'my-semantic-hook);names completion (semantic commands)(defun my-cedet-hook () (local-set-key [(control return)] 'semantic-ia-complete-symbol) (local-set-key "\C-x " 'semantic-ia-complete-symbol-menu) (local-set-key "\C-x\r" 'gtags-find-tag-from-here))(add-hook 'c-mode-common-hook 'my-cedet-hook);navigating in source code(semantic-mru-bookmark-mode 1);tell semantic to store its tags database between sessions here(require 'semanticdb)(setq-default semanticdb-default-save-directory "~/.semantic.cache")(setq-default semanticdb-default-system-save-directory "~/.semantic.cache");allow Semanticdb use databases generated by global(gtags)(require 'semanticdb-global)(semanticdb-enable-gnu-global-databases 'c-mode)</spc></spc>
I would recommend to try CEDET version from bzr. I'm not sure about preprocessor defines - how they're interact with ede-linux project type, maybe they're over-ridden somewhere. I think, that it's better to write to cedet-devel mailing list with this question. I really don't know anything about ede-linux project type
Thank you for the answer. I reinstalled CEDET in a new path with bzr (bzr checkout bzr://cedet.bzr.sourceforge.ne... cedet). Nothing changed. The same behaviour with defines.
This can help with returning from semantic-ia-fast-jump..
(load "etags")
(defun zuza-semantic-ia-fast-jump () (interactive)
(ring-insert find-tag-marker-ring (point-marker))
(semantic-ia-fast-jump (point))
)
Thanks for hint, good solution...
This is an excellent document. Unfortunately, the installation instructions fail at the first step! I have downloaded cedet 1.0 from sourceforge, untarred etc and then tried the "emacs -Q -l cedet-build.el -f cedet-build" command. This brings up Emacs and starts the build process but fails at Step 5 (load common/cedet.el) with an error in eieio.el: Wrong type of argument: listp, "Forgot to expand macro eieio-object-p".
I am using Emacs 24.0.50 on Debian (emacs-snapshot package from Julien Danjou) and am going crazy trying to get cedet up and running. Any advice greatly appreciated!
Thanks.
For this Emacs version you need to use CEDET from bzr repository - in Emacs's trunk macroexpansion was changed (as I remember) and this prevents older versions of CEDET from working...
And anyway, it's good idea to always use CEDET from trunk...
Thanks for this. I have now moved to the bzr version. This builds but fails in use. Time to check out the cedet-devel mailing list more closely methinks!
Thanks again.
Hello,
I'm not sure if I'm using the bazaar version but I downloaded cedet-1.0.tar.gz and emacs compile failed for me, too. But I think when I tried plain "make" everything worked. Hope this helps.
thank you , this is very usefully to me!
Hi Alex, several stuff on this page are not clear to me. I tried a whole day and still I was not able to make Cedet do what I was expecting it to do. One of the most useful features when one browses or develops code is to be able to click on a class member of function, and Cedet should take you where it is defined. This I know how to do with cscope, but not with Cedet. Furthermore, with Cedet I do not know how to create a project, easily by giving a folder of the headers and a folder of the .cpp files. For instance I would like to be able to provided my own Makefile if possible. Automake tools for me is a waste of time and complicate things too much. The amount of effort needed to maintain all the automake stuff is much more than writing your own makefiles by scratch. I do not know why people use them. FreeBSD has a smarter way for auto-configuration. The BSD makefiles. But this is not the point here. Is it possible to provide my own Makefile, or at least to give sources and headers to a simple project and this simple project can write a simple makefile, the easy way, where I can change compilers and their flags and add some libraries to link to?
Thank you Alex, it was a very useful article indeed!!
We have eclipse IDE. So it internally maintains all the 'make' related information somehow. Is the #include statement supposed to specify the exact path even if i use (semantic-load-enable-primary-exuberent-ctags-support)?
Yes, if you'll use (semantic-load-enable-primary-exuberent-ctags-support) - it should be used in tag completion.
How include paths are specified in your Makefiles? Is one Makefile, that lists all include directories, or there are a lot of Makefiles, each of them specifying it's own list of includes?
Thanks for the reply.
My knowledge of elisp is very limited. From what I can understand from your configuration you want me to give all the include directories in the system-include-path list. I still am struck with a dilemma. The project I am currently working on is huge. It has hundreds of include folders. What is the correct approach in this case? Should I give all of them in the system-include-path variable? Or is there a easier way?
I also have ctags/etags built for the entire project. I am sure you must be knowing omnicomplete plugin for vim which uses ctags for its completion.
Is there a similar feature available in cedet? I am assuming if I make cedet point to the TAGS file then I don't have to include the directory list because everything will be inside the TAGS file itself? Is my understanding correct?
I finally have been able to set up cedet properly; Many many thanks to this article!
Still i am facing an issue.
Cedet does not seem to work well in certain cases.
When I give the exact path relative to the current file i am working on then auto-completion is working fine.
#include "../../opensource/inc/lldp_port.h"
void test_func()
{
lldp_port port;
port.blah //here auto-completion worked fine
}
However i cannot specify the full path all the time( we have eclipse at office and it generates makefiles for us )
#include "lldp_port.h"
void test_func()
{
lldp_port port;
port. //here auto-completion does not work :(
}
What should i do to solve this?
Thanks for your comments...
about cpp-root-project, etc. cpp-root-project was introduced to provide EDE support for existing projects, that aren't using Project.ede. This allows to specify include search paths and other project-specific information, and (for my case) I also use it to store local information - compilation command, etc. I thought about implementing CMake support for EDE - in this case it could be much simplier to specify include path & libraries. But I have no time right now
About updates for article - yes, I plan to update article during next 2-3 months. I also thought about including it into CEDET distribution, as something like 'CEDET Quick Start Guide' - we need to discuss with Eric this once again