* 2 styles of string literals, using cc-mode
@ 2008-10-21 17:54 yary
2008-12-13 6:01 ` jrwats
0 siblings, 1 reply; 2+ messages in thread
From: yary @ 2008-10-21 17:54 UTC (permalink / raw)
To: help-gnu-emacs
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?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: 2 styles of string literals, using cc-mode
2008-10-21 17:54 2 styles of string literals, using cc-mode yary
@ 2008-12-13 6:01 ` jrwats
0 siblings, 0 replies; 2+ messages in thread
From: jrwats @ 2008-12-13 6:01 UTC (permalink / raw)
To: help-gnu-emacs
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...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-12-13 6:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-21 17:54 2 styles of string literals, using cc-mode yary
2008-12-13 6:01 ` jrwats
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.