2

I use emacs 24.4 with auto-complete1.5.0 and bundled version of CEDET2.0 (I've also tried with latest CEDET by downloading and loading cedet-devel-load.el).

I have qt4 sources installed and semantic in my ac-sources. I want it to parse and auto-complete my sources.

Following Alex's Ott tuto I put this in my init.el :

(require 'semantic/sb)
(require 'semantic/ia)
(require 'semantic/bovine/gcc)
(require 'semantic/bovine/c)

(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-highlight-func-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-local-symbol-highlight-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-decoration-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode)


(add-to-list 'auto-mode-alist '("/usr/include/qt4" . c++-mode))
(semantic-add-system-include "/usr/include/qt4" 'c++-mode)
(semantic-add-system-include "/usr/include/qt4/QtGui" 'c++-mode)
(semantic-add-system-include "/usr/include/qt4/Qt" 'c++-mode)

;(add-to-list 'semantic-lex-c-preprocessor-symbol-file "/usr/include/qt4/Qt/qconfig.h")
;(add-to-list 'semantic-lex-c-preprocessor-symbol-file "/usr/include/qt4/Qt/qconfig-dist.h")


(semantic-mode 1)

But there's nothing to do, I don't get any completions !

-- Edit --

After some search I think the problem is that semantic doesn't parse qt sources as it should;

for example, I have :

#include <QSystemTrayIcon>

But when I try to complete "QSyst"... I have only one possible completion : QSystemTrayIconPrivate So I opened /usr/include/qt4/QtGui/qsystemtrayicon.h to see what's in this file and there is the definition of QSystemTrayIcon class:

class Q_GUI_EXPORT QSystemTrayIcon : public QObject

and the definition of QSystemTrayIconPrivate :

class QSystemTrayIconPrivate;

I don't know what this Q_GUI_EXPORT means, I have never seen such construction of class; with root powers, I modified the header to :

class QSystemTrayIcon : public QObject

then forced semantic to reparse and the completion works for this class now !

I deduce Semantic doesn't understand how qt creates classes, it's the same for other such as QApplication, and so on...

I don't want to manually edit all qt sources. So, is there a way to hack Semantic source code so it can understand this kind of class construction ?

  • I recommend you to try emacs-ycmd. It works great – Jesse Aug 22 '15 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.