[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inserting code based on syntactic information in cc-mode

From: Alan Mackenzie
Subject: Re: inserting code based on syntactic information in cc-mode
Date: Fri, 11 Dec 2009 18:38:32 +0000 (UTC)
User-agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.11-RELEASE (i386))

SameerDS <address@hidden> wrote:
> Hello,

> I want to write elisp functions that can insert code based on the
> syntactic information at the point where they are invoked. For
> example, typing an opening brace at the start of a function definition
> should automatically insert the closing brace and put point on a new
> line between the two. But when an opening brace is typed at the start
> of a class description, it should also insert a semi-colon after the
> closing brace. Such a function might be easily written as a skeleton.
> What I need is a way to inspect the local syntactic information when
> the '{' key is pressed and then call the appropriate function.

> For this, I've been going through the documentation for CC-mode
> looking for a function that returns the syntax information for the
> current line. Basically a function that is equivalent to c-show-
> syntactic-information, but which can be used in elisp code directly. I
> couldn't find such a function ... is there a way to do this at all in
> CC-mode?

The function you need is `c-guess-basic-syntax', which is in the file
cc-engine.el.  The innards of that function aren't for the faint hearted.

> Sameer.

Alan Mackenzie (Nuremberg, Germany).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]