Subject: 30.1; cedet qt4-demo not working

From: Andrés Ramírez <[email-masked]>
Date: Mon, 24 Mar 2025 02:15:32 +0000

Hi.

When re-testing the qt4-demo showed in this blogpost:
,---- [ blogpost ]
| https://alexott.net/en/writings/emacs-devenv/EmacsCedet.html
`----
The image should be this one:

But I am getting this one:

The steps to reproduce (Failing) are:
1. emacs -Q -nw -l /tmp/.emacs-rc-cedet-nil.el -f cedet-lambda/load-qt4 /tmp/cedet/impressive/qt4/main_cedet_demo.cpp 
2. M-g g 10
4. C-e
5. M-x semantic-ia-complete-symbol-menu

It fails and show those messages:
--8<---------------cut here---------------start------------->8---
(error "Cannot find types for ‘QPushButton quit ()’")
No smart completions found.
--8<---------------cut here---------------end--------------->8---

The steps to reproduce (WORKAROUND) are:
1. emacs -Q -nw -l /tmp/.emacs-rc-cedet-t.el -f cedet-lambda/load-qt4 /tmp/cedet/impressive/qt4/main_cedet_demo.cpp -f semantic-mode
2. M-g g 10
4. C-e
5. M-x semantic-ia-complete-symbol-menu

As You could see on the image 'cedet-qt4-demo-t.png'. It works. And on
the image 'cedet-qt4-demo-fails.png' it fails. The difference is the way
the funct 'semantic-mode' is invoked.

Best Regards
Andrés Ramírez
;;; minimial-cedet-config.el --- Working configuration for CEDET from bzr
;;; https://gist.github.com/alexott/3930120
;;; NOTE2ME: 3 cedet versions bundled, latest-released, version-control
;;;; NOTE2ME: this is for cedet 1.0 && cedet 1.1
;;; NOTE2ME: semanticdb-default-save-directory {could not be mixed among different versions} {rm it before trying other version}
(setq semanticdb-default-save-directory (concat "/tmp/em-" (prin1-to-string emacs-major-version) "/cedet-cache/semanticdb"))

  ;;; NOTE2ME: comment line below when You want to test the cedet version bundled with emacs
;;;(load-file "~/.emacs.d/lisp/cedet/common/cedet.el") ;;;1.1
(when (fboundp 'semantic-load-enable-code-helpers)
  (setq srecode-map-save-file nil)
  (global-ede-mode t);;; 1.1
  (semantic-load-enable-code-helpers)
  (global-srecode-minor-mode 1))

(unless (fboundp 'semantic-load-enable-code-helpers)
  ;; Activate semantic {below is for cedet 1.0}
  (semantic-mode 1) ;;; this one Fails(uncommented)|Success(commented-and-called-interactively) qt4 demo
  ;;;(run-at-time 3 nil #'semantic-mode)
  (setq srecode-map-save-file nil))
(when (fboundp 'cedet-version)
  (cedet-version))

(if (fboundp 'semantic-load-enable-code-helpers)
    (message "cedet standalone version")
  (message "cedet bundled version"))

    (message "cedet: do not forget to setup qt or wxwidgets")

;; Setup JAVA....
;;;(require 'cedet-java)

;; Setup JAVA-arduino....
;;; ¿when?

;;; cogre needs no be put manually
;;;(add-to-list 'load-path "~/.emacs.d/lisp/cogre")
;;;(require 'cogre)

;;; NOTE2ME: helper functions
(defun cedet-lambda/load-qt4 ()
  "setup qt4 when in need."
  (interactive)
  (let ((my-toolkit-dir "/usr/include/qt4")) 
    (if (not (file-readable-p my-toolkit-dir))
        (message (format "qt4 directory not found: '%s'"  my-toolkit-dir))
      (require 'semantic/bovine/gcc)
      (require 'semantic/bovine/c)
      (semantic-add-system-include my-toolkit-dir 'c++-mode)
      (add-to-list 'auto-mode-alist (cons my-toolkit-dir 'c++-mode))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat my-toolkit-dir "/Qt/qconfig.h"))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat my-toolkit-dir "/Qt/qconfig-dist.h"))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat my-toolkit-dir "/Qt/qglobal.h")))))

;; Function to load all include files in the specified directory
(defun DE-imply-includes-in-directory (dir)
  "Add all header files in DIR to `semanticdb-implied-include-tags'."
  (let ((files (directory-files dir t "^.+\\.h[hp]*$" t)))
    (defvar-mode-local c++-mode semanticdb-implied-include-tags
      (mapcar (lambda (header)
                (semantic-tag-new-include
                 header
                 nil
                 :filename header))
              files))))

