From: yary <not.com@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: 2 styles of string literals, using cc-mode
Date: Tue, 21 Oct 2008 10:54:10 -0700 (PDT) [thread overview]
Message-ID: <1723d5b8-6bee-4ff0-9128-525da8a7b83c@i20g2000prf.googlegroups.com> (raw)
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?
next reply other threads:[~2008-10-21 17:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-21 17:54 yary [this message]
2008-12-13 6:01 ` 2 styles of string literals, using cc-mode jrwats
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=1723d5b8-6bee-4ff0-9128-525da8a7b83c@i20g2000prf.googlegroups.com \
--to=not.com@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.