From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: SameerDS Newsgroups: gmane.emacs.help Subject: Re: inserting code based on syntactic information in cc-mode Date: Fri, 11 Dec 2009 19:14:39 -0800 (PST) Organization: http://groups.google.com Message-ID: <2a1dcb7e-cf61-4df1-8aeb-5de852f92df6@y32g2000prd.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1260589252 19960 80.91.229.12 (12 Dec 2009 03:40:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Dec 2009 03:40:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 12 04:40:45 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 1NJIqa-0004nW-RN for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Dec 2009 04:40:45 +0100 Original-Received: from localhost ([127.0.0.1]:43634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NJIqa-0004jb-ON for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Dec 2009 22:40:44 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!y32g2000prd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 26 Original-NNTP-Posting-Host: 59.184.15.252 Original-X-Trace: posting.google.com 1260587679 24247 127.0.0.1 (12 Dec 2009 03:14:39 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 12 Dec 2009 03:14:39 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y32g2000prd.googlegroups.com; posting-host=59.184.15.252; posting-account=9lo_eQoAAACfsIyHE_E4yJ4DVkC1bdwh User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/3.0.15, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:175538 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:70615 Archived-At: harven, that explains it. I don't have the lisp sources installed! Thanks! Alan, from the lisp snippet posted earlier it seems the evaluation of `c-guess-basic-syntax' is usually stored in the variable `c-syntactic- context', _if_ it is currently bound. This might have been done for performance reasons, and perhaps because the side-effects are important here. Repeating the "probably correct" way of using this, that was posted earlier on this thread. This is basically a guess based on how other functions in cc-mode do it ... which is why I was trying to reach the source for cc-mode. (defun get-syntax () (let ((c-parsing-error nil)) (if (boundp 'c-syntactic-context) ;; Use `c-syntactic-context' in the same way as ;; `c-indent-line', to be consistent. c-syntactic-context (c-save-buffer-state nil (c-guess-basic-syntax))))) BTW, yasnippets rocks! :) -- Sameer. http://sameer.sbuddhe.net/