tags:

views:

781

answers:

3

Googling "csharp mode emacs" yields the page

http://www.emacswiki.org/emacs/CSharpMode

which includes a few links to various downloadable emacs lisp files. The 2005 link (DylanMoonfire) is broken, so I downloaded:

http://lists.ximian.com/pipermail/mono-list/2002-May/006182.html

as ~/.emacslib/csharp-mode.el

and added:

(autoload 'csharp-mode "csharp-mode"
  "Major mode for editing C# code." t)
(setq auto-mode-alist (cons '( "\\.cs\\'" . csharp-mode ) auto-mode-alist ))

to my .emacs file (anywhere, beginning, middle or end). I attempt to edit a new text file called "t.cs" and I get the error:

File mode specification error: (error "Buffer t.cs is not a CC Mode buffer (c-set-style)")

and no syntax highlighting. I'm not well versed in emacs-lisp but I know enough to install support for loads of language modes and csharp-mode is just not playing nice compared to every other language mode I've installed.

I was getting excited to play with Mono on my Mac and ran into this ridiculous barrier! Anyone out there know how to get decent support for C# syntax highlighting in emacs?

Note: I'm using a MacBook Pro running Emacs 22.1.1 on OS X Leopard.

+1  A: 

What you have seems to be very outdated. It's too bad that the more up-to-date version was not hosted somewhere safer, like the Emacs core, EmacsWiki, or Github.

But anyway, you might as well try asking on #emacs (Freenode) and see if someone can send you the more up-to-date file.

jrockway
Now hosted where it belongs, on EmacsWiki (care of danielpoe).
Jared Updike
+8  A: 

I found a more recent version of csharp-mode 0.7.0, go to the end of the page and download as plain text. Haven't tried loading the mode however.

Just uploaded the code to emacswiki as well: charp-mode.el

danielpoe
This is the one I use. (and I get syntax highlighting)
Cheeso
Thanks for updating that page for future users. Thanks for the reminded to download as plain text, with that weird ^L in there.
Jared Updike
FYI Csharp-mode.el is now v0.7.2. Still available at http://www.emacswiki.org/emacs/csharp-mode.el . It's improved in various ways, includes more reliable indenting, better fontification, and automatic xml code doc templating. No code-completion ("intellisense") ... yet?
Cheeso
A: 

I made a slight modification to make Tab indent 4 spaces and deal with braces correctly, so now hitting tab on any line "does the right thing" with respect to conventions in Visual Studio.

http://www.updike.org/files/csharp-mode.el

Jared Updike