From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: wewwew Newsgroups: gmane.emacs.help Subject: Re: How to disable multi-line string literal in c-mode and c++-mode? Date: Tue, 18 Aug 2009 13:40:16 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2307dce5-2043-446f-9073-2b9bc4d18cbc@l35g2000pra.googlegroups.com> References: <4a7f28df-9e34-4500-9038-199401f60d90@c1g2000yqi.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1250628053 9471 80.91.229.12 (18 Aug 2009 20:40:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Aug 2009 20:40:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 18 22:40:46 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 1MdVU5-0002AA-NH for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Aug 2009 22:40:46 +0200 Original-Received: from localhost ([127.0.0.1]:51659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MdVU5-0007IA-1l for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Aug 2009 16:40:45 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!l35g2000pra.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-NNTP-Posting-Host: 17.201.24.19 Original-X-Trace: posting.google.com 1250628017 21542 127.0.0.1 (18 Aug 2009 20:40:17 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 18 Aug 2009 20:40:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l35g2000pra.googlegroups.com; posting-host=17.201.24.19; posting-account=RZ5uTwkAAACKKd_1JWs8luP2Ks9v8SYd User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:172081 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:67255 Archived-At: On Aug 18, 12:35=A0pm, Alan Mackenzie wrote: > Hi, > > On Tue, Aug 18, 2009 at 08:21:01AM -0700, wewwew wrote: > > Hi, > > How can I disable multi-line string literals in c-mode and c++-mode, > > and treat the end of line as the end of string literal? > > This is not simple. =A0CC Mode uses the "syntax mechanism" of Emacs (See > the chapter "Syntax Tables" in the Elisp manual if you're interested), > which does things like matching up parentheses, recognising comments and, > in particular, recognising strings. > > To modify this string recognition, you'd have to identify the EOLs which > act as string terminators and individually mark them as such (by giving > them a "string" syntax-table property). > > You would need to modify CC Mode (by adding this option) to achieve this. It is not clear to me how easy to do that. Can I disable all string literals? > > > I am programming using noweb, where LaTeX and C++ sources are mixed > > together. =A0When editing the code part, the buffer uses c++-mode, but > > any single quote in the text is treated as start or end of string > > literal, so many of my code chunks are rendered as string literals. =A0= I > > would like to disable this multi-line string literals in c++-mode. > > I don't know noweb. =A0Is there any easy and reliable way to recognise th= e > LaTeX bits within the source file? =A0If so, maybe the mechanism used to > neutralize lines like > > =A0 =A0 #define QUOTE " > > could be adapted. =A0The above, fully legitimate, line used to cause the > following lines to be fontified as strings. I could also put a LaTeX comment in the text to do this: %' However, I would prefer not to use such hacks, because whenever I add/ remove quote in LaTeX text, the whole font colors of C/C++ code is messed up again. All C/C++ code are within such blocks: << some text >>=3D // C/C++ code here @ Where the "<<" and "@" always start on the first column. Ideally, C/C+ +-mode should only fontify chunks within the "<<" and "@". Is that possible? Thanks! -Wenguang > > > Appreciate any help. > > -Wenguang > > -- > Alan Mackenzie (Nuremberg, Germany).