unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: SameerDS <sameerds@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: inserting code based on syntactic information in cc-mode
Date: Mon, 23 Nov 2009 01:38:19 -0800 (PST)	[thread overview]
Message-ID: <af0b487e-69c2-4252-b4d3-8c5f25cf772b@o9g2000prg.googlegroups.com> (raw)

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?

Sameer.


             reply	other threads:[~2009-11-23  9:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-23  9:38 SameerDS [this message]
2009-11-23  9:44 ` inserting code based on syntactic information in cc-mode 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
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=af0b487e-69c2-4252-b4d3-8c5f25cf772b@o9g2000prg.googlegroups.com \
    --to=sameerds@gmail.com \
    --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).