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: How to disable multi-line string literal in c-mode and c++-mode? Date: Tue, 18 Aug 2009 19:35:02 +0000 Message-ID: <20090818193501.GA2475@muc.de> References: <4a7f28df-9e34-4500-9038-199401f60d90@c1g2000yqi.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1250623980 28662 80.91.229.12 (18 Aug 2009 19:33:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Aug 2009 19:33:00 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: wewwew Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 18 21:32:53 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 1MdUQM-00034m-6m for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Aug 2009 21:32:50 +0200 Original-Received: from localhost ([127.0.0.1]:37188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MdUQL-0004f4-Ib for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Aug 2009 15:32:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MdUPr-0004YY-LU for help-gnu-emacs@gnu.org; Tue, 18 Aug 2009 15:32:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MdUPm-0004Iq-ME for help-gnu-emacs@gnu.org; Tue, 18 Aug 2009 15:32:19 -0400 Original-Received: from [199.232.76.173] (port=46606 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MdUPm-0004IM-IR for help-gnu-emacs@gnu.org; Tue, 18 Aug 2009 15:32:14 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:2903 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MdUPm-0005zB-3q for help-gnu-emacs@gnu.org; Tue, 18 Aug 2009 15:32:14 -0400 Original-Received: (qmail 43722 invoked by uid 3782); 18 Aug 2009 19:32:08 -0000 Original-Received: from acm.muc.de (pD9E52EC7.dip.t-dialin.net [217.229.46.199]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Tue, 18 Aug 2009 21:32:07 +0200 Original-Received: (qmail 14960 invoked by uid 1000); 18 Aug 2009 19:35:02 -0000 Content-Disposition: inline In-Reply-To: <4a7f28df-9e34-4500-9038-199401f60d90@c1g2000yqi.googlegroups.com> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 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:67253 Archived-At: 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. CC 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. > I am programming using noweb, where LaTeX and C++ sources are mixed > together. When 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. I > would like to disable this multi-line string literals in c++-mode. I don't know noweb. Is there any easy and reliable way to recognise the LaTeX bits within the source file? If so, maybe the mechanism used to neutralize lines like #define QUOTE " could be adapted. The above, fully legitimate, line used to cause the following lines to be fontified as strings. > Appreciate any help. > -Wenguang -- Alan Mackenzie (Nuremberg, Germany).