From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: yary Newsgroups: gmane.emacs.help Subject: 2 styles of string literals, using cc-mode Date: Tue, 21 Oct 2008 10:54:10 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1723d5b8-6bee-4ff0-9128-525da8a7b83c@i20g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1224614489 3271 80.91.229.12 (21 Oct 2008 18:41:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Oct 2008 18:41:29 +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 Oct 21 20:42:27 2008 connect(): Connection refused 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 1KsMBE-0007OE-Et for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Oct 2008 20:42:08 +0200 Original-Received: from localhost ([127.0.0.1]:33051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsMA9-0006UO-2D for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Oct 2008 14:41:01 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!i20g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 49 Original-NNTP-Posting-Host: 65.208.210.98 Original-X-Trace: posting.google.com 1224611650 21102 127.0.0.1 (21 Oct 2008 17:54:10 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 21 Oct 2008 17:54:10 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i20g2000prf.googlegroups.com; posting-host=65.208.210.98; posting-account=d6bTuAkAAADNFwa37uXnhaYqYjfOS8nU User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; MS-RTC LM 8; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022),gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:163653 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:58995 Archived-At: Hi all, I'm using csharp-mode by Moonfire games ( http://mfgames.com/linux/csharp-mode ), which is derived from cc-mode. C# has a "feature", two styles of strings. Regular strings are very much like C strings, starting and ending with double quotes, backslash escapes allowed inside. @"Verbatim literal strings look like this"- they have an at-sign just before the double-quote. Verbatim literal strings can have embedded newlines, regular strings can't. Backslashes have no special meaning inside verbatim literals, so: @"\x00" == "\\x00" @"foo\" == "foo\\" I haven't hacked much cc-mode or elisp in general, still it was pretty simple to get multiline verbatim literals working: ;; Can't escape a newline in a regular string (c-lang-defconst c-string-escaped-newlines csharp nil) ;; Literal strings can be multiline without escaping (c-lang-defconst c-multiline-string-start-char csharp ?@) I had expected the @ to fontify the same as the " in @" after adding the following, but these seem to have made no difference: ;; Start of a comment or any string literal- copied from cc-lang, added @? before \" (c-lang-defconst c-literal-start-regexp csharp (concat (c-lang-const c-comment-start-regexp) "\\|" (if (memq 'gen-string-delim c-emacs-features) "@?\"|" "@?\""))) ;; add verbatim string literal to primary regexp (c-lang-defconst c-primary-expr-regexp csharp (concat (c-lang-const c-primary-expr-regexp) "\\|@\"")) ... and I have no clue how to tell emacs to change the syntax of \ inside a verbatim literal in csharp mode, so it won't be an escape anymore. I took a look at cc-engine.el to get a clue as to how it works, but its elisp is too advanced for me. Any pointers?