unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: help-gnu-emacs@gnu.org
Subject: Re: inserting code based on syntactic information in cc-mode
Date: Fri, 11 Dec 2009 18:38:32 +0000 (UTC)	[thread overview]
Message-ID: <hfu3j8$15op$1@colin2.muc.de> (raw)
In-Reply-To: af0b487e-69c2-4252-b4d3-8c5f25cf772b@o9g2000prg.googlegroups.com

SameerDS <sameerds@gmail.com> 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).



  parent reply	other threads:[~2009-12-11 18:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-23  9:38 inserting code based on syntactic information in cc-mode SameerDS
2009-11-23  9:44 ` Joost Kremers
2009-11-23  9:58   ` SameerDS
2009-11-23 10:42 ` Pascal J. Bourguignon
2009-11-23 11:03   ` SameerDS
2009-12-11 11:16   ` SameerDS
2009-12-11 16:42     ` Lennart Borgman
2009-12-11 17:09     ` harven
2009-12-11 18:38 ` Alan Mackenzie [this message]
2009-12-12  3:14   ` SameerDS

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='hfu3j8$15op$1@colin2.muc.de' \
    --to=acm@muc.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).