(defun cedet-lambda/load-wx2 ()
  "setup wx2 when in need."
  (interactive)
  ;; include files for wxwidgets
  (let ((my-toolkit-dir-parent "/usr/include/wx-2.8")
        (my-toolkit-dir "/usr/include/wx-2.8/wx")) ;;; base-dir
    (if (not (file-readable-p my-toolkit-dir))
        (message (format "wx2 directory not found: '%s'"  my-toolkit-dir))
      ;; other
                                        ;(require 'semantic-gcc) ;; not @emacs30-bundled
      (require 'semantic/bovine/gcc)
      (require 'semantic/bovine/c)
      ;; other
      (semantic-add-system-include my-toolkit-dir 'c++-mode)
      (semantic-add-system-include my-toolkit-dir 'c-mode)
      ;; preprocessor macro
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLEXPORT" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_CORE" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_FWD_CORE" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_BASE" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_FWD_BASE" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_FWD_XML" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_ADV" . ""))
      ;;; my-toolkit-dir parent
      (semantic-add-system-include my-toolkit-dir-parent 'c++-mode)
      ;; Implicitly adding the header files to get completion working
      ;; Adding all include files in gtk directory
      (DE-imply-includes-in-directory (concat my-toolkit-dir "/gtk")))))

;;; WIP (it failed)
(defun cedet-lambda/load-gtk2 ()
  "setup gtk when in need."
  (interactive)
  (let ((my-toolkit-dir "/usr/include/gtkmm-3.0")) 
    (if (not (file-readable-p my-toolkit-dir))
        (message (format "gtkmm directory not found: '%s'"  my-toolkit-dir))
      (semantic-add-system-include my-toolkit-dir 'c++-mode)
      (semantic-add-system-include my-toolkit-dir 'c-mode)
      )))
;;; WIP (it failed)
(defun cedet-lambda/load-gtk ()
  "setup gtk when in need."
  (interactive)
  (let ( (cedet-sys-include-dirs (list
                                  "/usr/include"
                                  "/usr/include/bits"
                                  "/usr/include/glib-2.0"
                                  "/usr/include/gnu"
                                  "/usr/include/gtk-2.0"
                                 ;;;"/usr/include/gtk-2.0/gdk-pixbuf"
                                  "/usr/include/gtk-2.0/gtk"
                                  "/usr/include/gtkmm-3.0"
                                  "/usr/local/include")))
    (mapc (lambda (dir)
            (semantic-add-system-include dir 'c++-mode)
            (semantic-add-system-include dir 'c-mode))
          cedet-sys-include-dirs)))
;;; minimial-cedet-config.el ends here
;;; minimial-cedet-config.el --- Working configuration for CEDET from bzr
;;; https://gist.github.com/alexott/3930120
;;; NOTE2ME: 3 cedet versions bundled, latest-released, version-control
;;;; NOTE2ME: this is for cedet 1.0 && cedet 1.1
;;; NOTE2ME: semanticdb-default-save-directory {could not be mixed among different versions} {rm it before trying other version}
(setq semanticdb-default-save-directory (concat "/tmp/em-" (prin1-to-string emacs-major-version) "/cedet-cache/semanticdb"))

  ;;; NOTE2ME: comment line below when You want to test the cedet version bundled with emacs
;;;(load-file "~/.emacs.d/lisp/cedet/common/cedet.el") ;;;1.1
(when (fboundp 'semantic-load-enable-code-helpers)
  (setq srecode-map-save-file nil)
  (global-ede-mode t);;; 1.1
  (semantic-load-enable-code-helpers)
  (global-srecode-minor-mode 1))

(unless (fboundp 'semantic-load-enable-code-helpers)
  ;; Activate semantic {below is for cedet 1.0}
  ;;;(semantic-mode 1) ;;; this one Fails(uncommented)|Success(commented-and-called-interactively) qt4 demo
  ;;;(run-at-time 3 nil #'semantic-mode)
  (setq srecode-map-save-file nil))
(when (fboundp 'cedet-version)
  (cedet-version))

(if (fboundp 'semantic-load-enable-code-helpers)
    (message "cedet standalone version")
  (message "cedet bundled version"))

    (message "cedet: do not forget to setup qt or wxwidgets")

;; Setup JAVA....
;;;(require 'cedet-java)

;; Setup JAVA-arduino....
;;; ¿when?

;;; cogre needs no be put manually
;;;(add-to-list 'load-path "~/.emacs.d/lisp/cogre")
;;;(require 'cogre)

;;; NOTE2ME: helper functions
(defun cedet-lambda/load-qt4 ()
  "setup qt4 when in need."
  (interactive)
  (let ((my-toolkit-dir "/usr/include/qt4")) 
    (if (not (file-readable-p my-toolkit-dir))
        (message (format "qt4 directory not found: '%s'"  my-toolkit-dir))
      (require 'semantic/bovine/gcc)
      (require 'semantic/bovine/c)
      (semantic-add-system-include my-toolkit-dir 'c++-mode)
      (add-to-list 'auto-mode-alist (cons my-toolkit-dir 'c++-mode))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat my-toolkit-dir "/Qt/qconfig.h"))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat my-toolkit-dir "/Qt/qconfig-dist.h"))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat my-toolkit-dir "/Qt/qglobal.h")))))

;; Function to load all include files in the specified directory
(defun DE-imply-includes-in-directory (dir)
  "Add all header files in DIR to `semanticdb-implied-include-tags'."
  (let ((files (directory-files dir t "^.+\\.h[hp]*$" t)))
    (defvar-mode-local c++-mode semanticdb-implied-include-tags
      (mapcar (lambda (header)
                (semantic-tag-new-include
                 header
                 nil
                 :filename header))
              files))))

(defun cedet-lambda/load-wx2 ()
  "setup wx2 when in need."
  (interactive)
  ;; include files for wxwidgets
  (let ((my-toolkit-dir-parent "/usr/include/wx-2.8")
        (my-toolkit-dir "/usr/include/wx-2.8/wx")) ;;; base-dir
    (if (not (file-readable-p my-toolkit-dir))
        (message (format "wx2 directory not found: '%s'"  my-toolkit-dir))
      ;; other
                                        ;(require 'semantic-gcc) ;; not @emacs30-bundled
      (require 'semantic/bovine/gcc)
      (require 'semantic/bovine/c)
      ;; other
      (semantic-add-system-include my-toolkit-dir 'c++-mode)
      (semantic-add-system-include my-toolkit-dir 'c-mode)
      ;; preprocessor macro
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLEXPORT" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_CORE" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_FWD_CORE" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_BASE" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_FWD_BASE" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_FWD_XML" . ""))
      (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("WXDLLIMPEXP_ADV" . ""))
      ;;; my-toolkit-dir parent
      (semantic-add-system-include my-toolkit-dir-parent 'c++-mode)
      ;; Implicitly adding the header files to get completion working
      ;; Adding all include files in gtk directory
      (DE-imply-includes-in-directory (concat my-toolkit-dir "/gtk")))))

;;; WIP (it failed)
(defun cedet-lambda/load-gtk2 ()
  "setup gtk when in need."
  (interactive)
  (let ((my-toolkit-dir "/usr/include/gtkmm-3.0")) 
    (if (not (file-readable-p my-toolkit-dir))
        (message (format "gtkmm directory not found: '%s'"  my-toolkit-dir))
      (semantic-add-system-include my-toolkit-dir 'c++-mode)
      (semantic-add-system-include my-toolkit-dir 'c-mode)
      )))
;;; WIP (it failed)
(defun cedet-lambda/load-gtk ()
  "setup gtk when in need."
  (interactive)
  (let ( (cedet-sys-include-dirs (list
                                  "/usr/include"
                                  "/usr/include/bits"
                                  "/usr/include/glib-2.0"
                                  "/usr/include/gnu"
                                  "/usr/include/gtk-2.0"
                                 ;;;"/usr/include/gtk-2.0/gdk-pixbuf"
                                  "/usr/include/gtk-2.0/gtk"
                                  "/usr/include/gtkmm-3.0"
                                  "/usr/local/include")))
    (mapc (lambda (dir)
            (semantic-add-system-include dir 'c++-mode)
            (semantic-add-system-include dir 'c-mode))
          cedet-sys-include-dirs)))
;;; minimial-cedet-config.el ends here

In GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.18.2, Xaw3d scroll bars) of 2025-03-13 built on huana84
System Description: Arch Linux

Configured using:
 'configure --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
 --localstatedir=/var --with-cairo --with-harfbuzz --with-libsystemd
 --with-wide-int --with-native-compilation=aot --with-modules
 --with-x-toolkit=lucid --with-tree-sitter 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3
 -Wformat -Werror=format-security -fstack-clash-protection
 -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
 -flto=auto' 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed
 -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XAW3D XDBE XIM XINPUT2 XPM
LUCID ZLIB

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C++//l

Minor modes in effect:
  global-semanticdb-minor-mode: t
  global-semantic-idle-scheduler-mode: t
  semantic-idle-scheduler-mode: t
  semantic-mode: t
  gpm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: linux
  auto-encryption-mode: t
  auto-compression-mode: t
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822
mml mml-sec epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils semantic/analyze/complete
semantic/db-typecache imenu semantic/ia semantic/senator
semantic/decorate/mode semantic/decorate pulse color dired-aux dired
dired-loaddefs semantic/tag-file semantic/db-file data-debug ring
cedet-files semantic/bovine/c hideif cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
semantic/bovine/c-by semantic/lex-spp semantic/bovine
semantic/analyze/refs semantic/db-find semantic/db-ref
semantic/bovine/gcc semantic/dep inversion semantic/db-mode
semantic/idle semantic/analyze semantic/sort semantic/scope
semantic/analyze/fcn semantic/db eieio-base semantic/format ezimage
semantic/tag-ls semantic/find semantic/ctxt semantic/util-modes
semantic/util semantic pp semantic/tag semantic/lex semantic/fw cl-extra
help-mode mode-local find-func cedet ffap thingatpt url-parse
auth-source cl-seq eieio eieio-core cl-macs icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars misearch
multi-isearch cl-loaddefs cl-lib t-mouse term/linux rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
touch-screen tool-bar dnd fontset image regexp-opt fringe tabulated-list
replace newcomment text-mode lisp-mode prog-mode register page tab-bar
menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse
jit-lock font-lock syntax font-core term/tty-colors frame minibuffer
nadvice seq simple cl-generic indonesian philippine cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop
case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo x-toolkit xinput2 x multi-tty move-toolbar
make-network-process native-compile emacs)

Memory information:
((conses 16 676210 286873) (symbols 48 14401 0)
 (strings 32 84648 21589) (string-bytes 1 1798802) (vectors 16 41211)
 (vector-slots 8 287772 187871) (floats 8 145 294)
 (intervals 56 961 349) (buffers 992 22))