Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting csharp-mode Emacs syntax highlighting working

Tags:

c#

emacs

mono

elisp

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.

like image 824
Jared Updike Avatar asked Jul 14 '09 05:07

Jared Updike


2 Answers

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

like image 57
danielpoe Avatar answered Nov 19 '22 21:11

danielpoe


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.

like image 30
jrockway Avatar answered Nov 19 '22 21:11

jrockway