[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 2 styles of string literals, using cc-mode
From: |
jrwats |
Subject: |
Re: 2 styles of string literals, using cc-mode |
Date: |
Fri, 12 Dec 2008 22:01:32 -0800 (PST) |
User-agent: |
G2/1.0 |
On Oct 21, 9:54 am, yary <not....@gmail.com> wrote:
> 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?
ping. I need this too! Has anyone figured this out yet? I suppose I
could start investigating some emacs-lisp source code...
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: 2 styles of string literals, using cc-mode,
jrwats <=