* cc-mode and imenu tags for functions and classes
@ 2009-10-05 8:45 Marc Dürner
0 siblings, 0 replies; only message in thread
From: Marc Dürner @ 2009-10-05 8:45 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1726 bytes --]
Hello,
In many C and C++ headers it is quite common to use a macro to hide special
compiler attributes for functions or classes. It would be great, if support
for this could be added to cc-mode. Maybe there is a different solution to
this problem.
For example:
class MY_API MyClass
{};
MY_API void func();
For gcc MY_API expands to __attribute__ for visiblity, or when the VC
compilers or MIN-GW are used the macro expands to the appropriate declspec.
Unfortunately, the imenu regexps in cc-menus.el fail to detect such
attributed classes and functions. I could modify the regexp in cc-menu.el to
make this work. I added this to my .emacs:
(defvar my-c++-class-expression
`("Class"
, (concat
"^[ \t]*" ; <<==== changed to allow
macro
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template
<...>'
"\\(class\\|struct\\)[ \t]+"
"\\([A-Z_]+[ \t]+\\)?" ; there may be a macro
"\\(" ; the string we want to get
"[" c-alnum "_]+" ; class name
"\\(<[^>]+>\\)?" ; possibly explicitly
specialized
"\\)"
"\\([ \t\n]\\|\\\\\n\\)*[:{]"
) 4)
"IMenu expression for C++ classes.")
(add-hook 'c-mode-common-hook
(lambda ()
(add-to-list 'imenu-generic-expression my-c++-class-expression)))
This seems to work. But I wasn't able to make it work for functions (like
'MY_API void func();' as shown above).
How could the rexexp in cc-menus.el be changed to make it work with
functions?
Is there a different way to make it work? (like telling it to simply ignore
"MY_API")
regards,
Marc
[-- Attachment #2: Type: text/html, Size: 2043 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-10-05 8:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-05 8:45 cc-mode and imenu tags for functions and classes Marc Dürner
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.