From: jrwats <jrwats@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: 2 styles of string literals, using cc-mode
Date: Fri, 12 Dec 2008 22:01:32 -0800 (PST) [thread overview]
Message-ID: <cc0e307f-dcde-4a63-8806-ecd4efd54bcf@n33g2000pri.googlegroups.com> (raw)
In-Reply-To: 1723d5b8-6bee-4ff0-9128-525da8a7b83c@i20g2000prf.googlegroups.com
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 parent reply other threads:[~2008-12-13 6:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-21 17:54 2 styles of string literals, using cc-mode yary
2008-12-13 6:01 ` jrwats [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc0e307f-dcde-4a63-8806-ecd4efd54bcf@n33g2000pri.googlegroups.com \
--to=jrwats@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.