* Check if inside a function definition
@ 2008-11-27 14:39 Nordlöw
2008-11-27 15:06 ` Richard Riley
2008-11-27 15:46 ` Alan Mackenzie
0 siblings, 2 replies; 3+ messages in thread
From: Nordlöw @ 2008-11-27 14:39 UTC (permalink / raw
To: help-gnu-emacs
Is there a function that check whether I am standing inside a function
in C/C++?
Is c-in-function-trailer-p the best Emacs can currently do?
/Nordlöw
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Check if inside a function definition
2008-11-27 14:39 Check if inside a function definition Nordlöw
@ 2008-11-27 15:06 ` Richard Riley
2008-11-27 15:46 ` Alan Mackenzie
1 sibling, 0 replies; 3+ messages in thread
From: Richard Riley @ 2008-11-27 15:06 UTC (permalink / raw
To: help-gnu-emacs
Nordlöw <per.nordlow@gmail.com> writes:
> Is there a function that check whether I am standing inside a function
> in C/C++?
>
> Is c-in-function-trailer-p the best Emacs can currently do?
>
> /Nordlöw
Look up the "Which Function" menu option in Senator/modes having loaded
Senator via the CEDET package. Lots of nice formatting goodies there
but can be a tad confusing at times (senator, semantic etc - it still
confuses me:-;).
See here for details:
http://cedet.sourceforge.net/
--
important and urgent problems of the technology of today are no longer the satisfactions of the primary needs or of archetypal wishes, but the reparation of the evils and damages by the technology of yesterday. ~Dennis Gabor, Innovations: Scientific, Technological and Social, 1970
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Check if inside a function definition
2008-11-27 14:39 Check if inside a function definition Nordlöw
2008-11-27 15:06 ` Richard Riley
@ 2008-11-27 15:46 ` Alan Mackenzie
1 sibling, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2008-11-27 15:46 UTC (permalink / raw
To: help-gnu-emacs
Nordl?w <per.nordlow@gmail.com> wrote:
> Is there a function that check whether I am standing inside a function
> in C/C++?
Yes.
> Is c-in-function-trailer-p the best Emacs can currently do?
No. :-)
The function you want is `c-where-wrt-brace-construct', the very next
function after `c-in-function-trailer-p' in cc-cmds.el. It returns a
symbol as detailed in the function's header comment:
;; Return one of these symbols:
;; at-header : we're at the start of a function's header.
;; in-header : we're inside a function's header, this extending right
;; up to the brace. This bit includes any k&r declarations.
;; in-block : we're inside a function's brace block.
;; in-trailer : we're in the area between the "}" and ";" of something
;; like "struct foo {...} bar, baz;".
;; at-function-end : we're just after the closing brace (or semicolon) that
;; terminates the function.
;; outwith-function: we're not at or in any function. Being inside a
;; non-brace construct also counts as 'outwith-function'.
'at-header, 'at-function-end and 'outwith-function, I think, all count as
not being being inside a function, though depending on what you want,
you might prefer either or both of these boundary symbols to cound as
"in".
This function is not currently regarded as being in the "public
interface" part of CC Mode, but I think I'm likely to make it such a
function soon.
> /Nordl?w
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-27 15:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-27 14:39 Check if inside a function definition Nordlöw
2008-11-27 15:06 ` Richard Riley
2008-11-27 15:46 ` Alan Mackenzie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).