comp.emacs
[Top] [All Lists]

how to find in cc-mode what is the function name at given point

Subject: how to find in cc-mode what is the function name at given point
From: ""
Date: Thu, 7 Aug 2008 14:38:59 -0700 PDT
Newsgroups: comp.emacs

Dear Experts,
i would like to locate a function name currently being edited in cc-
mode. I had an idea that walking back by compound-parenthesis ({)
would give me a starting position where to look for function
declaration. However this does not work because you never know in what
sub-statement you are and what is the top-level parenthesis. then i
looked into cc-mode sources and I have found 'c-show-syntactic-
information'. This gives what I need (looking for defun-open and its
anchor position) so I can reach the beginning of the function and by
regular expressions look for class and function declarations.
The problem with this solution is, that if the function is messy -
like written in a single line, whatever cursor position is inside such
function, I never get 'defun-open'. Instead I get ('topmost-intro'),
with anchor point showing at the end of preceding function.

is there an elegant way how to extract the belonging class(es) and
function name of the code appearing at position of cursor?

Any help very appreciated..
thanks
d.

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy