From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: inserting code based on syntactic information in cc-mode Date: Fri, 11 Dec 2009 18:38:32 +0000 (UTC) Organization: muc.de e.V. Message-ID: References: NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1260557318 28415 80.91.229.12 (11 Dec 2009 18:48:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Dec 2009 18:48:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 11 19:48:32 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NJAXQ-00070P-PT for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Dec 2009 19:48:25 +0100 Original-Received: from localhost ([127.0.0.1]:52640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NJAXQ-0005el-HE for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Dec 2009 13:48:24 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!goblin3!goblin2!goblin.stu.neva.ru!feeder.erje.net!newsfeed.freenet.de!news.tu-darmstadt.de!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 28 Original-NNTP-Posting-Host: marvin.muc.de Original-X-Trace: colin2.muc.de 1260556712 38681 2001:608:1000::2 (11 Dec 2009 18:38:32 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: Fri, 11 Dec 2009 18:38:32 +0000 (UTC) User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.11-RELEASE (i386)) Original-Xref: news.stanford.edu gnu.emacs.help:175528 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70604 Archived-At: SameerDS 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).